Is it possible to print pages from a PDF document from different printer trays? Let say I want to print first and last page from tray 2 and all the inbetween pages on tray 1. Is that possible with Aspose.PDF?
Hi Michael,
Thanks for your inquiry. You may accomplish your requirement with your own logic while using page range and print source tray properties. Please check Aspose.Pdf printing options and sample code snippet to use subjected properties.
//create objects for printer and page settings and PrintDocument
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
//specify your printer name
ps.PrinterName = myPrinterName;
ps.PrintRange = PrintRange.SomePages;
ps.FromPage = 1;
ps.ToPage = 2;
//set PageSize (if required)
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
//set PageMargins (if required)
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
//Here you can set the PaperSource which you want to use as per your printer.
pgs.PaperSource = ps.PaperSources[1];
//print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
Please feel free to contact us for any further assistance.
Best Regards,
Hi Tilal.
Unfortunately your reply does not answer my question.
I want to be able to send a document to the printer and have the printer print some pages from one tray and some pages from another tray.
Please carefully read my inquiry again.
Hi Michael,
Hi Tilal. I understand that I can break it up into several prints, but that is not an option. We have to be able to send a document to printer and be sure that there are no other printjobs in between our pages. The document must be printet as one.
In .NET we are able to do this by using the printDocument_QueryPageSettings event on the PrintDocument object. But we cannot figur out how to do it with Aspose.Pdf.Facades.PdfViewer.
Hi Michael,
Hi Tilal. Does this mean that you do not currently support the mentioned scenario and will implement this in future releases?
Hi Michael,
Thank you. We hope soon to receive any status because our choice of supplier heavily depends on this feature.
Hi Michael,
Hi Michael,
Hi Michael,
Thanks for your patience.
In order to print different page ranges to different paper source trays, you should use the PdfViewer.PdfQueryPageSettings event handler.
Following code snippet shows how to print even and odd page numbers to different sources:
[C#]
Aspose.Pdf.Facades.PdfViewer pdfv = new Aspose.Pdf.Facades.PdfViewer();
pdfv.PdfQueryPageSettings += PdfvOnPdfQueryPageSettings;
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrinterSettings prin = new System.Drawing.Printing.PrinterSettings();
pdfv.BindPdf(inFile);
prin.PrinterName = "HP LaserJet M9050 MFP PCL6";
prin.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
Aspose.Pdf.Facades.PdfPageEditor pageEditor = new Aspose.Pdf.Facades.PdfPageEditor();
pageEditor.BindPdf(inFile);
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
pgs.PaperSize = prin.DefaultPageSettings.PaperSize;
pdfv.PrintDocumentWithSettings(pgs, prin);
pdfv.Close();
private void PdfvOnPdfQueryPageSettings(object sender, QueryPageSettingsEventArgs queryPageSettingsEventArgs, PdfPrintPageInfo currentPageInfo)
{
bool isOdd = currentPageInfo.PageNumber % 2 != 0;
PrinterSettings.PaperSourceCollection paperSources = queryPageSettingsEventArgs.PageSettings.PrinterSettings.PaperSources;
if (isOdd)
queryPageSettingsEventArgs.PageSettings.PaperSource = paperSources[0];
else
queryPageSettingsEventArgs.PageSettings.PaperSource = paperSources[1];
}
The issues you have found earlier (filed as PDFNEWNET-37406) have been fixed in Aspose.Pdf for .NET 9.8.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(3)