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

Convert Docx with images to PDF

3 Answers 261 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 20 Sep 2018, 07:26 PM

Hello, in an MVC application I need to convert a .docx that contains images into a pdf. My code below works if the docx does not contain an image. If the docx contains an image I get an object reference error when importing the document on this line: document = providerDocx.Import(stream);

 

            RadFlowDocument document = null;
            DocxFormatProvider providerDocx = new DocxFormatProvider();
            using (FileStream stream = File.Open(@"C:\\test\myWordDoc.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(@"C:\\test\myWordDoc.pdf");
                outStream.Seek(0, SeekOrigin.Begin);
                outStream.CopyTo(fileStream);
                fileStream.Close();
            }

How can I convert an existing word document with images to a new pdf document?

3 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 25 Sep 2018, 10:52 AM
Hello Scott,

I just tried reproducing the issue with the same code snippet you have shared but to no avail. The document I tested with, containing several images was correctly converted to a pdf file with all the images inside. Could you share the document you have tested with. Also, what is the assemblies version you have in your app. Have you tried the same behavior with the latest R3 2018 official release?

Regards,
Peshito
Progress Telerik

0
Sridevi
Top achievements
Rank 1
answered on 11 Dec 2018, 04:34 PM

https://demos.telerik.com/aspnet-ajax/wordsprocessing/convert-documents/defaultvb.aspx

 

when I try to upload a document with image and click download it is redirecting me to error page

0
Tanya
Telerik team
answered on 13 Dec 2018, 01:18 PM
Hello Sridevi,

I believe we are discussing the same case in the support ticket you have opened. Let's continue the discussion there so we can keep all the information about the scenario in a single thread.

Regards,
Tanya
Progress Telerik

Tags
WordsProcessing
Asked by
Scott
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Sridevi
Top achievements
Rank 1
Tanya
Telerik team
Share this question
or