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

Free Support Forum - aspose.com

HTML to PDF landscape not working

Hi,

I’m converting a HTML to a PDF and want to use landscape pages.

final ByteArrayInputStream bais = new ByteArrayInputStream(...)
final HtmlLoadOptions loadOptions = new HtmlLoadOptions();

loadOptions.setHtmlMediaType(HtmlMediaType.Print);
loadOptions.setEmbedFonts(true);
loadOptions.setPageLayoutOption(HtmlPageLayoutOption.FitToWidestContentWidth);

PageInfo pageInfo = new PageInfo();
pageInfo.setLandscape(true);

// Margin
MarginInfo marginInfo = new MarginInfo();
marginInfo.setTop(50);
marginInfo.setRight(50);
marginInfo.setBottom(50);
marginInfo.setLeft(50);
pageInfo.setMargin(marginInfo);

loadOptions.setPageInfo(pageInfo);

final com.aspose.pdf.Document htmlDocument = new com.aspose.pdf.Document(bais, loadOptions);

ByteArrayOutputStream transformedPdf = new ByteArrayOutputStream();
htmlDocument.save(transformedPdf);

transformedPdf.close();

... save result to disk ...

The resulting PDF does not contain landscape pages.
The margin config is taken into account, so I believe I’m configuring it correctly.
Can anyone point me in the right direction? Am I doing it ‘wrong’ or did I find a bug?

Tested with version 22.12 as 23.1 is not released yet for Java at the time of writing.

Thanks

@StijnVdd
Could you please provide example of HTML document which you are trying to convert

Hi,

Please find attached the HTML I’m using.
(zipped as it is not supported to upload HTML)
Invoice-123456789.zip (11.1 KB)

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-42450

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks a lot.

Our subscription is currently being renewed.
Once this is completed, can I raise a ticket to elevate PDFJAVA-42450 to “Paid Support policies” ?
What procedure should I follow to do this ?

Kind regards.

@StijnVdd
You can to create a new ticket on https://helpdesk.aspose.com/, it is not necessary to describe an issue again, please just point to the free forum thread where the issue was reported.