Method RenderToMaxDimension
RenderToMaxDimension(int, int)
Renders a page so its LONGEST side is exactly maxDimension pixels,
preserving the page's aspect ratio; the shorter side follows. Every rendered page
therefore shares one max-dimension box regardless of orientation or native canvas
size - ideal for uniform thumbnails and previews.
public ImageBuffer RenderToMaxDimension(int maxDimension, int pageIndex = 0)
Parameters
maxDimensionintTarget size in pixels of the longer side (clamped to at least 1).
pageIndexintZero-based page index. Default is 0 (first page).
Returns
- ImageBuffer
A new ImageBuffer sized to the max-dimension box.
Examples
using var attachment = new Attachment("slides.pdf");
using ImageBuffer thumb = attachment.RenderToMaxDimension(maxDimension: 800, pageIndex: 0);
byte[] webp = thumb.SaveAsWebpBytes(quality: 90);
Remarks
For paginated documents that rasterize (e.g. PDF) the page is drawn straight to the target pixel box, so the output is exactly sized and vector-crisp - there is no zoom/DPI round-trip. For raster images the native frame is fit DOWN into the box and never upscaled (enlarging a raster only invents blur).
The returned ImageBuffer must be disposed by the caller.