// Create a pdf file stream using FileStream outputStream = new FileStream("SetPickTrayByPDFSizeOptionToPDF.pdf", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1"].Value = "Document Solutions for Excel"; worksheet.Range["A1"].Font.Size = 25; // You must create a pdfSaveOptions object before using ViewerPreferences. PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); // The PDF page size is used to select the input paper tray when printing. pdfSaveOptions.ViewerPreferences.PickTrayByPDFSize = true; // Save the workbook into pdf file. workbook.Save(outputStream, pdfSaveOptions);
' Create a pdf file stream Dim outputStream = File.Create("SetPickTrayByPDFSizeOptionToPDF.pdf") ' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range!A1.Value = "Document Solutions for Excel" worksheet.Range!A1.Font.Size = 25 'You must create a pdfSaveOptions object before using ViewerPreferences. Dim pdfSaveOptions As New PdfSaveOptions 'The PDF page size is used to select the input paper tray when printing. pdfSaveOptions.ViewerPreferences.PickTrayByPDFSize = True 'Save the workbook into pdf file. workbook.Save(outputStream, pdfSaveOptions)