Saves a Workbook as a PDF document to the specified stream.

 public static void SavePdf(Boolean onlySelectedWorksheets, System.IO.Stream stream)
Public Static Sub SavePdf(ByVal onlySelectedWorksheets As Boolean, ByVal stream As System.IO.stream)

If true, only selected worksheets will be saved to the PDF. If false, all visible worksheets in the workbook will be saved to the PDF.

The output stream to write to. This stream must be open and writable. ExcelWriter will not close this stream; the calling program is responsible for closing the stream and releasing the resource.

 

If there is a problem creating, opening, or writing to the stream specified, or reading from the Workbook object.

The Worksheet.PageSetup property will be used to specify how each worksheet should be rendered to the PDF document.  The individual PageSetup options are reflected in the final document.  Each worksheet uses its own PageSetup property to determine how that worksheet should be rendered.

           ExcelApplication xla = new ExcelApplication();
           Workbook WB= xla.Create(FileFormat.Xlsx);
           FileStream fstream = new FileStream(@"C:\temp\outfile.pdf", FileMode.Create);    
           WB.SavePdf(false, fstream);
	   Dim oExcelApp As New ExcelApplication()           
       Dim wb As Workbook = oExcelApp.Create(FileFormat.Xlsx)       
       Dim fstream As New FileStream("C:\temp\outfile.pdf", FileMode.Create)          
       wb.SavePdf(False, fstream)