Document Solutions for Excel, .NET Edition | Document Solutions
Features / Print / Page Setup / Configure Paper Source
In This Topic
    Configure Paper Source
    In This Topic

    DsExcel allows you to configure the paper source while printing a PDF document. It lets you control whether the PDF page size should be used to select the input paper tray while printing. This can be done by using the PickTrayByPDFSize property of the ViewerPreferences class.

    Refer to the following example code to configure paper source while printing a PDF document.

    C#
    Copy Code
    // Initialize workbook
    Workbook workbook = new Workbook();
    
    // Fetch default worksheet
    IWorksheet worksheet = workbook.Worksheets[0];
    
    worksheet.Range["A1"].Value = "Documents for Excel";
    worksheet.Range["A1"].Font.Size = 25;
    
    // create a pdfSaveOptions object before using ViewerPreferences
    PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
    
    // PDF page size is used to select the input paper tray when printing
    pdfSaveOptions.ViewerPreferences.PickTrayByPDFSize = true;
    
    // Save the workbook into pdf file
    workbook.Save("PickTrayByPDFSize.pdf", pdfSaveOptions);

    The paper source setting appears in the 'Print' dialog box of PDF document as shown below:

     

    Print dialog box