Remove empty pages

Technical support for Spire.Doc

Moderator: iceblue support

Remove empty pages

Postby mardla » Fri Jul 28, 2017 1:17 pm


we generate the document form template and we don't know how long will be the text, that we paste to the document. We get the document with empty pages now. How can we remove these empty pages (Pages C, D and E in the sample document)?

I have sent the sample document to email

Best regards.
Posts: 5
Joined: Fri Jun 09, 2017 12:32 pm

Re: Remove empty pages

Postby Betsy.jiang » Mon Jul 31, 2017 5:48 am

Dear Josef,

Sorry for late reply as weekend.
Please note that 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, our Spire.Doc product is based on MS Word specification, so it is impossible to remove empty pages.

Moreover, I checked your sample file and noticed the "empty page" you mentioned only has one row. So you could remove the three rows, then the "empty pages" will be removed.
Code: Select all
            Document doc = new Document(@"F:\UnitTestTemplate-success.docx");
            Table table = doc.Sections[0].Tables[0] as Table;
            int count = table.Rows.Count;
            //From the third row, delete these rows
            for (int i = 2; i < count;i++ )
                //remove the rows
            doc.SaveToFile("11239.docx", FileFormat.Docx);

If there is any question, please let me know.

E-iceblue support team
User avatar
Posts: 1894
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 0 guests