We have an application that inserts a paragraph into a table cell for .NET PDF generation.
The paragraph text comes in HTL format from a CK editor. This works fine most of the time, but we have one rather large (2 pages A4) instance with a couple of embedded PNG images inline which always renders the entire content twice when the PDF is generated.
Tests with similar length of HTML text without the embedded images renders fine.
Have tried updating to latest version of nuget package but no luck…please help,
@Efic_Helpdesk
Please provide the code snippet and file used
@Efic_Helpdesk
@Mohsin_Jawed
Thanks for the provided file.
I also need the code snippet you are using to reproduce issue.
Hi Segei, thanks for getting back to me. The basic code snippet that inserts the table, cell and paragraph is as follows:
var doc = new Aspose.Pdf.Document();
doc.PageInfo.Margin = new MarginInfo(35, 35, 35, 35);
var page = doc.Pages.Add();
var tab = new Table
{
ColumnWidths = "50% 50%",
ColumnAdjustment = ColumnAdjustment.Customized,
Border = new BorderInfo(BorderSide.All, .5f, Color.FromRgb(System.Drawing.Color.Black)),
DefaultCellPadding = new MarginInfo
{
Top = 5f,
Left = 5f,
Right = 5f,
Bottom = 5f
},
Margin = new MarginInfo(0, 15, 0, 0),
Left = 0
};
var r = tab.Rows.Add();
r.Border = new BorderInfo(BorderSide.Bottom, .5f, Color.FromRgb(System.Drawing.Color.Black));
Cell c = new Cell
{
ColSpan = 2
};
HtmlFragment hf = new HtmlFragment(testHtml2);
hf.VerticalAlignment = VerticalAlignment.Center;
c.Paragraphs.Add(hf);
r.Cells.Add(c);
page.Paragraphs.Add(tab);
using var s = File.OpenWrite("c:\\temp\\pdfgen\\test.pdf");
doc.Save(s);
The variable “testHtml2” contains the HTML content from the CK editor. I’ve been working on trying to generate a generic example of this content to reproduce the fault, but no luck so far - we only see the fault if:
- the two original inline PNG images are used (swapping them for others removes the fault)
- two specific lines of text between the inline images are included (there are others that don’t mattter)
- the table is appended to the original document content - you don’t see it if you just insert the table from the above code into a blank document.
So it’s clearly an edge case scenario where certain base 64 image content and perhaps some text characters from those sentences, plus the proceeding content create this scenario.
The content is commercailly confidential so I can’t share it on this forum unfortunately.
The only other thing I can think of is to modify the the original code to parse the HTML content and deconstruct it into discrete paragraphs (there are about 10) by looking for <p>
tags, and insert them one by one into the cell programatically.
Please let me know if you have any ideas?
Regards,
Stephen
@Efic_Helpdesk
Thanks for the provided data, I will try to reproduce the problem.
@Efic_Helpdesk
Unfortunately, I was unable to reproduce the problem.
It seems to me that you should take the code and HTML with which the problem is reproduced and remove confidential information from HTML a little bit (or change it to incorrect / irrelevant). Perhaps you will see at some stage what causes problem to appear, or remove / replace confidential information and be able to provide the code and data with which it will be reproduced.