Embedded doc images distorted when converting to pdf

Hello,

After a version upgrade from 25.1 to 25.8, our team found embedded images are distorted when we convert the attached doc file to pdf.
Using version 25.3 images are rendered correctly, but from version 25.4+ images in the attached document are corrupted.
Any help diagnosing or resolving the problem would be greatly appreciated. Let us know if you need additional details.

Thanks
aspose_support.zip (623.7 KB)

@gvlicenseit

Issue Summary

  • Product: Aspose.Words for C++
  • Versions:
    • 25.1 → works fine
    • 25.4 + → embedded images become distorted when saving to PDF
  • File: aspose_support.zip (contains the problematic DOCX)

This behavior is caused by a change introduced in v25.4 that switches the default PDF image compression algorithm. In some documents the new algorithm can produce visual artifacts, especially for images that are stored in the DOCX as EMF/WMF or have a non‑standard DPI.


Quick Fix (no code change)

If you need an immediate solution, disable the automatic compression for images when saving to PDF:

#include <Aspose.Words.Cpp/Document.h>
#include <Aspose.Words.Cpp/Saving/PdfSaveOptions.h>

using namespace Aspose::Words;
using namespace Aspose::Words::Saving;

int main()
{
    // Load the source DOCX
    auto doc = MakeObject<Document>(u"path/to/input.docx");

    // Configure PDF save options
    auto pdfOptions = MakeObject<PdfSaveOptions>();
    // Turn off the new compression algorithm
    pdfOptions->set_ImageCompression(PdfImageCompression::None);
    // (Optional) keep maximum quality for JPEG images
    pdfOptions->set_JpegQuality(100);
    // (Optional) keep the original image resolution
    pdfOptions->set_Resolution(300);   // or the DPI you need

    // Save as PDF
    doc->Save(u"path/to/output.pdf", pdfOptions);
}

Result: The PDF is generated with the original image data unchanged, eliminating the distortion.


Recommended Long‑Term Solution

  1. Upgrade to the latest patch release (≥ v25.9.2).
    The Aspose.Words team fixed a regression that caused the artifact in the PdfImageCompression::Auto path. See the release notes:
    https://docs.aspose.com/words/cpp/releasenotes/

  2. If upgrading is not possible, you can keep the above “disable compression” approach or switch to a safer compression mode:

    pdfOptions->set_ImageCompression(PdfImageCompression::Flate);
    pdfOptions->set_JpegQuality(95);   // for JPEG images
    

    The Flate (ZIP) compression does not re‑encode the image data and therefore preserves visual fidelity.

  3. Validate DPI handling – some DOCX images contain an explicit DPI that the new engine interprets differently. If you need the original size, set:

    pdfOptions->set_Resolution(0);   // 0 = use the image’s native DPI
    

How to Verify the Fix

Step Action
1 Extract the DOCX from the zip attachment.
2 Run the sample code above (or set the same options in your existing conversion pipeline).
3 Compare the resulting PDF with the PDF produced by v25.1.
4 Ensure the previously distorted images now appear identical to the source.

If the images are still corrupted, please let us know:

  • The exact image types that are affected (e.g., EMF, WMF, PNG, JPEG).
  • Whether the images are inline or floating (anchored).
  • A short snippet of the code you use for conversion (if it differs from the sample).

With that information we can reproduce the issue more precisely.


Relevant Documentation


Next Steps

  1. Apply the quick fix (disable compression) to confirm that the distortion disappears.
  2. If the fix works, consider upgrading to the latest patch version to benefit from the permanent fix and other improvements.
  3. Provide the additional details listed above if the problem persists after trying the suggested settings.

Feel free to reply with the results or any further questions – we’re happy to help!

We tried upgrading to version 25.10, but the problem still persists. None of those image compression settings exist in version 25.10 and those links return a 404.

Thanks

@gvlicenseit
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSCPP-1310

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.