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

Word to PDF VB.NET Library
How to convert Word docx to PDF programmatically without Office, interop in vb.net


VB.NET Tutorial for Creating PDF document from MS Office Word in Visual Basic .NET Class





In this vb.net tutorial, you will learn how to merge, combine PDF documents using VB.NET code in Visual Studio applications.

  • Convert word to pdf programmatically
  • Convert to PDF from docx in byte array, or Stream objects
  • No need install Office Word, and interop
  • Easy to integrate in Windows Forms, WPF applications, ASP.NET using VB.NET

How to convert Word to PDF using Visual Basic .NET

  1. Download XDoc.PDF Converter VB.NET library
  2. Install vb library to convert docx to PDF document
  3. Step by Step Tutorial




















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


Following is VB.NET demo code for Word (.docx/.dotm/.docm/.dotx) to PDF conversion.



Dim inputFilePath As String = "C:\1.docx"
Dim outputFilePath As String = "C:\Output.pdf"
Dim doc As DOCXDocument = New DOCXDocument(inputFilePath)
doc.ConvertToDocument(DocumentType.PDF, outputFilePath)






VB.NET: convert Word (.docx) to Adobe PDF with outline support


When you convert Office Word (.docx) document to PDF file, you can generate PDF outline (bookmark) from Word document heading content or bookmarks.

There are four options for OutlineMode:


  1. None: Do not create any outline entry.

  2. ByOutlineLevel: Create outline entries by paragraph's outline level.

  3. ByHeading: Create outline entries by paragraph's style IDs (heading styles).

  4. ByBookmark: Create outline entries by bookmarks.


Dim inputFilePath As String = "C:\1.docx"
Dim outputFilePath As String = "C:\output.pdf"

Dim doc As DOCXDocument = New DOCXDocument(inputFilePath)
' Set strategy used to create outline entries for the document.
' Default: OutlineMode.ByOutlineLevel
doc.OutlineSetting.Mode = OutlineMode.ByHeading
' Set the maximum level of entires in the outline.
' Valid range: 1 ~ 9; default value: 3
doc.OutlineSetting.MaxLevel = 2

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






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


Convert MS Office Word 2007 (.docx) file to PDF using single thread



            String inputDirectory = @"C:\input\";
            String outputDirectory = @"C:\output\";
            String[] files = Directory.GetFiles(inputDirectory, "*.docx");
            foreach (String filePath in files)
            {
                int startIdx = filePath.LastIndexOf("\\");
                int endIdx = filePath.LastIndexOf(".");
                String docName = filePath.Substring(startIdx + 1, endIdx - startIdx - 1);
                DOCXDocument doc = new DOCXDocument(filePath);
                doc.ConvertToDocument(DocumentType.PDF, outputDirectory + docName + ".pdf");
            }