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

Convert from Word to PDF

3 Answers 1079 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
grenadejumper
Top achievements
Rank 1
grenadejumper asked on 25 Nov 2015, 12:50 PM
Hello.

I am trying to convert docx-files to pdf-files using DocxFormatProvider to import the files, and using PdfFormatProvider to export the files. This works fine in most cases, but it seems that images that are not inline are missing from the generated pdf-file.

Example:
If I have a word-file with 2 images and some text. One image is inline, another is not (lets say it has the text-wrap setting to "square"). I import the docx-file to a RadFlowDocument. The inline image gets detected in the RadFlowDocument as ImageInLine, while the image with text-wrap gets detected as FloatingImage. In the end I export as PDF and save it locally. When I open the PDF, only text and the inline image is showing, the floating (text-wrapped) image is gone.

Is there a way to keep all images when converting from docx to pdf?

Here is a snippet of my code:
 
var providerDocx = new DocxFormatProvider();
var document = providerDocx.Import(inStream); //inStream is read from a docx file earlier
 
var providerPdf = new PdfFormatProvider();
 
Stream outStream = new MemoryStream();
providerPdf.Export(document, outStream);
 
//Test the conversion:
var fileStream = File.Create("PdfTest.pdf");
outStream.Seek(0, SeekOrigin.Begin);
outStream.CopyTo(fileStream);
fileStream.Close();

3 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 27 Nov 2015, 06:44 PM
Hi,

The floating images are not supported by the PdfFormatProvider, used to  export RadFlowDocument. We have already logged a request for this feature and you could vote and subscribe to the related feedback item in order to receive updates about status changes on it.

Regards,
Tanya
Telerik
0
Moe
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 25 Mar 2019, 03:04 AM

Hi Tanya,

I also have same problem and other problem also textbox. When converting from docx to pdf , textbox didn't convert .

 

Thanks

Moe

0
Tanya
Telerik team
answered on 26 Mar 2019, 09:54 AM
Hi Moe,

The text boxes in a DOCX document could be defined as shapes or as content controls. At this point, both types of document elements are not supported and here are the items we have logged for the implementation of the functionalities:
You can vote for the implementation of the tasks as well as subscribe to track their status using the public items above. The text boxes are currently skipped while importing the document and I am afraid that I cannot suggest an approach for preserving them.

Regards,
Tanya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Joseph
Top achievements
Rank 1
commented on 30 Nov 2021, 05:11 PM

Hi, 

I am trying to accomplish a similar goal to the original poster's. I have a method which attempts to create a RadFlowDocument from a .docx file stream, and then to export this RadFlowDocument to PDF. It works fine for most .docx files. However, it is breaking on files that have "Track Changes" sections, throwing an InvalidOperationException. The stack trace is shown here: 

 

It is my understanding that DocxFormatProvider doesn't support the Track Changes feature. Does anyone have a workaround or know of a way to fix this issue?

 

Thank you, and best regards, 

Joseph

Tanya
Telerik team
commented on 01 Dec 2021, 03:07 PM

Hi Joseph,

We have that behavior logged on our feedback portal: WordsProcessing: InvalidOperationException thrown when document with comment on a deleted text is imported. You can use the related item to subscribe for notifications about status changes on the task. I am afraid that, due to the nature of the issue and the currently missing implementation for Track Changes, there is no approach that I could suggest for working around the error. I am sorry I couldn't help more with that.

Hope this information is useful.

Tags
WordsProcessing
Asked by
grenadejumper
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Moe
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or