Convert from Word to PDF

2 posts, 0 answers
  1. grenadejumper
    grenadejumper avatar
    1 posts
    Member since:
    Nov 2015

    Posted 25 Nov 2015 Link to this post

    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();
  2. Tanya
    Admin
    Tanya avatar
    402 posts

    Posted 27 Nov 2015 Link to this post

    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
Back to Top