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

Free Support Forum - aspose.com

Overflow of Content and Enquiry regarding automatic orientation

Hi,
RTT5B-01-03-02-A1(1).zip (11.5 KB)

I have an issue while converting HTML to PDF in Aspose pdf for .net.

  1. During conversion, my table content overflows to next page, which doesn’t look good. Please let me know is there a way to either increase page size or counter this problem.

  2. There are few pages in html which are of landscape size and few are of portrait size, let me know if there’s a way to dynamically detect this and convert those html pages accordingly into landscape/portrait in PDF.

PFA copy of files to replicate the issue that i have been facing

@ganesha_prasad_lntte

Thanks for contacting support.

Please check following code snippet, where I have increased the Page Height, so that all HTML content can be displayed on single page. For your reference, I have also attached an output PDF document.

var loadoptions = new HtmlLoadOptions(dataDir);
loadoptions.PageInfo.Height = PageSize.PageLetter.Height * 2;
loadoptions.PageInfo.IsLandscape = true;
loadoptions.PageInfo.Margin = new MarginInfo(10, 10, 10, 10);

Document doc = new Document(dataDir + "RTT5B-01-03-02-A1(1).html", loadoptions);//MergePDF(docList);
doc.Save(dataDir + "HtmlToPdf_out.pdf");

HTMLToPDF_out.pdf (145.2 KB)

I am afraid that Aspose.Pdf supports no such feature to detect orientation/dimension of the HTML page and please note that it is quite difficult to determine exact height and width of the HTML page, as it depends upon many factors i.e screen resolution, CSS, responsiveness, etc. However as a workaround, you may check the page count of the PDF document (after conversion and before saving), specify its height and width as per your requirement and convert it again.

In case you face any issue while generating desired outputs, please feel free to let us know.

We are sorry for the inconvenience.