We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

Convert docx to pdf loses images

Hello,

We recently upgraded our C# conversion project to .Net 6 and upgraded GroupDocs.Conversion to 22.5 at the same time. We are noticing that images get dropped from the output when converting docx to pdf. This appears to have been a problem for a while now, though our previous version, 20.8, worked fine (unfortunately, we cannot go back to that version due to the fact that it doesn’t support .Net 6)

The converter is running on Windows. Here’s our conversion code:

        public override async Task<Stream> ConvertToThumbnailAsync(Stream source, int width, int height)
    {
        Stream thumbnailStream = null;

        var options2 = new PdfConvertOptions
        {
            Format = PdfFileType.Pdf,
            PageNumber = 1,
            PagesCount = 1
        };

        source = await ConvertToType(source, options2);

        using (Converter converter = new Converter(() => source))
        {
            thumbnailStream = new MemoryStream();

            var options = new ImageConvertOptions
            {
                Format = ImageFileType.Png,
                PageNumber = 1,
                PagesCount = 1,
                Height = height
            };

            converter.Convert(() => new MemoryStream(), (convertedStream, x) =>
            {
                convertedStream.CopyTo(thumbnailStream);
            }, options);
        }

        return await Task.FromResult(thumbnailStream);
    }

    protected async Task<Stream> ConvertToType(Stream source, ConvertOptions options)
    {
        Stream stream = null;

        using (Converter converter = new Converter(() => source))
        {
            stream = new MemoryStream();

            converter.Convert(() => new MemoryStream(), (convertedStream, x) =>
            {
                convertedStream.CopyTo(stream);
            }, options);
        }

        return await Task.FromResult(stream);
    }

What other information can I provide?

@dallen3xerox

We are investigating this scenario. Your investigation ticket ID is CONVERSIONNET-5297. We’ll notify you in case of any update.

Hi Atir, my apologies. I got to the root of the problem when I tried to reproduce it in a console app. It turns out that we were including an old version of libSkiaSharp.dll in our project output. It took me 2 days to find it, but once it was removed everything worked fine. Thanks for your help!

@dallen3xerox

You are welcome.