Note that there are some explanatory texts on larger screens.

plurals
  1. POiText – HTML to PDF - Image is not displayed in PDF
    primarykey
    data
    text
    <p>I have a html page with text, image and I am parsing the HTML content to iText to generate the PDF. In the generated PDF,Included images are not getting displayed and , only the text is getting displayed. </p> <p>If I pass the absolute path like <strong>D:/Deiva/CRs/HTMLPage/article-101-horz.jpg</strong> then the image will get printed. But if I try to print the image from the server like </p> <p><code>http://localhost:8085/content/dam/article-101-h1.jpg or http://www.google.co.in/intl/en_ALL/images/logos/images_logo_lg.gif</code> </p> <p>then it is not getting printed in the PDF.</p> <p><strong>NOTE:</strong> I am using <strong>itextpdf-5.2.1.jar</strong> to generate the PDF.</p> <p><strong>My HTML Code (Article.html):</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Generate PDF with image using iText.&lt;/p&gt; &lt;img src="http://localhost:8085/content/dam/article-10-h1.jpg"&gt;&lt;/img&gt; &lt;img src="http://www.google.co.in/intl/en_ALL/images/logos/imgs_logo_lg.gif"&gt;&lt;/img&gt; &lt;img class="right horz" src="D:/Deiva/CRs/HTMLPage/article-101-horz.jpg"&gt;&lt;/img&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>I am using the below java code for generating the PDF:</strong></p> <pre><code>private void createPDF (){ String path = "D:/Deiva/Test.pdf"; PdfWriter pdfWriter = null; //create a new document Document document = new Document(); try { //get Instance of the PDFWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(path)); //document header attributes document.addAuthor("betterThanZero"); document.addCreationDate(); document.addProducer(); document.addCreator("MySampleCode.com"); document.addTitle("Demo for iText XMLWorker"); document.setPageSize(PageSize.LETTER); //open document document.open(); InputStream is = new FileInputStream("D:/Deiva/CRs/Oncology/Phase5/CR1/HTMLPage/Article.html"); // create new input stream reader InputStreamReader isr = new InputStreamReader(is); //get the XMLWorkerHelper Instance XMLWorkerHelper worker = XMLWorkerHelper.getInstance(); //convert to PDF worker.parseXHtml(pdfWriter, document, isr); //close the document document.close(); //close the writer pdfWriter.close(); } catch (Exception e) { e.printStackTrace(); } } </code></pre> <p>Please suggest a solution to display the image in PDF. </p> <p>Thanks in advance.</p> <p>Deiva</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload