3

I am building a Java web service application in which I would like to convert the HTML file to PDF and send an email to a particular email address.

Conversion from XHTML to PDF.

                 try {

                    File outputFile = new File("D:\\Files\\Output_Files\\" + System.currentTimeMillis() + ".pdf");
                    OutputStream file = new FileOutputStream(outputFile);
                    Document document = new Document();
                    PdfWriter writer = PdfWriter.getInstance(document, file);
                    document.open();
                    InputStream is = new ByteArrayInputStream(htmlString.getBytes());
                    XMLWorkerHelper.getInstance().parseXHtml(writer, document,is);
                    document.close();
                    file.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

I have verified htmlString and it holds an exact HTML string.

Please review my HTML content here

The issue is that I am receiving the PDF but it does not have any content but an empty page.

Rakesh L
  • 1,136
  • 4
  • 18
  • 44

0 Answers0