Choose paper source by PDF page size

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF PrintManager for .NET (v1)  /  Choose paper source by PDF page size

DynamicPDF PrintManager for .NET (v1) Forum

 Jun 24 2011 10:49 AM
I am replacing a manual process for printing PDFs at my company.  That process requires us to send print jobs for custom stock sizes.  The person printing the jobs now uses the "Choose paper source by PDF page size" option in Adobe Acrobat to accomplish this.  Is there a comparable method in DynamicPDF PrintManager to accomplish the same thing?  Right now it cuts the print jobs off at the selected paper size even though the PDF is larger.
Posted by a ceTe Software moderator
Hello,

The PrintManager API provides two different classes to programmatically set the paper source based on the page size, at the PrintJob level you can use PrintJobPrintOptions and set the PaperSource property based on the PaperSize. You can also do this at the PrintJobPage level by using PrintJobPagePrintOptions.

Below sample code demonstrates how to use the print options at page level, you can do the same with the PrintJob level options which will be applicable to the whole document.

    PrintJob printJob = new PrintJob(Printer.Default, @"C:\MyDocument.pdf", 1, 4);
    // Get the last page and set its print options
    PrintJobPage printJobPage = printJob.Pages[printJob.Pages.Count - 1];
    PrintJobPagePrintOptions pagePrintOptions = printJobPage.PrintOptions;
    pagePrintOptions.Inherit = false;
    // set the papersource based on the papersize.
    if(pagePrintOptions.PaperSize.Name == "Letter")
       pagePrintOptions.PaperSource = Printer.Default.PaperSources[2];
    printJob.Print();

Thanks,
ceTe Software Support Team
I am able to set the paper size to any of the options in the PaperSizeList, but my problem is that my stock is not in that list.  The printer I am printing to will accept any stock dimension up to the maximum size.  Is there a way to set the paper size to the size of the first page in the print job?
Posted by a ceTe Software moderator
Hello,

If you want to explicitly set the print job’s paper size of the first page’s size then you can use the code below, but printJob.PrintOptions.PaperSize should already have the first pages size set. Here you may also need to set the PaperSource to the specific tray that has this specific paper stock loaded and the list of paper sources is available in Printer.Default.PaperSources property.

            PrintJob printJob = new PrintJob(Printer.Default, @"C:\MyDocument.pdf");

            // Get the first page paper size.
            PrintJobPage firstPage = printJob.Pages[0];
            PaperSize firstPagePaperSize = firstPage.PrintOptions.PaperSize;

            //explicitly set the whole PrintJob's paper size to first page paper size.
            printJob.PrintOptions.PaperSize = firstPagePaperSize;

            //select the required paper source in the PaperSources list.
            printJob.PrintOptions.PaperSource = Printer.Default.PaperSources[0];

            // Print the job
            printJob.Print();

Thanks,
ceTe Software Support Team
What I really need to know is if I can send a paper size that is not in the list of available paper sizes.
Posted by a ceTe Software moderator
Hello,

Sorry for the confusion, it is not possible to use the paper sizes outside the list of paper sizes supported in the API.

Thanks,
ceTe Software Support Team
Could it in the future?  In our model we would prefer if it was able to use the PDF page size as the print page size.
Posted by a ceTe Software moderator
Hello,

We have this added to our feature request list but at this time we do not have any immediate plans on implementing this feature.

Thanks,
ceTe Software Support Team
.pdf automatically read the paper size when printing works great IF you are using IE.  Turns out it does not work in CHROME

Chrome defaults to requiring you to use THEIR .pdf reader which does NOT include a box to automatically choose paper size !!

If you are having this issue - go into chrome plug ins, and disable Chrome .pdf reader and select ADOBE .pdf reader - problem solved.

use: chrome://plugins in your top bar and hit return

Hope this helps

All times are US Eastern Standard time. The time now is 3:21 PM.