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

Free Support Forum - aspose.com

Printing to multiple trays

Hi, I need to be able to print to mutliple trays using the PdfViewer.

below is the code I'm trying to use. However, there is no direct link between the PrintDocument and the PdfViewer objects. As far as I'm aware, I need to hook into the PrintDocument events to alter the tray for each individual page in the document.

public static void Print(string inputFile, string printerName, int duplexMode, int firstTray, int followerTray)
{

_firstTray = firstTray;
_followerTray = followerTray;

PdfViewer viewer = new PdfViewer();
PrinterSettings settings = new PrinterSettings();
PageSettings pageSettings = new PageSettings();
PrintDocument doc = new PrintDocument();

viewer.OpenPdfFile(inputFile);

settings.PrinterName = doc.PrinterSettings.PrinterName;

if (ConverterConfig.Instance != null)
viewer.Resolution = ConverterConfig.Instance.PdfSettings.PdfPrintResolution;

PrintSettings = settings;

if (!printerName.IsNullOrEmpty())
settings.PrinterName = printerName;

if ((duplexMode == 1 || duplexMode == 2 || duplexMode == 3) && settings.CanDuplex)
settings.Duplex = duplexMode == 1 ? Duplex.Simplex : duplexMode == 2 ? Duplex.Vertical : Duplex.Horizontal;

currentPageNumber = 1;
doc.QueryPageSettings += new QueryPageSettingsEventHandler(doc_QueryPageSettings);
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);

viewer.PrintDocumentWithSettings(pageSettings, settings);

}

static void doc_PrintPage(object sender, PrintPageEventArgs e)
{
currentPageNumber++;
}

static void doc_QueryPageSettings(object sender, QueryPageSettingsEventArgs e)
{
foreach (PaperSource source in PrintSettings.PaperSources)
{
if (source.RawKind == _firstTray)
{
e.PageSettings.PaperSource = source;
}
}

if (currentPageNumber > 1)
{
foreach (PaperSource source in PrintSettings.PaperSources)
{
if (source.RawKind == _followerTray)
{
e.PageSettings.PaperSource = source;
}
}
}
}

If you need any more info, please let me know.


This message was posted using Aspose.Live 2 Forum

Hi Nolan,

You can print the PDF pages to different paper trays using a combination of PdfViewer, PageSettings and your custom coding.

Please have a look at this topic.
It helps you understand how to use PrinterSettings and PageSettings
classes of System.Drawing.Printing namespace. You can use PageSettings
class to set PaperSource (the paper tray). You can also set FromPage and
ToPage properties to set the starting and ending page to be printed in
this particular paper source.

Now, if you want to print
different pages to different paper sources, you’ll have to send a print
for each set of pages with particular paper source and from page and to
page settings separately.

For example, first send page range 1 -
1 to printer tray one and then page range 2 - 10 to printer tray two
and so on for as many sets of pages and paper trays as you like.

I hope this helps. If you have any further questions, please do let us know.
Regards,

So if i understand you correctly this means different printer jobs for the printer?

The reason i’m hooking into this subject is we are considering trying to do exactly the same. This because we have a staple finisher on our printer and we would like to have complexe documents stapled. However some pages should be printed from Tray 1 while others from Tray 3. This is easily done in Aspose.Words but if i understand your post correctly this is not possible with Aspose.Pdf?

Greetings,

F.B. ten Kate

Hi Folkert,

I’m sorry, this feature is current not supported. However, I have logged a new feature request as PDFNEWNET-31384 in our issue tracking system to provide support for this feature in our future versions. You’ll be notified via this forum thread once it is supported in future. Nevertheless, I’m afraid, this might not be available in short time.

We’re sorry for the inconvenience.
Regards,

Hi,

This request is quitte old already and sofar nothing happened. I don't think the request is a strange one and would help us a lot too. Let me explain why. Our customer prints each of their 1000 reports with a banner in front. That banner is printed on paper from a specific tray. Their printer also has a finisher (stacker) that jogs each printed report. Now the banner and the report shift because there considered different reports.

Thanks,

Ron

Hi Ron,


Thanks for contacting support and sorry for the delayed response.

The development team has been busy resolving other priority issues and implementing some high priority features and I am afraid the feature “Printing different pages of a single document from different trays” is not yet implemented. Please note that as per our current estimates, we plan to fix/support this feature by Q3 of 2013 (but still its not a promise. We will try our level best to support this feature by said time).

We are sorry for this inconvenience.

Hi there!

Any news on this topic? We would also greatly welcome a solution to this common problem…

Greetings

Hi Angelika,

Thanks for your inquiry. You can print different page range to different Paper source trays using Aspose.Pdf for .NET. Please check following documentation link, it will help you to accomplish the task.

Please feel free to contact us for any further assistance.

Best Regards,