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

Free Support Forum - aspose.com

Document.Print does not print document in Landscape

I’m having an issue getting some of our documents to print in Landscape. Opening the document in Word shows the orientation in Landscape, and the print dialogue says it will print in Landscape. I did notice that when I went into page setup it was set for Portrait. I changed that to Landscape, thinking I had found the solution, yet still it wants to print in Portrait.

I’ve looked into the Document object and the only section in the document has a PageSet.Orientation of Landscape. To test, I created a DocumentBuilder to check the PageSetup.Orientation there and it’s still Landscape. I even grabbed the PageInfo object of the only page in the document, and Landscape is set to true.

There’s also an issue in printing where it’s forcing the printer to use Tray 1, which is typically not used for us. I’ve checked in the Document object in places and the paper source is set to 0. Other documents I’ve tested print in their expected orientations and automatically select the paper source.

I’m not sure if there are other places in the object or Word document I can look to test orientation settings and paper sources. Any help is appreciated.

This particular file is a template created long before I started work here, so I’m not sure exactly in what manner it was created. There also may be more templates like this one somewhere but I figure if I can learn how to fix this one then I can fix any others we find.

Edit: I have attached the file if that helps, thanks.
File.zip (11.3 KB)

@jpass

We have printed the shared document using the latest version of Aspose.Words for .NET 19.12 and have not found the shared issue. Please try Aspose.Words for .NET 19.12.

Moreover, please call Document.UpdatePageLayout method before printing the document. Hope this helps you.

Microsoft Word stores printer specific values for paper trays in a Word document and therefore, only printing on the same printer model as the one that was selected when the user specified the paper trays will result in printing from the correct trays. If you print a document on a different printer, then most likely the default paper tray will be used, not the trays specified in the document.

Please check the following code example. Hope this helps you.

Document doc = new Document("input.docx");

// Find the printer that will be used for printing this document. In this case it is the default printer.
// You can define a specific printer using PrinterName.
PrinterSettings settings = new PrinterSettings();

// The paper tray value stored in documents is completely printer specific. This means 
// The code below resets all page tray values to use the current printers default tray.
// You can enumerate PrinterSettings.PaperSources to find the other valid paper tray values of the selected printer.
foreach (Section section in doc.Sections.OfType<Section>())
{
    section.PageSetup.FirstPageTray = settings.DefaultPageSettings.PaperSource.RawKind;
    section.PageSetup.OtherPagesTray = settings.DefaultPageSettings.PaperSource.RawKind;
}