title: Python Docx - Sections - Page Orientation
body: <p>The following code tries to use <code>landscape</code> orientation, but the document is created as <code>potrait.</code> <br>Can you suggest where the problem is?</p>
  
  <pre><code>from docx import Document
  from docx.enum.section import WD_ORIENT
  
  document = Document()
  
  section = document.sections[-1]
  section.orientation = WD_ORIENT.LANDSCAPE
  
  document.add_heading('text')
  document.save('demo.docx')
  </code></pre>
  
  <p>When I read the code back as XML</p>
  
  <pre><code>&lt;w:document&gt;
      &lt;w:body&gt;
         &lt;w:p&gt;
            &lt;w:pPr&gt;
               &lt;w:pStyle w:val="Heading1"/&gt;
            &lt;/w:pPr&gt;
            &lt;w:r&gt;
                &lt;w:t&gt;TEXT&lt;/w:t&gt;
            &lt;/w:r&gt;
         &lt;/w:p&gt;
         &lt;w:sectPr w:rsidR="00FC693F" w:rsidRPr="0006063C" w:rsidSect="00034616"&gt;
             &lt;w:pgSz w:w="12240" w:h="15840" w:orient="landscape"/&gt;
             &lt;w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="720" w:footer="720" w:gutter="0"/&gt;
             &lt;w:cols w:space="720"/&gt;
             &lt;w:docGrid w:linePitch="360"/&gt;
          &lt;/w:sectPr&gt;
      &lt;/w:body&gt;
   &lt;/w:document&gt;
  </code></pre>
  
  <p>I don't know XML well by assume the section tags should come above the TEXT tags at the top rather than the bottom???? </p>