Keep aspect ratio when converting using Width/Height property in .NET

Hi,

I want to create thumbnails of MS Word file using GroupDocs.Conversion .Net 19.12.1, so I need to specify a small Width for the ImageConvertOptions.
Unfortunately the thumbnails are squeezed, as their height is now much larger than their Width.
Is there a way to tell the Conversion API to keep the aspect ratio and adapt the height if not specified?

I tried the same thing using GroupDocs.Viewer and only specified the Width in PngViewOptions and it worked :grinning:
I would consider using the Viewer for thumbnail generation, but I’m not happy how Excel files are handled.
If there would be a way to split the file into A4 (or system default) paper size, I’d use the Viewer.
At the moment the Viewer renders everything from the first column to the last one and SpreadsheetOptions.ForSplitSheetIntoPages only uses rows and not columns.

@Clemens_Pestuka,

Can you please clarify, will you now proceed with GroupDocs.Viewer API for you needs? We’ll then assist you accordingly and move thread to GroupDocs.Viewer category.

@atirtahir3
Thanks for the reply. I’d rather go for GroupDocs.Conversion, as we’re using it primarily for all other conversion tasks.

1 Like

@Clemens_Pestuka,

Thanks for the clarification.

Please share sample code, source and output files, we’ll then investigate this scenario.

@atirtahir3

Thank you, I updated to 20.1 now and the issue is gone :slight_smile:

With 19.12.1 I’ve used the ConvertToPng sample, but with the attached file and the “Width” parameter:

        using (Converter converter = new Converter(@"C:\Portrait_Landscape.docx"))
        {
            ImageConvertOptions options = new ImageConvertOptions
            {
                Format = ImageFileType.Png,
                Width = 256
            };
        ...

Conversion Aspect Ratio.zip (43.7 KB)

But I guess it’s not really worth to investigate this any further as it works with 20.1.

@Clemens_Pestuka,

Good to know that your issue is resolved.

:smiley: sorry that was too quick… I did find another issue:

Portrait Landscape issue.zip (25.6 KB)

The aspect ratio is now correct, but the landscape page looks like portrait now.

@Clemens_Pestuka,

We are investigating this. Your investigation ticket ID is CONVERSIONNET-3728. As there is any further update, you’ll be notified.

1 Like

@Clemens_Pestuka,

Your reported issue CONVERSIONNET-3728 is now fixed in version 20.3.

1 Like

@atirtahir3

Thank you for your help :grinning:, I can confirm that aspect ratio and portrait/landscape layout are now applied correctly!

1 Like

@Clemens_Pestuka,

You’re welcome.