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

Convert Docx to PDF

Product Version Product Author
2021.2.511 RadWordsProcessing Dimitar Karamfilov

Description

This article demonstrates how you can convert a Docx file to a PDF with the WordsProcessing library.

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
Not finding the help you need? Improve this article