// Create a pdf file stream using FileStream outputStream = new FileStream("PrintMultipleWorksheetsToOnePage.pdf", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); Stream fileStream = this.GetResourceStream("xlsx\\Multiple sheets one page.xlsx"); workbook.Open(fileStream); //NOTE: To use this feature, you should have valid license for Document Solutions for PDF. //Create a pdf document. GrapeCity.Documents.Pdf.GcPdfDocument doc = new GrapeCity.Documents.Pdf.GcPdfDocument(); // This page will save datas for multiple pages. GrapeCity.Documents.Pdf.Page page = doc.NewPage(); //Create a PrintManager. GrapeCity.Documents.Excel.PrintManager printManager = new GrapeCity.Documents.Excel.PrintManager(); //Get the pagination information of the workbook. IList<PageInfo> pages = printManager.Paginate(workbook); //Divide the multiple pages into 1 rows and 2 columns and printed them on one page. printManager.Draw(page, pages, 1, 2); //Save the document into pdf file. doc.Save(outputStream); // close the pdf stream outputStream.Close();
' Create a pdf file stream Dim outputStream = File.Create("PrintMultipleWorksheetsToOnePage.pdf") ' Create a new Workbook Dim workbook As New Workbook Dim fileStream As Stream = GetResourceStream("Multiple sheets one page.xlsx") workbook.Open(fileStream) 'NOTE: To use this feature, you should have valid license for Document Solutions for PDF. 'Create a pdf document. Dim doc As New GcPdfDocument ' This page will save datas for multiple pages. Dim page As Page = doc.NewPage() 'Create a PrintManager. Dim printManager As New Excel.PrintManager 'Get the pagination information of the workbook. Dim pages As IList(Of PageInfo) = printManager.Paginate(workbook) 'Divide the multiple pages into 1 rows and 2 columns and printed them on one page. printManager.Draw(page, pages, 1, 2) 'Save the document into pdf file. doc.Save(outputStream) ' close the pdf stream outputStream.Close()