Hello everyone,
I have a problem to remove the header, I read lot of topic here for this kind of problem and could’nt find a suitable solution unfortunately.
I have 2 documents, one .docx file and one .pdf file that I transform as a .docx file, not sure it’s relevant for my problem…
Anyway, I cleared the header and footer on my source file, I unling with the previous header from the previous document, I removed header (first, primary, even), I tried to modify the “Header” style, well, I tried lot of things but couldn’t make it right.
image.png (18.8 KB)
In this picture, we can see this header Section 4, it does not follow the style from the previous one but even if I removed it by coding, it is still there. It bothers me because this small space cut the end of the document I try to add.
Here some code I have, it would be great to have some help from you, ideas, …
var stream = new MemoryStream();
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(input); // path document .pdf
doc.Save(stream, Aspose.Pdf.SaveFormat.DocX);
stream.Seek(0, SeekOrigin.Begin);
Aspose.Words.Document srcDoc = new Aspose.Words.Document(stream);
// .... //
foreach (Section s in srcDoc.Sections)
{
s.ClearHeadersFooters();
}
srcDoc.FirstSection.HeadersFooters.LinkToPrevious(false);
destDoc.AppendDocument(srcDoc, Aspose.Words.ImportFormatMode.KeepSourceFormatting);
Blockquote
I tried also to remove the header style :
SrcDoc.Styles[“Header”].Remove();
But I got an error that I can’t remove a built-in style.
All the borders from any paragraph from the headers have LineStyle = None.
I hope you can help me with this one.
Have a great one. Cheers
Alex.