Hi team,
I am official license hoalder of aspose I am getting one issue regarding pdf as I have upgraded the version to 25.5. The code base is same the issue is earlier when extra content is added in header section it was overlapping the body . but now it is taking full space of header and then body is starting . Kindly look into it attaching the supporting snapshot of code and screen shot please let me know if you need anything else.
Regard,
Ashwin Raut
notoverlapping aspose v25.zip (240.3 KB)
@rautashwin
It seems that you are experiencing an issue with the header section overlapping the body content after upgrading to version 25.5 of Aspose. In the previous version, the extra content in the header did not push the body down, but now it appears to be taking up the full space of the header.
This change in behavior could be due to modifications in how Aspose handles layout and rendering in the newer version. Here are a few steps you can take to troubleshoot and potentially resolve the issue:
-
Check Header Settings: Ensure that the header settings in your code are correctly configured. You may need to adjust the margins or padding to allow for additional space if the header content is larger than expected.
-
Review Release Notes: It’s beneficial to review the release notes for version 25.5, as they may contain information about changes in layout handling or any relevant bug fixes that could affect your implementation.
-
Test with Different Content: Try testing with different header content to see if the issue persists. This can help determine if the problem is related to specific content or a general change in behavior.
-
Sample Code: If you can share a snippet of your code related to the header setup, it may help in diagnosing the issue further.
-
Contact Support: If the problem continues, consider reaching out to Aspose support directly with your code and screenshots for more tailored assistance.
If you have any additional details or specific code snippets, feel free to share them for further assistance!
Hello can I get help from the team
@rautashwin As I can see the output produced by the latest 25.6 version of Aspose.Words is correct. Here is the test code compiled from the snippets provided in your initial post:
string HtmlString = "<html xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:w=\"urn:schemas-microsoft-com:office:word\" xmlns:m=\"http://schemas.microsoft.com/office/2004/12/omml\" xmlns=\"http://www.w3.org/TR/REC-html40\"><head><meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\"><meta name=ProgId content=Word.Document><meta name=Generator content=\"Microsoft Word 14\"><meta name=Originator content=\"Microsoft Word 14\"><link rel=File-List href=\"Body_POCWord/filelist.xml\"><!--[if gte mso 9]><xml><w:WordDocument><w:DisplayBackgroundShape/></w:WordDocument></xml><![endif]--><style><!--/* Page Definitions */@page WordSection1 {size:8.27in 11.7in;margin:1.2in 1in 0in 1.35in;mso-header-margin:1.2in;mso-footer-margin:0.62in;mso-title-page:yes;mso-header:;mso-footer:;mso-first-header:;mso-first-footer:;mso-paper-source:0;}div.WordSection1 {page:WordSection1;}--></style></head><body><div class=WordSection1><table class=\"mce-item-table\" style=\"table-layout:fixed;width: 579.32px; float: left; \" border=\"0\"><tbody><tr><td id=\"Field\" align=\"left\" valign=\"top\" style=\"width: 206.40px; font-family: Arial; font-size: 14pt;\" colspan=\"2\" title=\"CERT_HOLDER\"><span id=\"Field\"><span style=\"font-family: Arial; font-size: 14pt;\" data-mce-style=\"font-family: Arial; font-size: 14pt;\"><strong>Holder of Certificate:<br/><img id=\"CERT_HOLDER_LOGO\" src=\"C:\\Data\\Repo\\TEST_REQ\\TUVSUD.CBW2.WebUI\\Images_From_TinyMCE\\CompayLogo.png\" height=\"100\" data-mce-src=\"../Images_From_TinyMCE/CompayLogo.png\"></strong></span></span></td><td id=\"FieldValue$CERT_HOLDER\" align=\"left\" valign=\"top\" style=\"width: 372.92px; font-family: Arial; font-size: 10pt;\" colspan=\"2\"><strong><span style=\"font-size: 14pt;\" data-mce-style=\"font-size: 14pt;\"><strong>Testkunde GmbH</strong><br /><strong>Testkunde Name2</strong><br /><strong>Testkunde Name3</strong><br /><span style=\"font-size: 10px;\">Zus, Strasse Testkunde 1</span><br /><span style=\"font-size: 10px;\">Zus, Strasse Testkunde 2</span><br /><span style=\"font-size: 10px;\">EinbahnStrasse 44 62</sapn><br /><span style=\"font-size: 10px;\">B0000 München</span><br /><span style=\"font-size: 10px;\">GERMANY</span></span></strong></td></tr><tr><td id=\"Field\" align=\"left\" valign=\"top\" style=\"width: 82.56px; font-family: Arial; font-size: 10pt;\" title=\"ORDER_NO\"><span id=\"Field\" style=\"font-size: 9pt;\" data-mce-style=\"font-size: 9pt;\"><span style=\"font-family: Arial;\" data-mce-style=\"font-family: Arial;\"><strong>Order no:</strong></span></span></td><td id=\"FieldValue$ORDER_NO\" align=\"left\" valign=\"top\" style=\"width: 123.84px; font-family: Arial; font-size: 10pt;\"><span style=\"font-size: 9pt;\" data-mce-style=\"font-size: 9pt;\">ORDER NO 1234567890</span></td><td id=\"Field\" align=\"left\" valign=\"top\" style=\"width: 82.56px; font-family: Arial; font-size: 10pt;\" title=\"ORDER_DATE\"><span style=\"text-decoration: underline; font-size: 9pt;\" data-mce-style=\"text-decoration: underline; font-size: 9pt;\"><em><span id=\"Field\"><span style=\"font-family: Arial;\" data-mce-style=\"font-family: Arial;\"><strong>Order Date:</strong></span></span></em></span></td><td id=\"FieldValue$ORDER_DATE\" align=\"left\" valign=\"top\" style=\"width: 290.36px; font-family: Arial; font-size: 10pt;\"><span style=\"font-size: 10pt;\" data-mce-style=\"font-size: 10pt;\"><span style=\"text-decoration: underline; font-size: 9pt;\" data-mce-style=\"text-decoration: underline; font-size: 9pt;\"><em>dd.mm.yyyy</em></span><br/><br/><br/></span></td></tr><tr><td id=\"Field\" align=\"left\" valign=\"top\" style=\"width: 206.40px; font-family: Arial; font-size: 10pt;\" colspan=\"2\" title=\"SIGNATURE\"><span id=\"Field\"><span style=\"font-family: Arial; font-size: 10pt;\"><strong></strong></span></span></td><td id=\"FieldValue$SIGNATURE\" align=\"left\" valign=\"top\" style=\"width: 372.92px; font-family: Arial; font-size: 10pt;\" colspan=\"2\"><span style=\"font-size: 10pt;\"><img id=\"SIGNATURE_Image\" src=\"C:\\Data\\Repo\\TEST_REQ\\TUVSUD.CBW2.WebUI\\Images_From_TinyMCE\\Signature.png\" height=\"57\"></span></td></tr><tr><td id=\"Field\" align=\"left\" valign=\"top\" style=\"width: 206.40px; font-family: Arial; font-size: 10pt;\" colspan=\"2\" title=\"TC_NAME\"><span id=\"Field\"><span style=\"font-family: Arial; font-size: 10pt;\"><strong></strong></span></span></td><td id=\"FieldValue$TC_NAME\" align=\"left\" valign=\"top\" style=\"width: 372.92px; font-family: Arial; font-size: 10pt;\" colspan=\"2\"><span style=\"font-size: 10pt;\" data-mce-style=\"font-size: 10pt;\">Lara Croft</span></td></tr><tr><td id=\"Field\" align=\"left\" valign=\"top\" style=\"width: 206.40px; font-family: Arial; font-size: 10pt;\" colspan=\"2\" title=\"DESIGNATION\"><span id=\"Field\"><span style=\"font-family: Arial; font-size: 10pt;\"><strong></strong></span></span></td><td id=\"FieldValue$DESIGNATION\" align=\"left\" valign=\"top\" style=\"width: 372.92px; font-family: Arial; font-size: 10pt;\" colspan=\"2\"><span style=\"font-size: 10pt;\" data-mce-style=\"font-size: 10pt;\">DESIGNATION</span></td></tr></tbody></table></div></body></html>";
Document doc;
using (var ms = new MemoryStream())
{
byte[] byteInfo = Encoding.UTF8.GetBytes(HtmlString);
ms.Write(byteInfo, 0, byteInfo.Length);
ms.Position = 0;
doc = new Document(ms);
}
DocumentBuilder builder = new DocumentBuilder(doc);
Section currentSection = builder.CurrentSection;
Aspose.Words.Style style = doc.Styles[StyleIdentifier.Normal];
style.Font.Name = "Arial";
PageSetup pageSetup = currentSection.PageSetup;
pageSetup.DifferentFirstPageHeaderFooter = true;
pageSetup.PaperSize = PaperSize.A4;
pageSetup.Orientation = Orientation.Portrait;
pageSetup.HeaderDistance = 86.4;
pageSetup.TopMargin = 158.4;
pageSetup.RightMargin = 72;
pageSetup.BottomMargin = 0;
pageSetup.FooterDistance = 44.64;
pageSetup.LeftMargin = 97.20;
builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
builder.InsertHtml("<table class=\"mce-item-table\" style=\"table-layout:fixed;width:579.32px;float:left;\" border=\"0\"><tbody><tr><td id=\"FieldValue$HEADER\" colspan=\"4\"><span style=\"font-size: 14pt; font-family: Arial;\" data-mce-style=\"font-size: 14pt; font-family: Arial;\"><strong>C E R T I F I C A T E</strong></span></td></tr><tr><td id=\"FieldValue$ADD_DESC_3\" colspan=\"4\"><span style=\"font-size:12pt;font-family:Arial;\"><span style=\"font-size: 10pt;\">test desc 3<br/>test desc 3<br/>test desc 3<br/>test desc 3<br/>test desc 3<br/>test desc 3</span></span></td></tr><tr><td id=\"FieldValue$ADD_DESC_4\" colspan=\"4\"><span style=\"font-size:12pt;font-family:Arial;\"><span style=\"font-size: 10pt;\">test desc 4<br/>test desc 4<br/>test desc 4<br/>test desc 4<br/>test desc 4<br/>test desc 4</span></span></td></tr></tbody></table>");
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.InsertHtml("<table class=\"mce-item-table\" style=\"table-layout:fixed;width:579.32px;float:left;\" border=\"0\"><tbody><tr><td id=\"FieldValue$HEADER\" colspan=\"4\"><span style=\"font-size: 14pt; font-family: Arial;\" data-mce-style=\"font-size: 14pt; font-family: Arial;\"><strong>C E R T I F I C A T E</strong></span></td></tr><tr><td id=\"FieldValue$ADD_DESC_3\" colspan=\"4\"><span style=\"font-size:12pt;font-family:Arial;\"><span style=\"font-size: 10pt;\">test desc 3<br/>test desc 3<br/>test desc 3<br/>test desc 3<br/>test desc 3<br/>test desc 3</span></span></td></tr><tr><td id=\"FieldValue$ADD_DESC_4\" colspan=\"4\"><span style=\"font-size:12pt;font-family:Arial;\"><span style=\"font-size: 10pt;\">test desc 4<br/>test desc 4<br/>test desc 4<br/>test desc 4<br/>test desc 4<br/>test desc 4</span></span></td></tr></tbody></table>");
builder.MoveToHeaderFooter(HeaderFooterType.FooterFirst);
builder.InsertHtml("<table class=\"mce-item-table\" style=\"table-layout:fixed;width:579.32px;float:left;\" border=\"0\"><tbody><tr><td id=\"FieldValue$PAGER\" colspan=\"4\"><span style=\"font-size: 8pt; font-family: Arial;\" data-mce-style=\"font-size: 8pt; font-family: Arial;\">Page X of Y</span></td></tr><tr><td id=\"FieldValue$CERT_NO\" colspan=\"4\"><span style=\"font-size:12pt;font-family:Arial;\"><strong><span style=\"font-size: 14pt;\">No. ASPS5 88888 01234 Rev. 01</span></strong></span></td></tr><tr><td id=\"FieldValue$FOOTER\" colspan=\"4\"><span style=\"font-size: 8pt; font-family: Arial;\" data-mce-style=\"font-size: 8pt; font-family: Arial;\">TÜV SÜD Product Service GmbH · Certification Body · Ridlerstrasse 65 · Munich · Germany</span></td></tr></tbody></table>");
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.InsertHtml("<table class=\"mce-item-table\" style=\"table-layout:fixed;width:579.32px;float:left;\" border=\"0\"><tbody><tr><td id=\"FieldValue$PAGER\" colspan=\"4\"><span style=\"font-size: 8pt; font-family: Arial;\" data-mce-style=\"font-size: 8pt; font-family: Arial;\">Page X of Y</span></td></tr><tr><td id=\"FieldValue$CERT_NO\" colspan=\"4\"><span style=\"font-size:12pt;font-family:Arial;\"><strong><span style=\"font-size: 14pt;\">No. ASPS5 88888 01234 Rev. 01</span></strong></span></td></tr><tr><td id=\"FieldValue$FOOTER\" colspan=\"4\"><span style=\"font-size: 8pt; font-family: Arial;\" data-mce-style=\"font-size: 8pt; font-family: Arial;\">TÜV SÜD Product Service GmbH · Certification Body · Ridlerstrasse 65 · Munich · Germany</span></td></tr></tbody></table>");
doc.Save(@"C:\Temp\out.docx");
doc.Save(@"C:\Temp\out.pdf");
out.docx (14.0 KB)
out.pdf (72.5 KB)
Please note, Aspose.Words Document Object Model is designed to work with MS Word documents. HTML documents object model is quite different and it is not always possible to provide 100% fidelity after importing or exporting HTML document. Usually Aspose.Words mimics MS Word behavior when work with HTML documents.
Hello alexey,
Thank you for your prompt response.
if you can see the same code with version 17.4 the header section overlaps with body .
and in version 25 it does not. Please check with both version and suggest the further actions . I am attaching the output with version 17.4
out result v 17.4.zip (91.5 KB)
Regards,
Ashwin Raut
@rautashwin Try optimizing the output for older version of MS Word:
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2007);
doc.Save(@"C:\Temp\out.docx");
doc.Save(@"C:\Temp\out.pdf");
out.docx (12.9 KB)
out.pdf (72.5 KB)