This is a migrated thread and some comments may be shown as answers.

Word document to PDF conversion Image issue using PdfFormatProvider

5 Answers 162 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anup Indurkar
Top achievements
Rank 1
Anup Indurkar asked on 23 Apr 2014, 06:38 PM
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

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 28 Apr 2014, 08:43 AM
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.

 
0
Arron
Top achievements
Rank 1
answered on 08 May 2014, 06:32 AM
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
0
Alice
Top achievements
Rank 1
answered on 24 Mar 2015, 07:39 AM
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. 



0
compLex
Top achievements
Rank 1
answered on 10 Nov 2016, 10:06 AM

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

0
Daniel
Telerik team
answered on 10 Nov 2016, 11:41 AM
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.
Tags
General Discussions
Asked by
Anup Indurkar
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Arron
Top achievements
Rank 1
Alice
Top achievements
Rank 1
compLex
Top achievements
Rank 1
Share this question
or