Word document to PDF conversion Image issue using PdfFormatProvider

6 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)
                {
                        SaveDocumentToDB(Document);
                }
    }
     

    Please help.


    Thanks
    Anup Indurkar
  2. Daniel
    Admin
    Daniel avatar
    4945 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>())
    {
        imageInline.ImageSource.Freeze();
    }

    Regards,
    Daniel
    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. UI for ASP.NET Ajax is Ready for VS 2017
  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,
    Arron
  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
    converter
    . Using any other PDF converter may harm your data and its
    formatting after conversion. So it is recommended that use a perfect PDF
    converter. 



  6. compLex
    compLex avatar
    1 posts
    Member since:
    Nov 2016

    Posted 10 Nov in reply to Daniel Link to this post

    Hello,
    we are looking for a good solution to convert word DOC files into PDF.
    The DOCX To PDF conversation in Telerik works really good.
    Is there a possible solution to convert DOC files as well?

    Thank you

    compLex

  7. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 10 Nov Link to this post

    Hello,

    DOC format is not supported at this point. You can vote for the following item within our feedback portal:
    WordsProcessing: Support for .doc files

    Regards,
    Daniel
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017