1. Products
  2.   Word Processing
  3.   .NET
  4.   DOCXToPDFConverter

Free .NET Library for Converting Microsoft® Word Processing Documents

Open-Source .NET Library for Converting Word DOCX Documents to PDF and DOCX to HTML inside C# applications.

What is DOCXToPDFConverter?

There is a bunch of open-source APIs available that allow the generation of PDF document via code. The problem with it is that, for even one line of change, the developer has to update the code, test it, release a new version and the end user will verify the update. The process is too long and hectic for small updates like these. DOCXToPDFConverter is developed with the aim to allow end users to update the output document via Word. End users can update the DOCX and the API will generate an output PDF file for it. Not only you can convert DOCX to PDF, but can also get HTML as output.

While working with DOCX to PDF and DOCX to HTML conversion the API parses source documents and introduces the dynamic content into predefined placeholders. The API works on Windows, Linux, and macOS.

Previous Next

Getting Started with DOCXToPDFConverter

First of all, you require to have .NETCoreApp 2.1. After that, please download the repository manually from GitHub or install it from NuGet.

Installation DOCXToPDFConverter via NuGet

 Install-Package DocXToPdfConverter -Version 1.0.5

Convert DOCX to PDF via Free .NET API

DOCXToPDFConverter allows .NET programmers to convert DOCX to PDF programmatically. In order to convert DOCX to PDF, you need to define a source file, define path to LibreOffice, set placeholders, and convert the document using Convert() method. By using the following code snippet, you can convert DOCX to PDF.

Convert DOCX to PDF in C#

  1. Initialize path to LibreOffice soffice.exe
  2. Initialize placeholders that you want to use in your Word Documents. There are 3 types of placeholders: one for plain text, one for table rows and one for images
  3. Initialize ReportGenerator and pass locationOfLibreOfficeSoffice as parameter
  4. Convert DOCX to PDF by using ReportGenerator's Convert() method and pass input DOCX file path, output PDF path, and placeholders as parameters.

Free .NET API to Convert DOCX to PDF

// initialize LibreOffice soffice.exe filepath
string locationOfLibreOfficeSoffice = @"C:\PortableApps\LibreOfficePortable\App\libreoffice\program\soffice.exe";
// define placeholders
placeholders.NewLineTag = "
"; placeholders.TextPlaceholderStartTag = "##"; placeholders.TextPlaceholderEndTag = "##"; placeholders.TablePlaceholderStartTag = "=="; placeholders.TablePlaceholderEndTag = "=="; placeholders.ImagePlaceholderStartTag = "++"; placeholders.ImagePlaceholderEndTag = "++"; // initialize report generator var test = new ReportGenerator(locationOfLibreOfficeSoffice); // convert DOCX to PDF test.Convert("Test-Template.docx", "Test-Template-out.pdf", placeholders);