New to Telerik Document Processing? Download free 30-day trial

Convert Docx to PDF

Product Version Product Author
2021.3.909 RadWordsProcessing Dimitar Karamfilov

Description

This article demonstrates how you can convert a Docx file to a PDF with the WordsProcessing library. In the WordsProcessing Getting Started article you can find all the required assembly references.

Solution

The solution is to import the file with the DocxFormatProvider and export it with the PdfFormatProvider.

Convert Docx to PDF

.

public static void ConverDocxToPdf(string path, string resultPath) 
{ 
    var docxPRovider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider(); 
    var pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider(); 
 
    var docBytes = File.ReadAllBytes(path); 
    var document = docxPRovider.Import(docBytes); 
 
    var resultBytes = pdfProvider.Export(document); 
    File.WriteAllBytes(resultPath, resultBytes); 
} 
In this article