-1

Hi I am trying to convert DOCX to PDF conversion in C# using only telerik controls not any other third party assemblies or introp.

I found similar questions in stack overflow but didn't get the proper answer means unable to proceed with those approaches.

Thanks in advance.

Learner
  • 139
  • 1
  • 9

1 Answers1

0

Please Try this.You may take some help from this.

RadDocument document = null;
IDocumentFormatProvider providerDocx = (IDocumentFormatProvider) new DocxFormatProvider();
using (FileStream stream = File.Open(@"C:\Test.docx", FileMode.Open))
{
    document = providerDocx.Import(stream);

    var providerPdf = new PdfFormatProvider();

    Stream outStream = new MemoryStream();
    providerPdf.Export(document, outStream);

    //Test the conversion:
    var fileStream = File.Create("PdfTest.pdf");
    outStream.Seek(0, SeekOrigin.Begin);
    outStream.CopyTo(fileStream);
    fileStream.Close();
}
Moinul Islam
  • 469
  • 2
  • 9
  • I am getting 'The type or namespace name 'IDocumentFormatProvider' could not be found (are you missing a using directive or an assembly reference?) ' while trying to add the 2nd line of your code. – Learner Mar 19 '18 at 11:59
  • Add this ref Telerik.Windows.Documents.FormatProviders – Moinul Islam Mar 19 '18 at 12:10
  • DocxFormatProvider providerDocx = new DocxFormatProvider(); – Moinul Islam Mar 19 '18 at 13:03
  • Am unable to import namespace 'Telerik.Windows.Documents.Flow.FormatProviders.Pdf', but able to 'Telerik.Windows.Documents.Flow.FormatProviders.Docx. Don't know why? – Learner Mar 19 '18 at 13:43
  • Was able to add that namespace after adding the 'Telerik.Windows.Documents.Flow.FormatProviders.Pdf.dll' into references. Finally solution is working now.Thanks a lot for your help :) – Learner Mar 19 '18 at 15:33