We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Column width for html->pdf conversions

I am trying to convert an html report to pdf (Java aspose.word product) but the column widths and wrapping are not being converted properly. I am wondering if I can control this to make a readable pdf? With a prior product, I was able to use setHtmlWidth() to help control but event without that, the results were better. I am hoping to use this product so please let me know what I can do.

I tried using PdfSaveOptions with (setZoomBehaviour./setZoomFactor) but I don’t see any differences. The code I am using follows …

Document doc = new Document("testHtml.html");            
// easiest way to save to file
// using output stream
ByteArrayOutputStream out = new ByteArrayOutputStream();
// trying options
PdfSaveOptions options = new PdfSaveOptions();
doc.save(out, options);
byte[] dataForWriting = out.toByteArray();
FileUtils.writeByteArrayToFile(new File("testHtml.pdf"), dataForWriting);

I have also tried with just this …

Document doc = new Document("testHtml.html");
// easiest way to save to file

Please find before (html) and after (pdf) attached…

testHtml.zip (54.4 KB)

@alcea The problem occurs because page width is too small for the table in your HTML. You can adjust page size to get a better result. For example see the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

not sure if I like the product or the support better
Thanks so much

1 Like