# 导出指定页面到PDF

## Content

GcExcel允许用户只将工作簿中的某些特定工作表（而不是整个工作簿）导出成PDF。
此功能特别适用于包含大量工作表的工作簿。例如-保存到PDF文件时，您可能不希望将整个工作簿导出，而只希望将一些重要的工作表保存到PDF文件中。在这种情况下，您可以使用此功能根据需要生成PDF文件。

要将特定页面导出到PDF文件，请创建[PrintManager](/developer/grapecitydocuments/excel-java/api/com/grapecity/documents/excel/PrintManager.html)类的实例，并使用[paginate()](/developer/grapecitydocuments/excel-java/api/com/grapecity/documents/excel/PrintManager.html#paginate)方法获取默认分页。接下来，需要指定要导出或打印的页面。最后，调用[updatePageNumberAndPageSettings()](/developer/grapecitydocuments/excel-java/api/com/grapecity/documents/excel/PrintManager.html#updatePageNumberAndPageSettings)方法来更新页码索引和每个页面的页面设置。完成后，只需使用[savePageInfosToPDF()](/developer/grapecitydocuments/excel-java/api/com/grapecity/documents/excel/PrintManager.html#savePageInfosToPDF)方法保存PDF文件。

### 代码用例

请参阅以下示例代码以将指定页面导出到PDF文件。

```Java
// Initialize workbook
Workbook workbook = new Workbook();
        
// Open Excel file
workbook.open("PrintSpecificPDFPages.xlsx");

// Create an instance of the PrintManager class
PrintManager printManager = new PrintManager();

// Get the natural pagination information of the workbook
List pages = printManager.paginate(workbook);

// Pick some pages to print
List newPages = new ArrayList();
newPages.add(pages.get(0));
newPages.add(pages.get(2));

/* Update the page number and the page settings of each page. 
   The page number is continuous */
printManager.updatePageNumberAndPageSettings(newPages);

// Save the pages into pdf file
printManager.savePageInfosToPDF("PrintSpecificPages.pdf", newPages);
```
