Free Support Forum -

Aspose freezes when determining page numbers for a section

When pulling page numbers from a document, the aspose code hangs.

Document pwd: 20031003184


/// Aspose method for getting the number of pages in each section

private static Dictionary GetPageStartOfSections( Document doc )
var builder = new DocumentBuilder( doc );

var sectionStartFields = new Dictionary();
var sectionStartPages = new Dictionary();
var sectionRestartNumbers = new Dictionary();

foreach( Section section in doc.Sections )
// We have to find out how many pages there are in the currentSection
// and what pages they are in the overall document.
var first = section.Body.FirstParagraph;
builder.MoveTo( first.HasChildNodes ? first.FirstChild : first );
builder.Font.Hidden = true;
sectionStartFields.Add(section, builder.InsertField(@"PAGE \* Arabic", "1"));

if( !section.PageSetup.RestartPageNumbering ) continue;
sectionRestartNumbers.Add( section, section.PageSetup.PageStartingNumber );
section.PageSetup.RestartPageNumbering = false;

doc.UpdatePageLayout(); //Freezes

foreach( var pair in sectionStartFields )
sectionStartPages.Add( pair.Key, int.Parse(pair.Value.Result) );
var section = pair.Key;
if( !sectionRestartNumbers.ContainsKey( section ) ) continue;
section.PageSetup.RestartPageNumbering = true;
section.PageSetup.PageStartingNumber = sectionRestartNumbers[pair.Key];

return sectionStartPages;

what is the status with this issue?



Thanks for your inquiry and sorry for the delayed response. First of all, in case you’re using an older version of Aspose.Words, I would suggest you please download and use the latest version of Aspose.Words i.e. 11.6.0 from the following link:

Secondly, upon calling Document.UpdatePageLayout method, on average, Aspose.Words layouts 10 pages per second. So, in your case, the extra amount of time, Document.UpdatePageLayout takes to rebuild page layout, depends on the number of pages your input Word document has. Moreover, it took Aspose.Words 111 seconds on my side to rebuild the page layout of your document. As your document contains 127 pages, Aspose.Words should take around 13 seconds. To address this performance issue, I have logged a new issue in our bug tracking system. The issue ID is .WORDSNET-6799 Your request has also been linked to this issue and you will be notified as soon as it is resolved.

Sorry for the inconvenience.

Best Regards,

I ran with the latest aspose.word and the file still freezes during conversion to PDF. Is this performance issue being addressed?


Thanks for your feedback. Yes, you’re right; the latest version of Aspose.Words takes the same amount of time during building the page layout of your document. I regret to share that the developer was unable to identify the root cause of this problem on his first attempt. For the sake of correction, I have logged a new issue in our bug tracking system as WORDSNET-6876. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Best Regards,

can I move this to priority support?

Hi John,

Thanks for your inquiry.

I’m afraid this issue has already been closed as not reproducible. There have been several attempts to reproduce the issue by running the code on the attached document, however each time the process does not freeze and completes within around the same time as previous versions.

Could you please clarify again what the exact problem is? Does running the code on your side ever complete? Could you please attach a sample application which demonstrates this issue?


The issue was re-opened as WORDSNET-6876v. The issue is the amount of time it takes to convert the word document.

The issue was reconized as a performance issue.

I'm re-attaching sample code and a document.


Thanks for the additional information. I executed your attached project on my side and it took literately no time at all. However, when I rendered your attached document ‘1133749-timeout.doc’ to PDF format, the conversion took around 108 seconds. We will further look into the details of this problem and provide you more information. Could you please provide us some more details about the machine you’re getting this problem on (e.g: Operating System information (32 or 64 bit), .Net framework version etc)?

Best Regards,

Windows 7 and Windows 2008 Server Standard both are 64 bit. .Net 4.0


Thanks for the additional information.

I have communicated the environment details to our development team. They will prepare the required platform to simulate the environment as of yours. As soon as everything is setup, they will test the issue on their end and then I will post the results here for your kind reference.

Thanks again for your patience and understanding.

Best Regards,

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

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