Convert a single page of multipaged document to PNG in .NET

@NPozdniakov

PageCount is the number of pages to convert starting from PageNumber. Furthermore, take a look at this API reference.

Correct but my point is it doesn’t work. I specify page 1 and gives me more. Works fine for Word but not for Excel.

@NPozdniakov

Please utilize following code (load option for Excel/Spreadsheet):

Func<LoadOptions> getLoadOptions = () => new SpreadsheetLoadOptions
{ 
    OnePagePerSheet = true
};
Converter converter = new Converter(@"D:/ALEWIS_0000000021.0001.XLS", getLoadOptions); 

Set OnePagePerSheet to true and you’ll get one image in output.

@NPozdniakov
I agree with you that it does not work the way it’s intended.

If you just want to create a preview and because of that, the “OnePagePerSheet = true” is giving you a too small result, you may want to add “ConvertRange” to your SpreadsheetLoadOptions.
e.g. loadOptions.ConvertRange = “A1:AF50”;

it will of course cut off data outside this range, but for a preview / thumbnail it’s good enough.

1 Like

@Clemens_Pestuka

Yes, that can help if you are going to generate images for preview/thumbnail.

It maybe good enough for now. Ultimately @Clemens_Pestuka is right, it doesn’t work as intended and I would like to see this fixed.
Thank you both for suggestions.

2 Likes

@NPozdniakov

You are welcome. We’ll let you know if we implement further improvements for this scenario.

The issues you have found earlier (filed as CONVERSIONNET-6035) have been fixed in this update. This message was posted using Bugs notification tool by nikola.yankov

It appears that the issue you’re encountering is tied to the Conversion .Net 20.1 update, where the capability to convert a single page of a multi-page document into PNG has been affected. The suggested approach is to utilize SavePageStream as a potential workaround for this problem.

However, if you’re searching for a more user-friendly, non-programmatic solution, I’d recommend trying an online tool like Converter365, a PNG converter that provides hassle-free conversions without the need to write any code. This might be particularly beneficial if you have only a few files and are looking for a straightforward method.

On the other hand, if your goal is to incorporate conversion functionalities within a more extensive system or application, then it’s essential to keep abreast of the provided code and suggestions. The problem might sometimes be specific to certain files, such as the creation of an unanticipated additional page during the conversion. It might necessitate either a more detailed investigation or an update from the software developers to resolve.

@EnigmaticEcho

Yes, the workaround will work.