Document Solutions for Excel, .NET Edition | Document Solutions
File Operations / Export to PDF / Control Pagination / Export Custom Page Information
In This Topic
    Export Custom Page Information
    In This Topic

    DsExcel .NET enables users to save and print custom page information while exporting to a PDF file.

    For instance - Sometimes, users may want to apply different page settings and display custom page number, page count, title rows, tail rows, column headers, row headers, title columns, tail columns, range, paper width, paper height, page margins, page headers, page footers etc. as per their own preferences while exporting to a PDF file or while printing a PDF file. In this scenario, they can use this feature to showcase the desired page information instead of the default page information in the PDF file.

    Depending upon the specific requirements of the users, the custom page information can be exported using the following APIs:

    Using Code

    Refer to the following example code to allow users to export custom page information while saving the workbook to a PDF file.

    C#
    Copy Code
    // Initialize workbook
    Workbook workbook = new Workbook();
            
    // Open Excel file
    workbook.Open("KeepTogether.xlsx");
            
    // Fetch default worksheet 
    IWorksheet worksheet = workbook.Worksheets[0];
    
    // Create an instance of the PrintManager class
    PrintManager printManager = new PrintManager();
    
    /* Get the natural pagination information of the worksheet.
       The first page of the natural pagination is "A1:F37", 
       the second page is from row "A38:F73" */
    IList<PageInfo> pages = printManager.Paginate(worksheet);
    
    // Customize the page information. The first page is "A1:F36"
    pages[0].PageContent.Range = worksheet.Range["A1:F36"];
            
    /* The center header of the first page will 
       show the text "Budget summary report" */
    pages[0].PageSettings.CenterHeader =
    "&KFF0000&18 Budget summary report";
            
    /* The center footer of the first page will
       show the page number "1" */
    pages[0].PageSettings.CenterFooter = 
    "&KFF0000&16 Page &P";
            
    // The second page is "A37:F73"
    pages[1].PageContent.Range = 
    worksheet.Range["A37:F73"];
    
    // Save the modified pages into PDF file
    printManager.SavePDF(@"CustomPageInfos.pdf", pages);