Search code examples
pythonms-wordorientationlandscapepython-docx

How to change page orientation to landscape?


I want to change the orientation to landscape for only certain pages in the word that I'm creating using python-docx. Is this possible? If yes, how? If no, is there any other option to do the same?


Solution

  • Page orientation is specified on a section-by-section basis. So if you want to change back and forth, you'll need to add a section break at each point you want to change from portrait to landscape or vice versa.

    This page in the documentation should give you what you need.

    http://python-docx.readthedocs.io/en/latest/user/sections.html