none
Get Ms word page count using Open Xml RRS feed

Answers

  • I think you are using OpenXML SDK 2.0 to extract information from MS Word Metro Formats. So do it like follows

     

    using (WordprocessingDocument document = WordprocessingDocument.Open(fileName, false))
    {
      int pageCount = (int) document.ExtendedFilePropertiesPart.Properties.Pages.Text;
    }
    

     

    -Kusala

    Saturday, July 31, 2010 8:58 PM

All replies

  • I think you are using OpenXML SDK 2.0 to extract information from MS Word Metro Formats. So do it like follows

     

    using (WordprocessingDocument document = WordprocessingDocument.Open(fileName, false))
    {
      int pageCount = (int) document.ExtendedFilePropertiesPart.Properties.Pages.Text;
    }
    

     

    -Kusala

    Saturday, July 31, 2010 8:58 PM
  • What if document was changed. Can I count pages manually? without getting info from properties.
    Monday, October 25, 2010 8:30 AM
  • No. The number of pages is a function of the document content and the printer driver. Using the SDK you only have one of those two variables (the document content) and no way to get the other, so repagination, and recounting, is not possible. The value stored in the property is the result of the last time Word calculated it, and that is all you can have.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Monday, October 25, 2010 1:41 PM
  • Hello Tony, Kausala

       I have a doubt, If the document is being created then this code does not work.. Actually, I want to get the line count in the similar manner above. so, is it possible?


    Wednesday, November 21, 2012 11:28 AM