// Create a pdf file stream using FileStream outputStream = new FileStream("PrintSpecificPages.pdf", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); Stream fileStream = this.GetResourceStream("xlsx\\PrintSpecificPDFPages.xlsx"); workbook.Open(fileStream); //Firstly, create a printManager. GrapeCity.Documents.Excel.PrintManager printManager = new GrapeCity.Documents.Excel.PrintManager(); //Get the natural pagination information of the workbook. IList<PageInfo> pages = printManager.Paginate(workbook); //Pick some pages to print. IList<PageInfo> newPages = new List<PageInfo>(); newPages.Add(pages[0]); newPages.Add(pages[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.SavePDF(outputStream, newPages); // close the pdf stream outputStream.Close();
' Create a pdf file stream Dim outputStream = File.Create("PrintSpecificPages.pdf") ' Create a new Workbook Dim workbook As New Workbook Dim fileStream As Stream = GetResourceStream("PrintSpecificPDFPages.xlsx") workbook.Open(fileStream) 'Firstly, create a printManager. Dim printManager As New Excel.PrintManager 'Get the natural pagination information of the workbook. Dim pages As IList(Of PageInfo) = printManager.Paginate(workbook) 'Pick some pages to print. Dim newPages As New List(Of PageInfo) From { pages(0), pages(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.SavePDF(outputStream, newPages) ' close the pdf stream outputStream.Close()