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

PDF Converter VB.NET Library
Create PDF from OpenOffice in VB.NET


How to Convert OpenOffice Document (Odt, Ods, Odp) to PDF with VB.NET Demo Code Samples







  • Best Visual Studio .NET OpenOffice to adobe PDF file converter control, which able to be integrated in .NET WinForms and ASP.NET project
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Support multiple OpenOffice documents to PDF files batch conversion in VB.NET
  • Create PDF document from OpenOffice Text Document ( .odt )with embedded fonts
  • Convert OpenOffice Spreadsheet ( .ods ) data to PDF in Visual Basic project
  • Export PDF document from OpenOffice Presentation ( .odp ) in VB.NET application
  • Quick integrate online source code to VB.NET class project
  • Free PDF SDK library and components for .NET framework




VB.NET Project: Necessary DLLs for Conversion from OpenOffice to PDF



In order to run the sample codes, the following steps would be necessary.


How to VB.NET: Convert single open office(odt, odp) file to PDF



VB.NET demo code for creating PDF document from ODT format.



'odt convert to pdf(file to file)
Dim doc As ODTDocument = New ODTDocument("C:\dmeo.odt")
doc.ConvertToDocument(DocumentType.PDF, "C:\output.pdf")



'odt convert to pdf(Stream to Stream)
Dim inputFilePath As String = "C:\demo.odt"
Dim arr() As Byte = File.ReadAllBytes(inputFilePath)
Dim inputStream As MemoryStream = New MemoryStream(arr)
Dim doc As ODTDocument = New ODTDocument(inputStream)
Dim outputStream As MemoryStream = New MemoryStream()
doc.ConvertToDocument(DocumentType.PDF, outputStream)




VB.NET demo code for creating PDF document from ODP format.



'odp convert to pdf(file to file)
Dim doc As ODPDocument = New ODPDocument("C:\dmeo.odp")
doc.ConvertToDocument(DocumentType.PDF, "C:\output.pdf")



'odp convert to pdf(Stream to Stream)
Dim inputFilePath As String = "C:\demo.odp"
Dim arr() As Byte = File.ReadAllBytes(inputFilePath)
Dim inputStream As MemoryStream = New MemoryStream(arr)
Dim doc As ODPDocument = New ODPDocument(inputStream)
Dim outputStream As MemoryStream = New MemoryStream()
doc.ConvertToDocument(DocumentType.PDF, outputStream)





How to VB.NET: Convert two or multiple open office(odt, odp) files to PDF(batch convert)



Following demo codes will show how to convert odt/odp files to pdf documents.



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

'convert odt document to pdf one by one.
For Each filePath As String In  files
       Dim doc As ODTDocument = New ODTDocument(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



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

'convert odp document to pdf one by one.
For Each filePath As String In  files
       Dim doc As ODPDocument = New ODPDocument(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





How to VB.NET: Combine multiple open office (odt, odp) files, and convert to PDF



Following is VB.NET demo code for open office(odt, odp) files to PDF conversion.



Dim files() As String = { "C:\demo1.odt, C:\demo2.odt, C:\demo3.odt" }
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 ODTDocument = New ODTDocument(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)



Dim files() As String = { "C:\demo1.odp, C:\demo2.odp, C:\demo3.odp" }
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 ODPDocument = New ODPDocument(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)





How to VB.NET: Insert open office (odt, odp) file into pdf document, and create a new PDF file



Following is VB.NET demo code to Insert open office(odt, odp) to PDF at specific location.



Dim filePath As String = "C:\demo.odt"
Dim doc As ODTDocument = New ODTDocument(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")



Dim filePath As String = "C:\demo.odp"
Dim doc As ODPDocument = New ODPDocument(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")