Conversion of specific DOCX file to PNG does not correctly work on Ubuntu

Hello, when converting a specific DOCX file to PNG on Ubuntu, we get the following error:

“Saving complete multi page document to image is not supported. Please save by page.”

We already specify all the things we can:

var imageConvertOptions = new ImageConvertOptions()
{
Format = ImageFileType.Png,
Height = requiredDimension,
HorizontalResolution = 300,
VerticalResolution = 300,
PageNumber = 1,
PagesCount = 1,
Pages = [1]
};

… but still this doesnt help. Attached you find the file.

pv-inspection-2025-emailing-outbound-1-de.docx (155.6 KB)

@reinhardholzner

It seems that you are encountering an issue when trying to convert a multi-page DOCX file to PNG format on Ubuntu. The error message indicates that saving a complete multi-page document to an image is not supported, and you need to save it page by page.

To resolve this, you should ensure that you are specifying the correct options for converting a single page at a time. Here’s an example of how you can modify your code to convert a specific page of the DOCX file to PNG:

var imageConvertOptions = new ImageConvertOptions()
{
    Format = ImageFileType.Png,
    Height = requiredDimension,
    HorizontalResolution = 300,
    VerticalResolution = 300,
    PageNumber = 1, // Specify the page number you want to convert
    PagesCount = 1, // Set to 1 to convert only one page
};

// Assuming you have a method to handle the conversion
converter.convert(() => getPageStream, imageConvertOptions);

Make sure to adjust the PageNumber to the specific page you want to convert. If you need to convert multiple pages, you will have to loop through the pages and call the conversion method for each page individually.

If you continue to face issues, please check the documentation or examples related to converting documents to images, as they often provide insights into handling specific cases like yours.

For further assistance, you might want to look at the examples provided in the GroupDocs conversion repository, which demonstrate how to convert documents to images with various options.

If you have any more questions or need further clarification, feel free to ask!

Sorry, but the auto-suggestions provided no additional useful information.

@reinhardholzner

Can you please share which version of GroupDocs.Conversion you’re using since there are two possible versions of code for v24.10 and later and previous versions that is highlighted in Convert Word document to Image topic?

GroupDocs.Conversion 25.2.1

@reinhardholzner

Thanks, we’ll double check this and update you.

@reinhardholzner

Unfortunately, I have failed to reproduce this issue in Docker using this sample-app.zip (144.6 KB). Can you please check the app and try running it on your side?

You are using SavePageContext. Please try using:


using var converter = new Converter(() => inputStream, (LoadContext loadContext) => GetLoadOptions(loadContext, convertOptions), settings: null);

converter.Convert((ConvertContext convertContext) => GetConvertOptions(convertContext, convertOptions), (ConvertedContext convertedContext) => convertedContext.ConvertedStream.CopyTo(outputStream));

outputStream.Seek(0, SeekOrigin.Begin);


We only want to get the first page of the document as a preview.

@reinhardholzner

I have updated the app - sample-app-1.zip (190.0 KB) and added the following method:

private static void ConvertDocxToPng1()
{
    var imageConvertOptions = new ImageConvertOptions()
    {
        Format = ImageFileType.Png,
        Height = 300,
        HorizontalResolution = 300,
        VerticalResolution = 300,
        PageNumber = 1,
        PagesCount = 1,
        Pages = [1]
    };

    // Load the source DOCX file
    using var converter = new Converter(
        () => File.OpenRead("pv-inspection-2025-emailing-outbound-1-de.docx"), 
        (LoadContext loadContext) => new WordProcessingLoadOptions(), 
        settings: null);

    converter.Convert(
        (ConvertContext convertContext) => imageConvertOptions, 
        (ConvertedContext convertedContext) => convertedContext.ConvertedStream.CopyTo(File.OpenWrite("output/page-1.png")));
}

But can’t reproduce the issue. May you please update the sample application or share a complete code snippet?

Please note that some of the Conversion methods are designed to convert whole document and some of them are for page by page conversion.

Hm if I state I want to have only one page, it should be ending up with only one page.

Is there a way using SavePageContext to only convert the first page, and cancel the process then (if there would be somehow > 1 page)?