Word document to PDF conversion Image issue using PdfFormatProvider

4 posts, 0 answers
  1. Anup Indurkar
    Anup Indurkar avatar
    1 posts
    Member since:
    Oct 2009

    Posted 23 Apr 2014 Link to this post

    Hi there, 

           I have a Byte [ ] of word document containing Text, Images and Tables.
           I want to generate and store PDF file into the database table.
           I am able to generate the PDF file using below code but Image is not exporting to PDF.
           Text and Tables exported successfully.

            public void ByteArrayToPdf()
                Byte[] Document = null;
                RadDocument document = new RadDocument();
                PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
                RtfFormatProvider providerRtf = new RtfFormatProvider();

                string path = Path.GetTempPath() + "\\TempFile.doc";
                Document = File.ReadAllBytes(path);

                using (FileStream stream = File.Open(path, FileMode.Open))
                    document = providerRtf.Import(stream);

                Document = pdfFormatProvider.Export(document);

                if (Document != null && Document.Length > 0)

    Please help.

    Anup Indurkar
  2. Daniel
    Daniel avatar
    4934 posts

    Posted 28 Apr 2014 Link to this post

    Hello Anup,

    This won't work for doc files, but will do for docx provided that you freeze the images after the import. Sample code is shown below:
    (FileStream stream = File.Open(path, FileMode.Open))
       document = providerRtf.Import(stream);
    foreach (var imageInline in document.EnumerateChildrenOfType<ImageInline>())


    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. DevCraft R3 2016 release webinar banner
  4. Arron
    Arron avatar
    22 posts
    Member since:
    Apr 2013

    Posted 08 May 2014 in reply to Anup Indurkar Link to this post

    Hi, Anup.
    How about these code:
    Dim PDF As New YGPic()
    Public Sub WordToPDFConversion()
    WordImportFolder = ("C/:YGDemo.docx")
    PicExportFolder = PicFormat.pdf
    End Sub
    doc.Store(@"C:/YG.docx", 1, @"C:/YG.pdf")
    It will help you convert Word Doc to PDF file. I hope you success. Good luck.

    Best regards,
  5. Alice
    Alice avatar
    1 posts
    Member since:
    Mar 2015

    Posted 24 Mar 2015 in reply to Arron Link to this post

    if you want to convert your PDF file
    without any issue then you have to use a professional PDF
    . Using any other PDF converter may harm your data and its
    formatting after conversion. So it is recommended that use a perfect PDF

Back to Top