XDoc.PDF
Features
Tech Specs
How-to VB.NET
Pricing
How to Start Convert PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

VB.NET PDF - Create PDF from Microsoft Office Excel in VB.NET


VB.NET Tutorial for Converting PDF from Microsoft Office Excel Spreadsheet Using VB.NET Demo Code





Look for HTML5 PDF Editor?

EdgePDF: ASP.NET PDF Editor is the best HTML5 PDF Editor and ASP.NET PDF Viewer based on XDoc.PDF, JQuery, HTML5. It supports ASP.NET MVC and WebForms projects.


Best Visual Studio .NET Microsoft Office Excel to adobe PDF file converter control, which able to be used integrated in .NET WinForms and ASP.NET project


Support multiple formats, includes xls, xlsx, etc


Turn all Excel spreadsheet into high quality PDF without losing formatting in VB.NET


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


Create fillable and editable PDF documents from Excel in Visual Basic .NET class


Create searchable and scanned PDF files from Excel in VB.NET Framework


Convert to PDF with embedded fonts or without original fonts fast


Professional .NET PDF converter component for batch conversion


Merge all Excel sheets to one PDF file in VB.NET


Change Excel hyperlink to PDF hyperlink and bookmark


Export PDF from Excel with cell border or no border


Convert Excel to PDF document free online without email


Source code and library for quick evaluation in VB.NET class




VB.NET Demo Code  for Converting Excel to PDF



Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Raster.dll


  RasterEdge.XDoc.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.XDoc.Excel.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.Excel;


  using RasterEdge.XDoc.PDF;


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.




VB.NET Sample Code: Convert Excel to PDF in VB.NET Project



Following is VB.NET demo code for Excel(.xlsx/.xlsm/.xltx) to PDF conversion.



Dim inputFilePath As String = "C:\1.xlsx"
Dim outputFilePath As String = "C:\Output.pdf"

' Load a Excel (.xlsx) document.
Dim doc As XLSXDocument = New XLSXDocument(inputFilePath)

' Convert it to PDF document.
doc.ConvertToDocument(DocumentType.PDF, outputFilePath)




Following is VB.NET demo code for Excel (.xls) to PDF conversion.



Dim inputFilePath As String = "C:\1.xls"
Dim outputFilePath As String = "C:\Output.pdf"

' Load a Excel(.xls) document.
Dim doc As XLSDocument = New XLSDocument(inputFilePath)

' Convert it to PDF document.
doc.ConvertToDocument(DocumentType.PDF, outputFilePath)





VB.NET Convert two or multiple Excel files to PDF (batch convert)



Following is VB.NET demo code for Excel(.xlsx/.xlsm/.xltx) to PDF conversion.



Dim inputDirectory As String = "C:\input\"
Dim outputDirectory As String = "C:\Output\"
Dim files() As String = Directory.GetFiles(inputDirectory, "*.xlsx")

' convert excel document to pdf one by one.
For Each filePath As String In  files
       Dim doc As XLSXDocument = New XLSXDocument(filePath)
       Dim startIdx As Integer = filePath.LastIndexOf("\")
       Dim endIdx As Integer = filePath.LastIndexOf(".")
       Dim docName As String = filePath.SubString(startIdx + 1, endIdx - startIdx - 1)
       ' Convert it to PDF document.
       doc.ConvertToDocument(DocumentType.PDF, outputDirectory + docName + ".pdf")
Next




Following is VB.NET demo code for Excel(.xls) to PDF conversion.



Dim inputDirectory As String = "C:\input\"
Dim outputDirectory As String = "C:\Output\"
Dim files() As String = Directory.GetFiles(inputDirectory, "*.xls")

' convert excel document to pdf one by one.
For Each filePath As String In  files
       Dim doc As XLSDocument = New XLSDocument(filePath)
       Dim startIdx As Integer = filePath.LastIndexOf("\")
       Dim endIdx As Integer = filePath.LastIndexOf(".")
       Dim docName As String = filePath.SubString(startIdx + 1, endIdx - startIdx - 1)
       ' Convert it to PDF document.
       doc.ConvertToDocument(DocumentType.PDF, outputDirectory + docName + ".pdf")
Next





VB.NET Convert two or multiple Excel files to one PDF



Following is VB.NET demo code for Excel(.xlsx/.xlsm/.xltx) to PDF conversion.



Dim files() As String = { "C:\demo1.xlsx", "C:\demo2.xlsx", "C:\demo3.xlsx" }
Dim outputFilePath As String = "C:\output.pdf"
Dim streams As List(Of MemoryStream) = New List(Of MemoryStream)()
For Each filePath As String In  files
       Dim doc As XLSXDocument = New XLSXDocument(filePath)
       Dim outputStream As MemoryStream = New MemoryStream()
       ' Convert it to PDF document.
       doc.ConvertToDocument(DocumentType.PDF, outputStream)
       streams.Add(outputStream)
Next
PDFDocument.CombineDocument(streams, outputFilePath)




Following is VB.NET demo code for Excel(.xls) to PDF conversion.



Dim files() As String = { "C:\demo1.xls", "C:\demo2.xls", "C:\demo3.xls" }
Dim outputFilePath As String = "C:\output.pdf"
Dim streams As List(Of MemoryStream) = New List(Of MemoryStream)()
For Each filePath As String In  files
       Dim doc As XLSDocument = New XLSDocument(filePath)
       Dim outputStream As MemoryStream = New MemoryStream()
       ' Convert it to PDF document.
       doc.ConvertToDocument(DocumentType.PDF, outputStream)
       streams.Add(outputStream)
Next
PDFDocument.CombineDocument(streams, outputFilePath)





VB.NET insert excel file into pdf document, and create a new PDF file



Following is VB.NET demo code to Insert Excel(.xlsx/.xlsm/.xltx) to PDF at specific location.



Dim filePath As String = "C:\demo.xlsx"
Dim doc As XLSXDocument = New XLSXDocument(filePath)
Dim stream As MemoryStream = New MemoryStream()
doc.ConvertToDocument(DocumentType.PDF, stream)
Dim pdf As PDFDocument = New PDFDocument(stream)
Dim pageCount As Integer = pdf.GetPageCount()
Dim pages List(Of BasePage) = New List(Of BasePage)() 
For i As Integer = 0 To pageCount - 1
       pages.Add(pdf.GetPage(i))
Next
Dim outputPdf As String = "C:\output.pdf"
Dim desDoc As PDFDocument = New PDFDocument(outputPdf)
Dim insertLocation As Integer = 2
desDoc.InsertPages(pages.ToArray(), insertLocation)
desDoc.Save("C:\desDocument.pdf")




Following is VB.NET demo code to Insert Excel(.xls) to PDF at specific location.



Dim filePath As String = "C:\demo.xls"
Dim doc As XLSDocument = New XLSDocument(filePath)
Dim stream As MemoryStream = New MemoryStream()
doc.ConvertToDocument(DocumentType.PDF, stream)
Dim pdf As PDFDocument = New PDFDocument(stream)
Dim pageCount As Integer = pdf.GetPageCount()
Dim pages List(Of BasePage) = New List(Of BasePage)() 
For i As Integer = 0 To pageCount - 1
       pages.Add(pdf.GetPage(i))
Next
Dim outputPdf As String = "C:\demo.pdf"
Dim desDoc As PDFDocument = New PDFDocument(outputPdf)
Dim insertLocation As Integer = 2
desDoc.InsertPages(pages.ToArray(), insertLocation)
desDoc.Save("C:\desDocument.pdf")