Free .NET Library for Converting Microsoft® Word Processing Documents
Open-Source Library to Convert DOCX to PDF
What is DOCXToPDFConverter?
There are a bunch of open-source APIs available that allow generating 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 end user will verify the update. The process is too long and hectic for small updates like these. DOCXToPDFConverter is developed with 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 document, and introduces the dynamic content into predefined placeholders. The API works on Windows, Linux and MacOS.
At A Glance
An overview of DOCXToPDFConverter features.
- DOCX to DOCX
- DOCX to PDF
- DOCX to HTML
DOCXToPDFConverter works with .NETCoreApp 2.1. Furthermore, the API requires LibreOffice, Document.Format.OpenXm, and System.Drawing.Common.
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 from 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#
- Initialize path to LibreOffice soffice.exe
- Initialize placeholders which 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
- Initialize ReportGenerator and pass locationOfLibreOfficeSoffice as parameter
- 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);