protected override void OnQueryPageSettings(QueryPageSettingsEventArgs e)
{
base.OnQueryPageSettings(e);
// A single Word document can have multiple sections that specify pages with different sizes,
// orientation and paper trays. This code is called by the .NET printing framework before
// each page is printed and we get a chance to specify how the page is to be printed.
PageInfo pageInfo = this.mDocument.GetPageInfo(this.mCurrentPage - 1);
e.PageSettings.PaperSize = pageInfo.GetDotNetPaperSize(this.PrinterSettings.PaperSizes);
// MS Word stores the paper source (printer tray) for each section as a printer-specfic value.
// To obtain the correct tray value you will need to use the RawKindValue returned
// by .NET for your printer.
e.PageSettings.PaperSource.RawKind = pageInfo.PaperTray;
e.PageSettings.Landscape = pageInfo.Landscape;
}