[]
        
(Showing Draft Content)

Export Last Page Without Headers

GcExcel .NET enables users to export the last page of a PDF file without headers while keeping the headers intact in rest of the pages across the PDF file. For instance - While saving a workbook to a PDF file, you may sometimes have data in the last page of the PDF that doesn't need any headers. In such a scenario, this feature can be helpful in order to save the last page of the PDF without displaying any header information.

In order to export the last page without headers while saving to a PDF file, you need to first get the default pagination by using the Paginate() method of the PrintManager class. Then, you can use the PageContent property of the PageInfo class and the TitleRowStart property of the PageContentInfo class in order to modify the header index of the last page. When you are done, simply save your file using the SavePDF() method.

Using Code

Refer to the following example code to allow users to save the last page of the PDF without any headers while exporting to a PDF file.

// Initialize workbook
Workbook workbook = new Workbook();

// Open Excel file
workbook.Open("ExcelData.xlsx");

// Fetch default worksheet
IWorksheet worksheet = workbook.Worksheets[0];

// Create an instance of the PrintManager class
PrintManager printManager = new PrintManager();

// Repeat rows at the top of each page while saving PDF
worksheet.PageSetup.PrintTitleRows = "$1:$2";

// Get the natural pagination information of the workbook
IList pages = printManager.Paginate(workbook);

// Modify the print header of the last page
pages[pages.Count - 1].PageContent.TitleRowStart = -1;

// Save the modified pages into PDF file
printManager.SavePDF("98-ExportLastPageWithoutHeaders.pdf", pages);