Could you tell me what I need to change/which method does the sizing in the table
class so I can try to change it to work? I will need to do row spanning, so I either
need to change Table or use nested PdfPTable objects, correct?
Thanks for your help with the images.
"Paulo Soares" <[EMAIL PROTECTED]> wrote:
>Problem solved. The Table class attempts to fit the image to the cell size
>but in doing so it trashes the content and makes the image unusable for a
>second insertion. PdfPtable doesn't have that problem and you just have to
>add to pdfPTableTest the line:
>
>t.setWidthPercentage(85);
>
>to make the images show (you must not call normalTableTest though).
>
>The changed files are attached.
>
>Best Regards,
>Paulo Soares
>
>----- Original Message -----
>From: <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Cc: <[EMAIL PROTECTED]>
>Sent: Friday, July 26, 2002 23:37
>Subject: RE: [iText-questions] table w/ images formatting problem
>
>
>Paulo:
> �I have tried both table classes and cannot get them to work. �The
>table class displays the image in the right cell, while PdfPTable
>doesn't display the image at all. �The document size is A3, and
>therefore 842 units wide. �Each image is about 350 pixels wide. So,
>there should be space for both images...
>
>Here is the source code of the test I did, showing the image creation
>and table commands. �In the actual application, the images are captures
>from applets and/or java.awt.component subclasses, so they will either
>be imported into iText as PdfTemplate objects (preferable, since that
>class draws so neatly), or ImgRaw objects based on java.awt.Image
>objects. �I have also enclosed the image I use in the test class.
>
>import com.lowagie.text.*;
>import com.lowagie.text.pdf.*;
>
>import pdfconvert.*;
>import pdfconvert.htmltag.*;
>
>public class tabletest {
> � �public static void main(String[] args) throws Exception {
>
> � � � �// create the PDF file
> � � � �Document doc = new Document(PageSize.A3, 9, 9, 36, 36);
> � � � �PdfWriter pdf = PdfWriter.getInstance(doc, new
>java.io.FileOutputStream("htmltest.pdf"));
> � � � �doc.open();
>
> � � � �// create the image -- the images in the actual program will be
>either java.awt.Image
> � � � �// or PDFTemplate-based images ("ImgRaw" and "ImgTemplate" in
>iText, i think)
> � � � �java.awt.Image awtImg =
>java.awt.Toolkit.getDefaultToolkit().getImage("itext.jpg");
> � � � �Image img = Image.getInstance(awtImg, null);
> � � � �System.out.println("\nImage dimensions: width=" + img.width() +
>" height=" + img.height());
>
> � � � �// run table tests
> � � � �doc.add(new Chunk("Output from \"Table\" class"));
> � � � �normalTableTest(doc, img);
> � � � �doc.newPage();
> � � � �doc.add(new Chunk("Output from \"PdfPTable\" class"));
> � � � �pdfPTableTest(doc, img);
>
> � � � �// quit
> � � � �doc.close();
> � �}
>
> � �public static void pdfPTableTest(Document doc, Image img)
> � � � � � throws Exception
> � �{
> � � � �// table creation
> � � � �float[] colWidth = {410, 410};
> � � � �PdfPTable t = new PdfPTable(colWidth);
> � � � �PdfPCell c1 = new PdfPCell(img);
> � � � �PdfPCell c2 = new PdfPCell(img);
>
> � � � �// formatting stuff (if necessary ??)
>
> � � � �// add to table
> � � � �t.addCell(c1);
> � � � �t.addCell(c2);
> � � � �doc.add(t);
> � �}
>
> � �public static void normalTableTest(Document doc, Image img)
> � � � � � throws Exception
> � �{
> � � � �// table creation
> � � � �Table t = new Table(2);
> � � � �Cell c1 = new Cell(img);
> � � � �Cell c2 = new Cell(img);
>
> � � � �// formatting stuff (if necessary ??)
>
>
> � � � �// add to table
> � � � �t.addCell(c1);
> � � � �t.addCell(c2);
> � � � �doc.add(t);
> � �}
>}
>Paulo Soares <[EMAIL PROTECTED]> wrote:
>
>>If you are using PdfPTable there are several options. For Table it
>might be
>>more complicated. A short code snippet on how you are creating the
>table and
>>inserting the images would help.
>>
>>Best Regards,
>>Paulo Soares
>>
>>> -----Original Message-----
>>> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
>>> Sent: Thursday, July 25, 2002 23:55
>>> To: [EMAIL PROTECTED]
>>> Subject: [iText-questions] table w/ images formatting problem
>>>
>>> I am having a problem with creating a table that has 2 columns, each
>with
>>> an image. The images are of different types: some of them are
>>> template-based (from drawing an applet to a PdfTemplate) and some of
>them
>>> are iText supported GIFs and JPEGs. I am using PageSize.LETTER as
>the
>>> page size, and one image has a width of 214 pixels while the other is
>350
>>> pixels wide. The magins are set for 1 pixel. Since PageSize.LETTER
>is a
>>> rectangle with a width of 612, both should fit without resizing next
>to
>>> one another.
>>>
>>> When I create the images and insert them into a 2-column table, one
>of two
>>> things happens:
>>>
>>> 1) Only one cell shows, and it takes up the entire page width.
>>> 2) Both cells show, but one has no image in it.
>>>
>>> I have tried many different table settings, but none seem to allow
>both
>>> images to display. iText also seems to resize the images, even
>though
>>> this is unnecessary, since there is plenty of space. (It also
>resizes the
>>> images even when there is only one column!)
>>>
>>> I would appreciate some help with the table settings to make it
>render
>>> correctly. Another option I had though of was to create an image
>>> sub-class that would not allow itself to be resized, so that the
>table
>>> would try to resize the image (even when it doesn't need to) and
>would get
>>> back the full size image as it should be displayed. However, in
>order to
>>> do this, I would need to find the location in the table code where
>this is
>>> done so I can override the appropriate method(s).
>>>
>>> I have looked and will continue to pursue this and other solutions to
>this
>>> problem, and appreciate any assistance in this matter
>>>
>>> Ryan Johnston
>>>
>>>
>>>
>>> __________________________________________________________________
>>> Your favorite stores, helpful shopping tools and great gift ideas.
>>> Experience the convenience of buying online with Shop@Netscape!
>>> http://shopnow.netscape.com/
>>>
>>> Get your own FREE, personal Netscape Mail account today at
>>> http://webmail.netscape.com/
>>>
>>>
>>>
>>> -------------------------------------------------------
>>> This sf.net email is sponsored by: Jabber - The world's fastest
>growing
>>> real-time communications platform! Don't just IM. Build it in!
>>> http://www.jabber.com/osdn/xim
>>> _______________________________________________
>>> iText-questions mailing list
>>> [EMAIL PROTECTED]
>>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>>
>>-------------------------------------------------------
>>This sf.net email is sponsored by:ThinkGeek
>>Welcome to geek heaven.
>>http://thinkgeek.com/sf
>>_______________________________________________
>>iText-questions mailing list
>>[EMAIL PROTECTED]
>>https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>
>
>__________________________________________________________________
>Your favorite stores, helpful shopping tools and great gift ideas.
>Experience the convenience of buying online with Shop@Netscape!
>http://shopnow.netscape.com/
>
>Get your own FREE, personal Netscape Mail account today at
>http://webmail.netscape.com/
>
>
>
__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the
convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions