DOCX to PDF conversion

8 posts, 0 answers
  1. Chris
    Chris avatar
    1 posts
    Member since:
    Nov 2014

    Posted 23 Nov 2014 Link to this post

    Hi

    According to this thread it is possible to convert a DOCX file to a PDF. The code there no longer seems to work however.

    The code I'm trying to run is:

    RadDocument document = null;
    IDocumentFormatProvider providerDocx = (IDocumentFormatProvider) new DocxFormatProvider();
    using (FileStream stream = File.Open(@"C:\Test.docx", FileMode.Open))
    {
        document = providerDocx.Import(stream);
    }
     
    PdfFormatProvider providerPdf = new PdfFormatProvider();
    using (Stream output = File.Open(@"C:\Test.pdf", FileMode.Create))
    {
        providerPdf.Export(document, output);
    }


    The error occurs on the last line: cannot convert from 'Telerik.Windows.Documents.Model.RadDocument' to 'Telerik.Windows.Documents.Fixed.Model.RadFixedDocument'

    Is it still possible to convert from docx to PDF?
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 26 Nov 2014 Link to this post

    Hi Chris,

    RadPdfProcessing does not provide an option to convert flow document (e.g. DOCX) to fixed format, although we are working on implementing such functionality. At this point such conversion can only be achieved using the assemblies shipped with RadRichTextBox and the code you found on the forums.

    As to the error you are experiencing, the PdfFormatProvider class that can export a RadDocument instance to PDF is located in the Telerik.Windows.Documents.FormatProviders.Pdf assembly. Please refer to this help article for additional information on the assemblies you need to add to your project in order to use the control.

    It seems the provider instance you are creating is from the Telerik.Windows.Documents.Fixed.dll and relates to the new RadPdfProcessing library. Like I said, the library does not allow for conversion of flow documents for now, but you can follow this item in the public portal to be notified when the feature is available.

    Do not hesitate to contact us if you have any additional questions.

    Regards,
    Petya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Nils C.
    Nils C. avatar
    41 posts
    Member since:
    Oct 2009

    Posted 19 Mar 2015 in reply to Petya Link to this post

    Hi, 

    in your Blogpost is announced: PdfProcessing and WordsProcessing now enable seamless conversion of DOCX/RTF/HTML documents to PDF

    Do you have an example for that?

    Best 

    Nils
  4. Petya
    Admin
    Petya avatar
    975 posts

    Posted 19 Mar 2015 Link to this post

    Hi Nils,

    There is an example of this in our online demos for WordsProcessing called Export to PDF.

    The basic idea is that you need to use the HtmlFormatProvider /DocxFormatProvider/ RtfFormatProvider to create a RadFlowDocument. Then, use the PdfFormatProvider to export the document to a PDF stream.

    Let us know if you face any difficulties with this.

    Regards,
    Petya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Igor
    Igor avatar
    3 posts
    Member since:
    Apr 2015

    Posted 09 Sep 2015 in reply to Petya Link to this post

    Petya said:Hi Nils,

    There is an example of this in our online demos for WordsProcessing called Export to PDF.

    The basic idea is that you need to use the HtmlFormatProvider /DocxFormatProvider/ RtfFormatProvider to create a RadFlowDocument. Then, use the PdfFormatProvider to export the document to a PDF stream.
     

    Petya, I try to make docx - pdf conversion in my project. Namespace Telerik.Windows.Documents.Flow.FormatProviders does not contain namespace Pdf. Was it changed? Am I missing some reference?

  6. Igor
    Igor avatar
    3 posts
    Member since:
    Apr 2015

    Posted 09 Sep 2015 in reply to Igor Link to this post

    Figured it out. I needed reference to Telerik.Windows.Documents.Flow.FormatProviders.Pdf.dll
  7. Shahbaz
    Shahbaz avatar
    8 posts
    Member since:
    Oct 2014

    Posted 18 Sep 2015 in reply to Igor Link to this post

    hello,

    did you manage to convert docx to pdf. can you please share the sample code. i am trying to do the same using Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf but can't get proceed.

    thanks..

  8. Igor
    Igor avatar
    2 posts
    Member since:
    Apr 2015

    Posted 20 Sep 2015 in reply to Shahbaz Link to this post

    https://dotnetfiddle.net/tAxzgN

    I hid reference to my employer project namespaces.​

    Fell free to advice any improvements (=

     

Back to Top