We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

The property of PageCount does not get updated in the word document

Hello,

The property of PageCount does not get updated in the word document. We initialize the document using a template and then populate the document with the data. The resulting document is almost always greater in the size than the template but the value of PageCount property does not update itself for the document. We cannot set it and there is no way to force an update to this count or get an actual count. This impacts our ability to place electronic signatures in the document at the proper place which hampers our sales efforts. Need a fix asap.



Thanks

1 Reply

DB Dilli Babu Nandha Gopal Syncfusion Team November 14, 2018 12:15 PM UTC

Hi Muhammad, 

Thank you for contacting Syncfusion support. 

Regarding PageCount property not updated properly:
The Word document is a flow document in which contents will not be preserved page by page; instead the contents will be preserved sequentially section by section. 
 
Word viewer/editor renders the contents of the Word document page by page dynamically when opened for viewing or editing. This page wise rendered information will not be preserved in the saved file level.  
Essential DocIO is a non-UI component that provides a full-fledged document object model (logical structure as defined in the file level) to manipulate the Word document contents without converting page by page. So, DocIO returns the page count, stored in input file level (updated earlier by other Word viewer/editor applications) and doesn’t automatically update on adding or removing the contents (sections, paragraphs, etc.).


Regarding Page count in .NET Framework (Windows Forms, WPF, ASP.NET and ASP.NET MVC):
To get page count from the Word document, we suggest you to use
UpdateWordCount method of DocIO which internally uses Word to PDF conversion process to calculate the page count.

Please refer the below code snippet to get page count in .NET Framework: 
 
//Creates an empty WordDocument instance   
WordDocument document = new WordDocument();  
//opens an existing word document through Open method of WordDocument class   
document.Open(fileName);  
  
//To-Do some manipulation   
  
//Updates the page count, if perform layout sets to true.  
document.UpdateWordCount(true);  
//Gets the updated page count value.   
int count = document.BuiltinDocumentProperties.PageCount;  
//Saves the document in file system   
document.Save(outputFileName, FormatType.Docx);  
//Closes the document  
document.Close();  


Currently the
UpdateWordCount API is not supported in UWP platform and we have already logged this as a feature request in our database. We will implement this feature in any of our upcoming releases and we don’t have any immediate plans to implement this feature. We will update you when this feature has been implemented. We request you to visit our website periodically for feature related updates.  
Regarding “to place electronic signatures in the document at the proper place”:
For adding electronic signatures in the Word document, you can add a placeholder text and replace with electronic signature, instead of accessing page count. Could you please provide us more details about how you are adding electronic signatures to the Word document (along with an example Word document)? Based on these details, we will analyze and provide appropriate solution to achieve your end requirement at the earliest using DocIO.

Regards, 
Dilli babu. 


Loader.
Up arrow icon