I have a DOCX file with a header logo.
I import the file in a RadFlowDocument and edit it with a RadFlowDocumentEditor.
If I save it in a new DOCX everything it is OK.
If I save a PDF (with Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider) the image disappears.
The image in my DOCX is "in line".
So I think I should not convert images to "ImageInline", right?
If so, why have not the class Telerik.Windows.Documents.Model.ImageInline?
My Telerik version is 2016.2.607.
11 Answers, 1 is accepted
We are unaware of issues related to the export of inline images to PDF and I am not sure what might be causing the behavior you are experiencing. Is it possible to share a document showing the exact case so we can test it locally?
Telerik by Progress
I have the same problem with 2016.2.607 when saving a RadFlowDocument as PDF.
To solve this, I had to do first create a new image with the existing data and then resave it as a PNG:
Once I did this step, the images were correctly added to the PDFs.
Hope this helps!
Sorry, forgot the first line of code.
As I mentioned in my previous post, the inline images are supported and I cannot say what the reason might be before testing a sample document.
Since you haven't specified the type of the image you are having troubles with, I would like to mention that the floating images are not supported by PdfFormatProvider and are skipped when you export PDF documents. If you would like, you can vote for the implementation of that feature and track its status through the related public item.
Telerik by Progress
I'm sorry but I do not understand the first line ... What is row["Picture"]?
However I solved by modifying the original document and using PNG images.
Now the output in DOCX is changed but well or other problem in the PDF generation. All paragraphs of justified text in DOCX, are left-aligned in the PDF.
thank you so much
Im having same same problem when trying to convert a docx (having logo/clip art images) to pdf. The backcolor of the images are turning black. Is there any solution for this?
Is there anyway i can convert those problematic images to png during conversion?
Here is my code,
var fileFormatProvider = new DocxFormatProvider();
var document = new RadFlowDocument();
string pdfFilename = string.Empty;
using (FileStream input = new FileStream(docxReportfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
document = fileFormatProvider.Import(input);
byte renderedBytes = null;
IFormatProvider<RadFlowDocument> formatProvider = new PdfFormatProvider();
using (MemoryStream ms = new MemoryStream())
renderedBytes = ms.ToArray();
pdfFilename = Path.ChangeExtension(docxReportfile, ".pdf");
You may enumerate the images in the RadFlowDocument instance and change their ImageSource properties. The following code snippet shows how to enumerate all ImageInline instances, calculate their image bytes so that they become valid PNG images and then change the ImageSouce.
It would also be helpful if you can share a link for downloading the problematic DOCX file. This way we would be able to reproduce the original issue on our side and try to provide a more concrete solution.
I hope this helps.
Is there any chance you could post the CreatePngImageBytes routine?
Actually I may have sorted that already ... but I have a further question
I've been using a RadDocument. My docx loads fine using that. However I don't have access to convert the embedded bitmaps to pngs as far as I can see. It looks like your code is tied to a RadFlowDocument as was Sharon's example code above.
However, if I try and load my docx in to RadFlowDocument, it errors out on the DocxFormatProvider.Import with an error
"Value cannot be null.
Parameter name: relationshipId"
Why would the RadDocument be ok and the RadFlowDocument not?
Further, if I need to use the RadDocument, how would I convert embedded images to pngs.
Many thx again
RadWordsProcessing and RadRichTextBox are two separate products and they do not have common codebase. This explains the different support of functionalities provided by the corresponding RadFlowDocument and RadDocument classes.
In order to reproduce the mentioned import exception, we need to test the problematic DOCX file. Could you send us this file either by adding it as an attachment to a newly opened support ticket or by sending a link to the file in this public forum thread? This way we will be able to investigate the concrete cause of the issue and suggest a solution for it.
As for changing the images with RadDocument - it is done in a way similar to the RadFlowDocument approach. There are only two API differences. The first difference is that instead of using Data property you should use InlineImage GetBytes() method. The second difference is that you should change the image source by using InlineImage Init method.
I hope this information is helpful.