• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic