Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Jul 09, 2014 8:29 am

Hi there,

is there any way to get the page number of a field (the page number on which the field is placed)?

The context for the page number can the whole document (absolute) or relative to the related section (better).

I could not find any GetPage()-Method or Page-Property in your API.

Any trick? Any tipp is very appreciated.

Thanks and regards
Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Wed Jul 09, 2014 9:12 am

Dear Felix,

Thanks for your inquiry.
Please try Document.GetPageCount() method.
Share sample code:
Code: Select all
Document doc = new Document();
            doc.LoadFromFile("..\\..\\test.docx");
            //Gets the number of pages of document.
            int pageCount = doc.GetPageCount();


Please feel free to contact us if you have any problems.

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Jul 09, 2014 1:29 pm

Hi Amy,

thank you for the prompt reply.

Unfortunately this was not my question. I do not need the total number of pages. I need the page (number) where a certain object (is this case, a field) is placed. Is there any way to calculate or query the page number for a certain object in the document?

I know, this depends a lot on the concrete page settings (format, sizes, etc.) of the concrete document. But it should be possible at runtime, right?

Thanks
Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Thu Jul 10, 2014 2:01 am

Dear Felix,

Sorry that I misunderstand your requirement.
Page number of every field is automatically calculated according to page breaks hence there is no way to get page number of certain field and only get a total number of pages, sorry for the inconvenience.

Please feel free to contact us if you have any problems.

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc