Images are not in the right place when converting PDF for .NET

Hello,

When converting to Pdf and previewing the same Word file, we’re having problems with the images in the documents.
After a few investigations and tests on the parameters of the images in the Word file, nothing was really conclusive.

Please find enclosed:

  • the Word file to be converted → R2401.0013-V1_C09962_RENAULT - 4EVER - Front and Rear Bumpers (C09962)_essais LA01.docx
  • the pdf file obtained using aspose → result.pdf
  • the file obtained by saving Word as a PDF file → Excepted.pdf

You can see the problem on page 10 of the file result.pdf and on page 9 of the file R2401.0013-V1_C09962_RENAULT - 4EVER - Front and Rear Bumpers (C09962)_essais LA01.docx or Excepted.pdf.

Here are the codes used for pdf conversion

protected void ConvertToPdf(string wordFile)
{
    Document doc = new Document(wordFile);

    PdfSaveOptions options = new PdfSaveOptions()
    {
        SaveFormat = SaveFormat.Pdf,
    };

    doc.Save(Path.ChangeExtension(wordFile, ".pdf"), options);
}

The version of Aspose used is 24.1.0.

Here’s the code used for the preview

using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Results;
using System;
using System.IO;

namespace Web.code.Lib.GroupDocsViewer
{
    public class HtmlViewer : IDisposable
    {
        private readonly GroupDocs.Viewer.Viewer viewer;
        private readonly HtmlViewOptions htmlViewOptions;
        private readonly ViewInfoOptions viewInfoOptions;

        private Stream stream;

        public HtmlViewer(string filePath, LoadOptions loadOptions)
        {
            viewer = new GroupDocs.Viewer.Viewer(filePath, loadOptions);
            htmlViewOptions = CreateHtmlViewOptions();
            viewInfoOptions = ViewInfoOptions.FromHtmlViewOptions(htmlViewOptions);
        }

        private HtmlViewOptions CreateHtmlViewOptions()
        {
            HtmlViewOptions htmlViewOptions = HtmlViewOptions.ForEmbeddedResources(
                // The action that will be done before each page informations is read
                pageNumber =>
                {
                    Stream pageStream = new MemoryStream();
                    stream = pageStream;

                    return pageStream;
                },
                // The action to do after each page information is read.
                // Must be there otherwise the stream is disposed and we can't used it anymore
                (pageNumber, stream) =>
                {
                });

            htmlViewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet();
            htmlViewOptions.SpreadsheetOptions.TextOverflowMode = TextOverflowMode.HideText;
            htmlViewOptions.SpreadsheetOptions.RenderHeadings = true;

            htmlViewOptions.ExcludeFonts = false;

            return htmlViewOptions;
        }

        public string GetPageContent(int pageNumber)
        {
            viewer.View(htmlViewOptions, pageNumber);
            stream.Position = 0;
            using (StreamReader reader = new StreamReader(stream))
            {
                string htmlContent = reader.ReadToEnd();
                stream.Dispose();
                return htmlContent;
            }
        }

        public void Dispose()
        {
            viewer.Dispose();
        }
    }
}

Version of GroupDocs.Viewer used 23.12.

We’re developing a web application and your solution is being used by our application for customers who want to be able to preview and convert their files correctly.

Thanks in advance

@BASSETTI Could you please attach your problematic input and output documents here for testing? Unfortunately, I do not see any attachments in your initial post. We will check the issue and provide you more information.

@alexey.noskov, yeah sorry i have forgot to join the file.
Here, the file for testing and pdf excepted and result obtains thanks to aspose.
R2401.0013-V1_C09962_RENAULT - 4EVER - Front and Rear Bumpers (C09962)_essais LA01.docx (6.3 MB)
result.pdf (3.5 MB)
Excepted.pdf (1.3 MB)

@BASSETTI
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): WORDSNET-26539

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.

@alexey.noskov
I wanted to use the fix, but on which release will it be available?
I didn’t see it on 24.02 release

Thanks by advanced.

@BASSETTI The issue is already resolved in the current codebase. The fix will be included into the next 24.3 (March 2024) version of Aspose.Words. We will be us to let you know once it us published.

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