LayoutCollector.GetStartPageIndex(...) updating fields unexpectedly

I have a field in the footer of a Word97-2003 (.DOC format) file. I have created this document through a MailMerge from a template.
The field is simply {FILENAME} which at the start of the below code is displayed as the template name.

If I step through the code saving the document before and after each line(using the below code);

asposeDocBuilder.Document.Save("C:\temp\test.doc", aspose.SaveFormat.Doc)

I can see that the highlighted line is updating the field from the name of the template to the name of the current document.

aspose.Layout.LayoutCollector layout = new aspose.Layout.LayoutCollector(asposeDocBuilder.Document);
aspose.NodeList paragraphNodes = asposeDocBuilder.Document.SelectNodes("//Body/Paragraph");
foreach (aspose.Node paraNode in paragraphNodes)
{
    aspose.Paragraph paragraph = (aspose.Paragraph)paraNode;
    if (layout.GetStartPageIndex(paraNode) == (MyTargetPageForABarcode - 1))
    {
        asposeDocBuilder.MoveTo(paraNode);
        break;
    }
}

In MS Word we can go to a particular page in the document, using Document.GoTo(…) and insert a shape and it doesn’t update this field.

Hi Tom,

Thanks for your inquiry. Please find attached a couple of input/output sample Word documents and try running the following simple code to reproduce this issue on your end. I have logged this issue in our bug tracking system. The ID of this issue is WORDSNET-10305. Your request has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Document doc = new Document(MyDir + @"in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
LayoutCollector layout = new LayoutCollector(doc);
NodeList paragraphNodes = doc.SelectNodes("//Body/Paragraph");
foreach(Node paraNode in paragraphNodes)
{
    Paragraph paragraph = (Paragraph) paraNode;
    int index = layout.GetStartPageIndex(paraNode);
    break;
}
doc.Save(MyDir + @"out.docx");

Best regards,

The issues you have found earlier (filed as WORDSNET-10305) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.