How to scale to fit HTML table to pdf


i am using Aspose PDF .NET to convert my HTML tables into PDF.

i am trying to use the Text Generator and input a HTML string to the generator.

when i open the generated PDF file, the table seems to overflow out of the page range and the alignment for the table cells when haywire.

The HTML table (application form) is a huge table that will span across about 4-6 pages.

Need some help on what to set so that the table will fit into the pdf

it seems that if i manually changing the width to be in px of some

the table will be able to fit into the pdf. is there any setting to set such that the pdf text generator is able to obey the css width % rule?

just to update after using some of the following option i am able to convert the HTML to PDF with decent looks.

HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PageInfo.Margin.Bottom = 1;
htmlLoadOptions.PageInfo.Margin.Top = 1;
htmlLoadOptions.PageInfo.Margin.Left = 1;
htmlLoadOptions.PageInfo.Margin.Right = 1;
htmlLoadOptions.PageInfo.IsLandscape = true;
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), htmlLoadOptions);

What i am unsure of is, the html is a html string copy from a html file. when i directly opened this html file the layout look prefectly ok. but if i convert the html markup and copy as string or even directly load the html file to the PDF the layout of the table gone haywire. is there any options for me to set such that the PDF will looks the same as when i open the html file.

For my case, i would need to use the html string way, as some data into the html contains dynamic variables

Hi Benjamin,

Thanks for contacting support.

Can you please share the resource HTML, so that we can test the scenario in our environment. We are sorry for this inconvenience. You may save the contents to some file and share the artifact, so that we can test the conversion in our environment.