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

Free Support Forum - aspose.com

Overlap of 1st and 2nd rows when table goes over a page

Hi,


My company has use the Aspose.PDF product to PDF files. We are using the version 11.5.0.

My system prepare HTML codes including a table, and then use Aspose.PDF with the HTML codes to generate the PDF file.
For some cases, when a table size over 1 page, the 1st and 2nd row in the second page will be overlap as attached.

Below is the codes we use to call Aspose.PDF product

private Aspose.Pdf.Document ExportGridToPDF(Aspose.Pdf.Document pdf)
{
PDFData userData = Newtonsoft.Json.JsonConvert.DeserializeObject(this.hfDataHTML.Value);

Aspose.Pdf.HtmlLoadOptions htmlLoadOptions = new Aspose.Pdf.HtmlLoadOptions();

htmlLoadOptions.InputEncoding = “UTF-8”;

htmlLoadOptions.PageInfo.Margin = new Aspose.Pdf.MarginInfo(5, 5, 20, 20);
htmlLoadOptions.PageInfo.Width = pdf.Pages[1].PageInfo.Height;
htmlLoadOptions.PageInfo.Height = pdf.Pages[1].PageInfo.Width;
htmlLoadOptions.PageInfo.IsLandscape = true;
Aspose.Pdf.Document newPDF = null;

string strTemplate=System.IO.File.ReadAllText(Server.MapPath("~/FNA/PDFTemplate.html"));
if (this.hfIncomeTo.Value != null && this.hfIncomeTo.Value != “”)
{
strTemplate = strTemplate.Replace("", double.Parse(HttpUtility.HtmlDecode(this.hfIncomeFrom.Value)).ToString("#,##0.00"));
strTemplate = strTemplate.Replace("", double.Parse(HttpUtility.HtmlDecode(this.hfIncomeTo.Value)).ToString("#,##0.00"));
}
else if (this.hfLiquidAssetTo.Value != null && this.hfLiquidAssetTo.Value != “”)
{
strTemplate = strTemplate.Replace("", double.Parse(HttpUtility.HtmlDecode(this.hfLiquidAssetFrom.Value)).ToString("#,##0.00"));
strTemplate = strTemplate.Replace("", double.Parse(HttpUtility.HtmlDecode(this.hfLiquidAssetTo.Value)).ToString("#,##0.00"));
}
strTemplate = strTemplate.Replace("", this.hfIncludeRider.Value);
strTemplate = strTemplate.Replace("", double.Parse(HttpUtility.HtmlDecode(this.hfTargetProtection.Value)).ToString("#,##0"));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_typeproduct));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_protectionamount));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_policyterm));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_paymentterm));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_recommendproduct));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_recommendproductlist));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(ViewState[“ActualPremiumRemark”].ToString()));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_applicantage));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_applicantsex));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_applicantsmoking));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_insuredage));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_insuredsex));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(userData.pdf_insuredsmoking));
strTemplate = strTemplate.Replace("", HttpUtility.HtmlDecode(this.hfGenerateOthers.Value));


using (System.IO.MemoryStream stream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(strTemplate)))
{
newPDF = new Aspose.Pdf.Document(stream, htmlLoadOptions);
}
foreach(Aspose.Pdf.InteractiveFeatures.Forms.Field f in newPDF.Form.Fields)
{
if (f.Border != null)
{
f.Border.Width = 0;
f.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;
f.Color = Aspose.Pdf.Color.Transparent;
}

if (f is Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField)
{
Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField txtField = (Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField)f;

}
if (f is Aspose.Pdf.InteractiveFeatures.Forms.ComboBoxField)
{
Aspose.Pdf.InteractiveFeatures.Forms.ComboBoxField cboField = (Aspose.Pdf.InteractiveFeatures.Forms.ComboBoxField)f;
cboField.Width = 8;

}
}
newPDF.Flatten();
foreach(Aspose.Pdf.Page p in newPDF.Pages)
{
p.PageInfo.IsLandscape = true;

}
pdf.Pages.Add(newPDF.Pages);

return pdf;
}

Output sample and the HTML prepared by my system is attached for your reference.
Please study and help to solve, thanks.

Hi There,


Thanks for contacting support.

manmo:
My company has use the Aspose.PDF product to PDF files. We are using the version 11.5.0.

Please note that you are using a quite old version of the API, whereas it is always recommended to use latest version of the API which is Aspose.Pdf for .NET 17.4.0.

I have tried to run the code snippet which you have shared and found that there were missing/undefined objects in it. Though I have managed to convert your shared HTML into PDF by following code snippet with latest version of the API and I have observed the anomalies in generated output.

Aspose.Pdf.HtmlLoadOptions htmlLoadOptions = new Aspose.Pdf.HtmlLoadOptions();<o:p></o:p>

htmlLoadOptions.InputEncoding = "UTF-8";

htmlLoadOptions.PageInfo.Margin = new Aspose.Pdf.MarginInfo(5, 5, 20, 20);

htmlLoadOptions.PageInfo.IsLandscape = true;

Aspose.Pdf.Document newPDF = new Document();

string strTemplate = System.IO.File.ReadAllText(dataDir + "HTMLforASPOSE.html");

using (System.IO.MemoryStream stream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(strTemplate)))

{

newPDF = new Aspose.Pdf.Document(stream, htmlLoadOptions);

}

foreach (Aspose.Pdf.Page p in newPDF.Pages)

{

p.PageInfo.IsLandscape = true;

}

newPDF.Save(dataDir + "HTMLforASPOSE.pdf");


In the generated output, content was overlapped and for the sake of correction, I have logged an issue as PDFNET-42628 in our issue tracking system. We will further investigate the issue and keep you informed on the status of its resolution. Please be patient and spare us a little time. We are sorry for the inconvenience.


Best Regards,

Hi Asad Ali,


Thanks for your help, please keep update me if any solution found for my issue.

Best Regards,
Manmo

Hi Manmo,


Thanks for contacting support.

As soon as we have some definite updates regarding the resolution of earlier reported issue, we will surely update you within this forum thread.

Hi codewarior,

For my issue, is there any updates?
I found the latest update Aspose.Pdf for .NET 17.8, but the Release Note does not include my issue(PDFNET-42628), is this version can fix the issue?

Please let me know the progress, thanks.

Best Regards.

@manmo1

Thanks for your inquiry.

I am afraid that earlier logged issue has not been resolved yet due to large number of pending issues in the queue. Product team will surely plan to provide a fix against your issue as per their development schedule and as soon as we have some certain updates in this regard, we will let you know. Please be patient and spare us little time.

We are sorry for the inconvenience.