Free Support Forum - aspose.com

HTMl to PDF is generating an empty PDF

Hi,

I am trying to convert an HTML to PDF. I am not getting any exception, but the pdf generated is empty.Can you please verify if the approach used is correct?

Code snippet.

String outputFileName;

public boolean convert(String fileName){

Document doc;

outputFileName = fileName+".pdf";

try {

doc=new Document(fileName, LoadFormat.HTML, null);

PdfOptions options = new PdfOptions();

options.setHeadingsOutlineLevels(3);

options.setExpandedOutlineLevels(1);

doc.saveToPdf(0, 1, outputFileName, options);

} catch (Exception e) {

System.out.println("Exception occurred while file conversion to pdf.");

e.printStackTrace();

}

return true;

}

I have attached the HTMl file. It has references to some images, but since i m able to attach only one file, i cant add those image files.


This message was posted using Page2Forum (attachment) from Aspose.Words for .NET and Java - Documentation

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words for Java. I use the following code for testing:

Document doc = new Document("C:\\Temp\\HtmlThumb.html", LoadFormat.HTML, null);

PdfOptions options = new PdfOptions();

options.setHeadingsOutlineLevels(3);

options.setExpandedOutlineLevels(1);

doc.saveToPdf(0, doc.getPageCount(), "C:\\Temp\\HtmlThumb.pdf", options);

You can download the latest version of Aspose.Words for Java from here:

http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/category1378.aspx

Best regards,

Hi,

I downloaded the latest zip Java 4.0.2 Beta. From that i am using the jar for jdk 1.5

But the pdf generated is still empty.i.e with a message

Evaluation Only. Created with Aspose.Words. Copyright 2003-2008 Aspose Pty Ltd.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Please try using the following line of code:

doc.saveToPdf(0, doc.getPageCount(), "C:\\Temp\\HtmlThumb.pdf", options);

In this case you will get all pages of your document. You use the evaluation version. If you would like to test Aspose.Words without the evaluation version limitations, you can request a 30-day Temporary License. Please refer to
http://www.aspose.com/corporate/purchase/faqs/temporary-license.aspx

Best regards,