Hi,
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; try { stream = new MemoryStream(); wordDocument.Save(stream, imageSaveOptions); using (var bitmap = new Bitmap(stream)) { stream = null; AddBitmapToTiff(bitmap); } } finally { if (stream != null) { stream.Dispose(); } } }
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.
Thanks,
Roman
Files.zip (1.2 MB)