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.
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);
}