Hi
I have a problem with the header in a docx file, that is saved as a pdf file. In my template, I have the following header:
the image on top appears on every header. the yellow marked text is only in primary header, but not on first header. when I save this document as DOCX, the header is as in the screenshot, but when I save the document as PDF, the yellow marked text disappears. May there be any problem with the header height? Or do I have to configure something for the First / Primary Header configuration to be taken? Has anyone an idea what the problem could be here.
Thanks in advance for your support.
@sysmgr42 Could you please attach your input and output documents here for our reference? We will check the issue and provide you more information. Unfortunately, it is not possible to analyze the problem using screenshots.
I have attached the template, the output in DOCX and the output in PDF. hope this helps.
template.docx (110,9 KB)
Output_DocX.docx (110,7 KB)
Output_PDF.pdf (197,1 KB)
@sysmgr42 Unfortunately, I cannot reproduce the problem on my side using the latest 23.7 version of Aspose.Words. As I can see you are using old 22.5 version of Aspose.Words. Please try using the latest version and let us knw is the problem still persist on your side.
I first wrote this application using the 23.7 evaluation version. the error was there as well…
do you define any settings regarding the header in Aspose? or which lines of code do you write to not get the wrong behavior?
basically I just open the document, replace the tag StammNr and save as pdf.
@sysmgr42 I have used the following simple code for testing:
Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out.pdf");
Where in.docx
is Output_DocX.docx
. I have compared PDF output with PDF produced by MS Word, and do not see any issues:
ms.pdf (218.2 KB)
out.pdf (139.8 KB)
As i need a byte[] as output, I used
doc.Save(pdfStream, SaveFormat.Pdf);
to save the pdf. I’m unable to use this save-method without the SaveFormat Parameter. don’t you get the error this way?
@sysmgr42 I have tested with byte array and still cannot see any issues:
Document doc = new Document(@"C:\Temp\in.docx");
byte[] pdfBytes;
using (MemoryStream ms = new MemoryStream())
{
doc.Save(ms, SaveFormat.Pdf);
pdfBytes = ms.ToArray();
}
File.WriteAllBytes(@"C:\Temp\out.pdf", pdfBytes);
I don’t know if the error has been corrected. If I download the latest version of the library via NuGet and execute my code, the error does not exist anymore. seems like it has been fixed since my last download of the library. anyway thank you very much for your help.
1 Like