I solved it !

First I created a com.lowagie.text.Image object by this way:

...
String pathToImg = "c:\\tmp\logo.jpg";
Image logoImg = Image.getInstance(pathToImg); 
...

And I was getting the ArrayIndexOutOfBoundsException exception when printing
or viewing the PDF with PDFRender.

java.lang.ArrayIndexOutOfBoundsException: 766
        at
com.sun.pdfview.colorspace.IndexedColor.<init>(IndexedColor.java:72)
        at
com.sun.pdfview.colorspace.PDFColorSpace.getColorSpace(PDFColorSpace.java:154)



The solution is to create first a AWT Image and pass it to the getInstance
method of com.lowagie.text.Image : 

String pathToImg = "c:\\tmp\logo.jpg";
java.awt.Image awtImage =
Toolkit.getDefaultToolkit().createImage(pathToImg);
                        logoImg = Image.getInstance(awtImage, null); 




pepwallace wrote:
> 
> 
> I know that the bug is from PDFRenderer code but I have generated the same
> PDF with FOP and I can print the PDF ok with PDFRenderer ...   
> 
> 
> pepwallace wrote:
>> 
>> Hi there,
>> 
>>  
>> 
>> I have generated a PDF with iText. It has a header and a table. The
>> header has a 3 column table, and I have inserted an image in the first
>> one. First I inserted the image in a Pragraph, and then tried it with a
>> Chunk. In both cases, I can see the image in the generated PDF with
>> Acrobat Reader, but if I try to open or print the document with
>> PdfRenderer (https://pdf-renderer.dev.java.net/) the image des not
>> appear.
>> 
>>  
>> 
>> Furthermore, in the other 2 header columns I have some text. If I put an
>> image in the first column, the text in the second and third column
>> doesn´t appear when I view it with PDFRenderer (although it's generated
>> ok with iText). If I don´t put the image in the first column, the I can
>> see the text in the other 2 columns.
>> 
>>  
>> 
>> Has anyone generated an image in a header with iText and then can see it
>> with PDFRenderer ? I 'm using it to print the PDF directly from my java
>> application.
>> 
>>  
>> 
>> Thanks a lot !
>> 
>> 
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
>> Don't miss this year's exciting event. There's still time to save $100. 
>> Use priority code J8TL2D2. 
>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>> _______________________________________________
>> iText-questions mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>> 
>> Do you like iText?
>> Buy the iText book: http://www.1t3xt.com/docs/book.php
>> Or leave a tip: https://tipit.to/itexttipjar
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Image-desn%C2%B4t-appear-when-viewing-PDF-with-PDFRenderer-tp16673907p16761426.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to