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

Free Support Forum - aspose.com

Image in footer changes position when saved to pdf

Hi,

I’ve found a potential issue with saving word documents to pdf. Could you please take a look?
I’m using Aspose.Words .Net 22.5.0 with license applied.

I’m running the following code to import the contents of Source.docx to the footer of a new document:

var sourceDocument = new Document("D:/Source.docx");

var document = new Document();
var builder = new DocumentBuilder(document);
builder.MoveToSection(0);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

var importer = new NodeImporter(sourceDocument, document, ImportFormatMode.UseDestinationStyles);
var footer = document.FirstSection.HeadersFooters.First() as HeaderFooter;

var refNode = footer.FirstChild;

foreach (var paragraph in sourceDocument.FirstSection.Body.Paragraphs)
{
    var importedNode = importer.ImportNode(paragraph, true);
    footer.InsertBefore(importedNode, refNode);
}
refNode.Remove();

document.Save("D:/test.pdf");

The position of an image differs when saving as pdf and docx.
Please note that it worked as expected in version 21.8 but not 21.9.

Please see the attached zip file for the source document, pdf outputs from versions 21.8, 21.9 and 22.5 and docx output from version 22.5.
Aspose.zip (86.1 KB)

Thanks

@acturisaspose Thank you for reporting this problem to us. For a sake of correction it has been logged as WORDSNET-23853. We will keep you informed and let you know once it is resolved.

Currently you can fix the problem using the following line of cocde:

Document document = new Document();
document.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2007); // This fixes the problem.