• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Deivamani Arumugam
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Winston Gutkowski
Bartender
Pie
Posts: 10099
56
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic