Articles in this section
Category / Section

Why it is not possible to access the Word document contents page by page?

3 mins read

The Word document is a flow document in which contents (paragraphs, tables, etc.,) will not be preserved page by page; instead, the contents will be preserved sequentially section by section. Each section may extend to various pages based on its contents like table, text, images, etc.

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 file level. Whereas Syncfusion .NET Word library is a non-UI component that provides a full-fledged document object model to manipulate the Word document contents.

Hence it is not directly possible to access the Word document contents page by page using DocIO. As a workaround you can split the contents of each page as separate section in the Word document and access the contents by sections instead of pages.

Alternate approaches:

Below are some alternate suggestions to access the Word document contents page by page using DocIO.

  1. Split Word documents according to pages:
    • To achieve this, you to maintain each page as each section, thereby you can split the Word document by sections. To know more about split Word documents based on sections, refer here.
    • Alternatively, you can convert the Word document to PDF, then convert the PDF to Word document again by converting each page as image and adding each image to separate Word document. Note: This created Word document will not be editable, as the contents are preserved as image.
  2. Insert text in particular page:
    • You can insert a placeholder in the input Word document, thereby you can find the placeholder from the Word document and replace it with necessary content using Find functionality. To know more about find and replace, you can refer here.
    • Alternatively, you can insert a bookmark in the input document, thereby you can navigate to the bookmark and replace the bookmark content programmatically. To know more about bookmarks in a Word document, refer here.
  3. To extract text based on each page, this, you can maintain each page as each section, thereby you can split the Word documents according to sections. Then using GetText() API you can get all the text from the split Word documents.
  4. To add line number restarting for each page, you can maintain each page as each section, then add line number for each section starting from the beginning value. To know more about adding line number, refer here.
  5. To remove empty pages from a Word document, where the empty pages are due to continuous section breaks or page breaks, you can refer to the GitHub sample.
  6. To fetch page numbers from a Word document, you can maintain each page as each section and add Page field in each section. To know more about fetching page number from Word document, refer here.
  7. To set landscape and portrait orientation for each page, you can maintain each page as each section, then set different orientation for different sections, refer here.

Take a moment to peruse the [documentation](https where you can find basic Word document processing options along with the features like mail merge, merge, split, and compare documents, find and replace text in the Word document, protect the Word documents, and most importantly, the PDF and Image conversions with code examples.

Conclusion
I hope you enjoyed learning about why it is not possible to access the Word document contents page by page using .NET Core Word Library.

You can refer to our ASP.NET Core DocIO feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET Core DocIO example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied