HTML table column widths not carried across multiple pages

I am using Aspose.Pdf.Document to create a large PDF using HTML. I create a page object, set the margins and then add a HtmlFragment to it (containing quite a lot of HTML in a table). If the content of the HtmlFragment goes over more than one page the column widths of the tables don’t seem to be honored on anything but the first page, I was just wondering if I am doing something wrong. Please see sample code below:


Document oDoc = new Document();
Page oPage = oDoc.Pages.Add();
oPage.PageInfo.Margin = new MarginInfo() { Top = 400, Right = 100, Bottom = 200, Left = 100 };
oPage.PageInfo.Width = Aspose.Pdf.Generator.PageSize.A4Width;
oPage.PageInfo.Height = Aspose.Pdf.Generator.PageSize.A4Height;
HtmlFragment oHTML = new HtmlFragment(“A long html string goes here, in a HTML table with 2 columns, the first column has a set width, the html is large so spans multiple pages”);
oPage.Paragraphs.Add(oHTML);
oDoc.Save(“My File.pdf”, SaveFormat.Pdf);

The actual HTML I am using is:

test test test
test test test
test test test
 
test test test,
 
test test test
 
Ttest test test test test. Test test test test test test test test test test test test test test test test.
 
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test.
 
test test test test test test
 
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test. test test test test test test test test test test test test test test test test test test test test test, test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
 
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
 
 
test test test test test test test test test
 

test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test. test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test. test test test test test test test test test.  

test test test test test test
 
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
test test test test test test
 

test test test test test test test test test.

 
test test test test test test test test test:
 
·test test test test test test test test test test test test test test test test test test test test test test test test test test test.
 
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
 
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test leave.
 
test test test test test test. test test test test test test test test test test test test test test test test test test test test test
 
test test test test test test.

I have attached the PDF which is generated, as you can see the barcode is in the first column, but the width of this column is lost on the second page.


Thanks for the help
Alun

Hi Alun,


Thanks for contacting support.

I have tested the scenario where I have placed HTML contents inside HTML file and when using following code snippet, the resultant PDF is appearing as blank. Can you please share some sample project so that we can again test the scenario. We are sorry for this inconvenience.

[C#]

String FILE_NAME = “c:/pdftest/stream_out.html”;<o:p></o:p>

System.IO.TextReader objReader = new System.IO.StreamReader(FILE_NAME);

Document oDoc = new Document();

Page oPage = oDoc.Pages.Add();

oPage.PageInfo.Margin = new Aspose.Pdf.MarginInfo() { Top = 400, Right = 100, Bottom = 200, Left = 100 };

oPage.PageInfo.Width = Aspose.Pdf.Generator.PageSize.A4Width;

oPage.PageInfo.Height = Aspose.Pdf.Generator.PageSize.A4Height;

HtmlFragment oHTML = new HtmlFragment(objReader.ReadLine());//"A long html string goes here, in a HTML table with 2 columns, the first column has a set width, the html is large so spans multiple pages");

oPage.Paragraphs.Add(oHTML);

oDoc.Save("c:/pdftest/LargeHTML_Converted.pdf", SaveFormat.Pdf);

Hi,


Thanks for getting back to me. The code you have written calls the ReadLine method on the TextReader, this will only give you the first line of text from your file, if you open the file the first line of text is “”, this is why you document is blank when you convert it. Instead what you need to do is call the ReadToEnd method instead, this will return you all of the HTML and then once converted to PDF you should see the same thing that I am experiencing.

Thanks
Alun.

Hi Alun,


Thanks for your feedback. I have tested the scenario with your shared HTML text and noticed that table column width is same across the pages however page margin info is not being honored on subsequent pages. So I have logged a ticket PDFNEWNET-39362 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,