aspose file tools*
The moose likes XML and Related Technologies and the fly likes iText - HTML to PDF - Image is not displayed in PDF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "iText - HTML to PDF - Image is not displayed in PDF" Watch "iText - HTML to PDF - Image is not displayed in PDF" New topic
Author

iText - HTML to PDF - Image is not displayed in PDF

Deivamani Arumugam
Greenhorn

Joined: Mar 08, 2013
Posts: 4
I am having an html page with text, image and I am parsing the HTML content to iText to generate the PDF. In the PDF, image is not getting displayed, only the text is getting displayed.

If I pass the absolute path like D:/Deiva/CRs/HTMLPage/article-101-horz.jpg then the image will get printed. But if I try to print the image from the server like

http://localhost:8085/content/dam/article-101-h1.jpg or http://www.google.co.in/intl/en_ALL/images/logos/images_logo_lg.gif

then it is not getting printed in the PDF.

I am using itextpdf-5.2.1.jar to generate the PDF.

My HTML Code (Article.html):



I am using the below java code for generating the PDF:



Please suggest a solution to display the image in PDF.

Thanks in advance.

Deiva
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41529
    
  53
My guess would be that the XMLWorkerHelper class does not support retrieving remote images. Have you found anything in the documentation to indicate that it does?


Ping & DNS - my free Android networking tools app
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7653
    
  19

Deivamani Arumugam wrote:Please suggest a solution to display the image in PDF.

Well, I've never tried what you're doing, and I'm certainly no expert; but a glance at the documentation would suggest that you might need an ImageProvider.

However, beyond that, I have no idea. I'm also amazed that the API documentation is so poor for a product that touts itself as, among other things, "best documented".

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41529
    
  53
It's possible that better documentation is available for licensees - iText 5 is licensed under the Affero GPL which makes getting a license a requirement for just about all business use cases (unless you're prepared to distribute your source code).
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
Question too difficult for “beginning”: moving discussion. Not sure where to, so it might move again when somebody else works out where it belongs
Deivamani Arumugam
Greenhorn

Joined: Mar 08, 2013
Posts: 4
Hi Ulf Dittmer,

I found the below explanation in the iText XMLWorker Documentation.

XML Worker will only add pictures to the document if they are defined using a fully qualified URL.

What is the fully qualified URL here. Can you give some example for the fully qualified URL?
Deivamani Arumugam
Greenhorn

Joined: Mar 08, 2013
Posts: 4
Can anyone provide the sample code please.

I have googled, and could not able to find any example for the same. I have to complete this task within this week. Please help me.

Thanks in advance.
 
wood burning stoves
 
subject: iText - HTML to PDF - Image is not displayed in PDF