Set "Choose paper source by PDF page size" in code

Hello.


Could you please clarify if it’s possible to set “Choose paper source by PDF page size” flag using Aspose API. If it’s possible could you provide an example.

Thanks,
Dima.

Hi Dima,

Thank you for considering Aspose.Pdf.

I am afraid; your requested feature to select “Choose paper source by PDF page size” flag while printing the PDF document using Aspose.Pdf for .NET is not supported at the moment. I have logged a new feature request as PDFNEWNET-34266 in our issue tracking system. Our development team will investigate this requirement in detail and you’ll be notified via this forum thread regarding any updates.

Sorry for the inconvenience,

@ShmelP

Beginning with Aspose.PDF 24.4 this preference can be switched on and off using the Document.PickTrayByPdfSize property or the PdfContentEditor facade:

using (Document document = new Document())
{
    Page page = document.Pages.Add();
    page.Paragraphs.Add(new TextFragment("Hello world!"));

    // Set the flag to choose a paper tray using the PDF page size
    document.PickTrayByPdfSize = true;
    document.Save("result.pdf");
}
using (PdfContentEditor contentEditor = new PdfContentEditor())
{
    contentEditor.BindPdf("input.pdf");

    // Set the flag to choose a paper tray using the PDF page size
    contentEditor.ChangeViewerPreference(ViewerPreference.PickTrayByPDFSize);
    contentEditor.Save("result.pdf");
}