----- Original Message -----
From: "Chris Farmer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 29, 2003 1:12
Subject: [iText-questions] Adding svg images to a table, revisited
>
> Thanks to Paulo for helping me get my table to display an SVG image
> several days ago. However, I'm having problems now extending my simple
> example to a more complicated one and I was hoping someone could point
> out what I'm doing wrong. Here's my goal...
>
> I have a framework that populates an iText Table object with iText Cell
> objects. The framework later goes back and adds the Cells to the
> "correct" place in a table. I am pretty confident that this part of my
> code works, since I can use it to successfully populate the cells with
> PNG-based images. Where I'm going crazy is trying to extend this to add
> SVG-based images to the cell. I took some code from these archives that
> uses the batik libraries and modified it to create an ImgTemplate from
> the resulting PdfTemplate object. The resulting pdf document shows what
> looks like empty images (apparently of the correct size) in my cells.
> Where am I screwing up here (efficiency aside... I'd just like something
> to work first!)? My code is pasted below.
>
>
> Thanks,
> Chris
>
>
>
>
> // "writer" is a valid PdfWriter object and was created with
> // the Document object I'm adding the Table and Cells to. It
> // was already opened with writer.open();
> //
> // width and height are ints, both set to 125.
> //
> // The c:\svg.svg file is a valid svg that is 125 x 125 pixels.
> //
> // m_columnData is a container that creates cells from Elements.
> // It works correctly if img is a PNG image.
>
> PdfContentByte cb = writer.getDirectContent();
>
> PdfTemplate template = cb.createTemplate(width, height);
> DefaultFontMapper mapper = new DefaultFontMapper();
> Graphics2D g2 = template.createGraphics(width, height);
> PrintTranscoder prm = new PrintTranscoder();
> prm.addTranscodingHint(PrintTranscoder.KEY_WIDTH, new Float(width));
> prm.addTranscodingHint(PrintTranscoder.KEY_HEIGHT, new Float(height));
> TranscoderInput ti = new TranscoderInput("file:///C:/svg.svg");
>
> prm.transcode(ti, null);
> PageFormat pg = new PageFormat();
> Paper pp= new Paper();
> pp.setSize(width, height);
> pp.setImageableArea(0, 0, width, height);
> pg.setPaper(pp);
> prm.print(g2, pg, 0);
> g2.dispose();
>
> ImgTemplate img = new ImgTemplate(template);
Put here:
img.setAbsolutePosition(0, 0);
cb.addImage(img);
If it shows the image then I'll need a complete runnable example to test it
here.
If it doesn't the svg is probably off limits.
Best Regards,
Paulo Soares
> m_columnData.addRow(img);
>
>
>
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions