/// <summary> /// Called before each page is printed. /// </summary> 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; }
/// <summary> /// Called before each page is printed. /// </summary> protected override void OnQueryPageSettings(QueryPageSettingsEventArgs e) { base.OnQueryPageSettings(e); // A single Microsoft Word document can have multiple sections that specify pages with different sizes, // orientations, and paper trays. The .NET printing framework calls this code before // each page is printed, which gives us a chance to specify how to print the current page. PageInfo pageInfo = mDocument.GetPageInfo(mCurrentPage - 1); e.PageSettings.PaperSize = pageInfo.GetDotNetPaperSize(PrinterSettings.PaperSizes); // Microsoft Word stores the paper source (printer tray) for each section as a printer-specific value. // To obtain the correct tray value, you will need to use the "RawKind" property, which your printer should return. e.PageSettings.PaperSource.RawKind = pageInfo.PaperTray; e.PageSettings.Landscape = pageInfo.Landscape; }