Aspose.Words .NET - image lost when converting to PDF

Hi
We have a word document containing two images. When converting it to PDF (or PDF/A-2a) using Aspose.Words for .NET 21.10.0 (same with 21.8.0) the first of the images is lost, while the second is added to the PDF.
I have attached an example Word and the resulting PDF which was generated with:
var input = new Document("C:\\tmp\\Input.docx");
input.Save("C:\\tmp\\Output.pdf");

        /*
         Same result when using:
        var saveOptions = new PdfSaveOptions
        {
            Compliance = PdfCompliance.PdfA2a
        };
        input.Save("C:\\tmp\\Output.pdf", saveOptions);
        */`
  • When opening the word file with MS Word, save as pdf -> both images are contained
  • When opening the word file, right click on the first image -> change how it interacts with the text (the setting can remain the same, but it has to be changed manually first), then the PDF generated with Aspose.Words contains both images
  • The images have been added to the Word File while editing it with OnlyOffice in our application

Best Regards
Thomas Jost

Input.docx (1.6 MB)
Output.pdf (1.0 MB)

@thomas.jost,

I am afraid, I was unable to reproduce this issue when rendering “input.docx” to PDF format on my side (please see attached output: 21.10.pdf (1.6 MB)). Could you please double check if you had attached the correct source Word document that you’re actually getting this problem with? Please download DOCX file from your first post and try to convert it to PDF.

A post was split to a new topic: Retain Pictures during Word to PDF Conversion in C# over Linux

@awais.hafeez
Thank you for checking. I downloaded the file again and tried it in our application and in an “empty” console application and I could only reproduce it in our application at first.

After some testing I could reduce it to the following dependency we have in our application:

<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.3" />

With Aspose.Words and this additional dependecy, I can reproduce the problem in a plain console application too, with only the two mentioned lines of code.
I am now checking whether I can remove it from our application, but a collegue of mine mentioned that there was an error when running on linux without this dependency.

But even if I would be able to remove it from our application, it would be interesting to find out why this dependency breaks rendering of images for some cases.

Unfortunately our build (linux) does not run without this dependency:
System.DllNotFoundException: Unable to load shared library ‘libSkiaSharp’ or one of its dependencies.

Therefore we’d need a solution for the problem even if Skia is a dependency of the project.
If you need any more information, feel free to contact me.

@thomas.jost I managed to reproduce the problem on my side and logged it as WORDSNET-22859 in our defect tracking system.
However I almost 100% sure that this is a bug in SkiaSharp 2.80.3 version. If you do not need new features introduced in this version of SkiaSharp you can simply use 2.80.1 version. Simply update package reference as the following:

<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.1" />

And the image will be rendered on both Windows and Linux.

Thank you very much, in my Test Console Application this fixed the problem. I’ll test with the actual application now, but I’m positive this will help too :slight_smile:

The issues you have found earlier (filed as WORDSNET-22859) have been fixed in this Aspose.Words for .NET 21.12 update also available on NuGet.