none
Inserting pages when page count is odd in Word DOCX RRS feed

  • Question

  • I am trying to insert pages in a Word DOCX document when the total page count is an odd number.  The requirement is for there to always be an even number of pages in the document to facilitate correct 2-sided printing.

    I see 2 possible approaches to this requirement:

    1. Create Word field code that, when applied, will add the page if it is needed.  I found the formula below via an internet search.  I have implemented it via the XSL below but I am not sure how to code the page break - does anyone know how I would do that?

    { IF{ =MOD({ PAGE \* Arabic },2)}= 0 " " "[page break]" }

    <w:p>
                <w:r>
                    <w:fldChar w:fldCharType="begin"/>
                </w:r>
                <w:r>
                    <w:instrText xml:space="preserve">IF</w:instrText>
                </w:r>
                <w:r>
                    <w:fldChar w:fldCharType="begin"/>
                </w:r>
                <w:r>
                    <w:instrText xml:space="preserve">= MOD(</w:instrText>
                </w:r>
                <w:r>
                    <w:fldChar w:fldCharType="begin"/>
                </w:r>
                <w:r>
                    <w:instrText xml:space="preserve">NUMPAGES \* Arabic</w:instrText>
                </w:r>
                <w:r>
                    <w:fldChar w:fldCharType="end"/>
                </w:r>
                <w:r>
                    <w:instrText xml:space="preserve">,2)</w:instrText>
                </w:r>
                <w:r>
                    <w:fldChar w:fldCharType="end"/>
                </w:r>
                <w:r>
                    <w:instrText xml:space="preserve">= 0 [page break]</w:instrText>
                </w:r>
                <w:r>
                    <w:fldChar w:fldCharType="end"/>
                </w:r>
                <w:r>
                    <w:fldChar w:fldCharType="separate"/>
                </w:r>
            </w:p>

    2. Is there any way that XSL transforming the Word XML (document.xml) can be passed the number of pages in the document?  Is there some way that the NUMPAGES field could be assigned to an XSL variable?

    Is there some other approach for meeting the requirement that I am overlooking?

    Thank you very much for whatever assistance can be offered ...

    Friday, December 4, 2020 10:15 PM

All replies

  • Maybe whoever wrote the requirements is confused about odd and even pages, at least in the eastern left to right reading format.

    The first page of every Word document is an Odd page. When printing two-sided, and assuming there isn't a next page Section break at the end of the first page that includes a restarting of the page numbering, the second page in the document would be an Even numbered page. Even numbered pages are by default, printed on the "backside" of the preceding Odd numbered page.

    Another way to visualize this is to think about opening a book anywhere in the middle of the book. Lay the book on a table and open it in the middle. Now look at the page numbers ... you will find the left hand page is an even numbered page and the page on the right is odd numbered.

    I hope this helps with your coding for this assignment.


    Kind Regards, Rich ... http://greatcirclelearning.com

    Saturday, December 5, 2020 1:34 AM