We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page orientation setup does not work with some documents


We are using Aspose.Words for .NET version 17.7 for conversion DOCX files to images. We got an issue with page layout setup in some documents. We set up the Landscape orientation by the following code snippet:

Document wordDocument = new Document(contentStream);
foreach (Section wordSection in wordDocument.Sections)
    wordSection.PageSetup.Orientation = Orientation.Landscape;

Than, we save pages as bitmaps and generate tiff file:

var imageSaveOptions = new Aspose.Words.Saving.ImageSaveOptions(SaveFormat.Bmp);
imageSaveOptions.PixelFormat = ImagePixelFormat.Format24BppRgb;
imageSaveOptions.Resolution = resolution;
imageSaveOptions.PageCount = 1;

for (int pageIndex = 0; pageIndex < wordDocument.PageCount; pageIndex++)
    imageSaveOptions.PageIndex = pageIndex;
    MemoryStream stream = null;
        stream = new MemoryStream();
        wordDocument.Save(stream, imageSaveOptions);
        using (var bitmap = new Bitmap(stream))
            stream = null;
        if (stream != null)

In some documents pages take a landscape orientation, and in some they are converted as is.

Please see files in attached ZIP.

Good.docx - initial document, in which orientation setup works.
Good.docx.tif - TIFF file produced from initial Good.docx.
Bad.docx - initial document, in which orientation setup does not work.
Bad.docx.tif - TIFF file produced from initial Bad.docx.


Files.zip (1.2 MB)

Same issue we found with page size setup. The following code snippet

foreach (Section wordSection in wordDocument.Sections)
    wordSection.PageSetup.PageWidth = 841.9;
    wordSection.PageSetup.PageHeight = 1190.55;

affects Good.docx document and doesn’t affect Bad.docx document.


Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 17.10 and have not found the shared issue. Please use Aspose.Words for .NET 17.10.

If you face the same issue with some other documents, please call Document.UpdatePageLayout method before saving the document to image. Hope this helps you.