# Export Multiple Workbooks to Single PDF

This topic describes the steps to save a multiple workbook to a single PDF and its advantages.

## Content

DsExcel allows users to save multiple workbooks into a single Portable Document File (PDF) by either using the [saveWorkbooksToPDF()](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/PrintManager.html#saveWorkbooksToPDF) method or using the [savePageInfosToPDF()](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/PrintManager.html#savePageInfosToPDF) method of the [PrintManager](/document-solutions/java-excel-api/api/online/v9.2/com/grapecity/documents/excel/PrintManager.html) class. Each workbook is saved to a new page in the PDF file. The information in the PDF such as the page number, number of pages, odd and even pages, first page etc. is saved on the basis of the final pagination results.
Combining multiple workbooks into one PDF makes it easier to distribute and review related information stored in separate files. For example, if sales data for different product versions is stored in different workbooks, you can export the workbooks to a single PDF instead of sharing multiple spreadsheet or PDF files.

>type=note
> **Note:** In order to export multiple sheets to one page, you should have a valid license for Document Solutions for PDF.

The following example opens two workbooks, configures their page headers and footers, and saves them to a single PDF file.

```Java
// Initialize first workbook
Workbook workbook1 = new Workbook();
        
// Opening Excel file
workbook1.open("Book1.xlsx");
        
// Initialize second workbook
Workbook workbook2 = new Workbook();
        
// Opening Excel file
workbook2.open("Book2.xlsx");

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

workbook1.getWorksheets().get(0).getPageSetup().setCenterFooter("&P of &N");
workbook1.getWorksheets().get(0).getPageSetup().setCenterHeader("&G");
try {
    workbook1.getWorksheets().get(0).getPageSetup().getCenterHeaderPicture()
    .setFilename("C:\\Documents\\GcExcelJAVA-May'19Samples\\logo.png");
} catch (FileNotFoundException e) {

    e.printStackTrace();
}
workbook1.getWorksheets().get(0).getPageSetup().getCenterHeaderPicture().setWidth(150);
workbook1.getWorksheets().get(0).getPageSetup().getCenterHeaderPicture().setHeight(50);
workbook1.getWorksheets().get(0).getPageSetup().setTopMargin(100);

workbook1.getWorksheets().get(1).getPageSetup().setCenterFooter("&P of &N");
workbook1.getWorksheets().get(1).getPageSetup().setCenterHeader("&G");
try {
    workbook1.getWorksheets().get(1).getPageSetup().getCenterHeaderPicture()
    .setFilename("C:\\Documents\\GcExcelJAVA-May'19Samples\\logo.png");
} catch (FileNotFoundException e) {

    e.printStackTrace();
}
workbook1.getWorksheets().get(1).getPageSetup().getCenterHeaderPicture().setWidth(150);
workbook1.getWorksheets().get(1).getPageSetup().getCenterHeaderPicture().setHeight(50);
workbook1.getWorksheets().get(1).getPageSetup().setTopMargin(100);

workbook2.getWorksheets().get(0).getPageSetup().setCenterFooter("&P of &N");
workbook2.getWorksheets().get(0).getPageSetup().setCenterHeader("Google");
workbook2.getWorksheets().get(0).getPageSetup().setTopMargin(100);

List<PageInfo> pages1 = printManager.paginate(workbook1);
List<PageInfo> pages2 = printManager.paginate(workbook2);

ArrayList<PageInfo> pages = new ArrayList<PageInfo>();
pages.addAll(pages1);
pages.addAll(pages2);

printManager.updatePageNumberAndPageSettings(pages);

// Save the workbook1 and workbook2 into the PDF file
printManager.savePageInfosToPDF("SaveToOnePDF.pdf", pages);
```