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

Free Support Forum - aspose.com

Incorrect page numbers

Hi Aspose,

Seems that UpdatePageLayout() method doesn’t use margins or line spacing information for it’s work.
The page numbers are incorrect.

Please see result.docx attached, pages 27, 28, 40 - highlighted text.
issue.zip (149.6 KB)

Source code:

    var document = new Document("C:\\test.docx");

  	var builder = new DocumentBuilder(document);

  	var insertedFields = new List<Field>();

  	foreach (var paragraph in document.GetChildNodes(NodeType.Paragraph, true))
  	{
  		builder.MoveTo(paragraph);
  		Field insertedField = builder.InsertField(@"PAGE", "1");
  		insertedFields.Add(insertedField);
  	}

  	document.UpdatePageLayout();

  	insertedFields.ForEach(field => field.Update());

  	document.Save("C:\\result.docx", SaveFormat.Docx);

Thanks.

@spectr100,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-17255. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-17255) have been fixed in this Aspose.Words for .NET 19.4 update and this Aspose.Words for Java 19.4 update.