We are using Aspose.Words to generate DOC/RTF documents from a DOC template (replacing some tokens with data from a database) and then we protect them with a password, so some of the users/clients cannot change them but only print them.
The documents may have different sizes and page orientations (Portrait, Landscape). While being protected, users cannot change page orientation before printing and it’s a desired behavior.
and there the problem comes - the generated documents have the correct width and height, however the page orientation is always reset to Portrait! this can be seen in the “File”->“Page Setup” menu of the Microsoft Word. When users print such document, the text is cut and most of it is beyound the page limits, etc. We played with different printer settings, but even if the source template DOC file has correct page orientation, it always reset to Portrait after the document goes through the Aspose.Words…
I could not find any properties in the Aspose Document object to force the document into the correct page orientation.
We also tried to generate the documents in PDF using Aspose.Pdf library, however we encountered other issues with text layout, text does not expand the table cells, etc when the document is generated…
This is rather an urgent issue for our clients and a workaround/hot patch will be much appreciated from the Aspose team…
Thanks for your request. Page orientation is property of each section in the document. You can change Page orientation using Section.PageSetup.Orientation. For example see the following code.
Document doc = new Document(); doc.FirstSection.PageSetup.Orientation = Aspose.Words.Orientation.Landscape; doc.Save(@"Test077\out.doc");
Also, could you please attach your document for testing and provide me code snippet that will allow reproducing this issue?
Alexey, thanks a lot for this tip - it actually solved the problem, I just go over all the sections and force them to the needed page orientations. I tried to find documentation for the Page Orientation, but could not - neither using Aspose search nor Google search, nor just browsing it…
You can find documentation here.