-
Notifications
You must be signed in to change notification settings - Fork 20
Minimal working example
Giorgio Bianchini edited this page Jul 26, 2022
·
2 revisions
The following example shows the bare minimum code necessary to render a page of a PDF document to a PNG image using MuPDFCore:
//Initialise the MuPDF context. This is needed to open or create documents.
using MuPDFContext ctx = new MuPDFContext();
//Open a PDF document
using MuPDFDocument document = new MuPDFDocument(ctx, "path/to/document.pdf");
//Page index (page 0 is the first page of the document)
int pageIndex = 0;
//Zoom level, converting document units into pixels. For a PDF document, a 1x zoom level corresponds to a
//72dpi resolution.
double zoomLevel = 1;
//Save the first page as a PNG image with transparency, at a 1x zoom level (1pt = 1px).
document.SaveImage(pageIndex, zoomLevel, PixelFormats.RGBA, "path/to/output.png", RasterOutputFileTypes.PNG);