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.

Tue May 16, 2017 1:37 pm

Can Spire.doc add automatically page break ? i need to have the same word paging without process a file with MS Word

Spire.doc count pages so i would like to have the pagebreak at the end of the page even if is in the middle of a single word

morix
 
Posts: 4
Joined: Mon May 15, 2017 1:48 pm

Wed May 17, 2017 3:22 am

Dear morix,

Thanks for your inquiry.
Please note that MS Word document is a flow document which does not contain any information about its layout into lines and pages. Like MS Word, our Spire.Doc will automatically break a page according to the content that the page can hold rather than in the form of adding a PageBreak at the end of the page. Kindly note that the PageBreak is used to forcibly break a page.
If I misunderstand you, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed May 17, 2017 4:27 pm

I have a plain text and i want to know in his document.xml when MS word puts its pagebreak WITHOUT opening and saving document with MS word. Is this possible?

morix
 
Posts: 4
Joined: Mon May 15, 2017 1:48 pm

Thu May 18, 2017 6:40 am

Dear morix,

Thanks for your inquiry.
As I mentioned before, MS Word document is a flow document which does not contain any information about its layout into lines and pages, so it is impossible to achive that.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu May 18, 2017 1:51 pm

Ok, but since i can have the page count there is there an algorithm in spire.doc that process the document ?

morix
 
Posts: 4
Joined: Mon May 15, 2017 1:48 pm

Fri May 19, 2017 5:47 am

Dear morix,

Thanks for your feedback.
MS Word document is flow document and does not contain any information about its layout into lines and pages. Therefore, technically there is no "Page" and "Line" concept in Word document, so it will be very tough to calculate the height of every element accurately, and it depends on lots of things, such as the font you use and where/how the paragraph contents break. Yet after a further investigation on your requirement, we found there is only a way to roughly calculate the position of page break.
Firstly, get the page width and page height as below.
Code: Select all
            pageWidth = section.PageSetup.PageSize.Width - section.PageSetup.Margins.Left - section.PageSetup.Margins.Right;
            pageHeight = section.PageSetup.PageSize.Height - section.PageSetup.Margins.Top - section.PageSetup.Margins.Bottom;

Then confirm the position of page break by calculating the height and width of text by yourself. Kindly note this is just a rough calculation, and maybe the breaks are different from the breaks in MS word.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc