diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-02 21:28:49 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-10 09:17:07 -0300 |
| commit | ec19caddb60e748115adb562b46d007598dcdb95 (patch) | |
| tree | aaf282dec5beaf445fc7a5fb194aa438c3ae4986 /src/pdf_bridge.c | |
| parent | 5d5f2a25011c751452fb4ff42e28ee84d4bb4fdf (diff) | |
| download | pardes-ec19caddb60e748115adb562b46d007598dcdb95.tar.gz pardes-ec19caddb60e748115adb562b46d007598dcdb95.zip | |
render PDFs as a continuous vertical page strip
Diffstat (limited to 'src/pdf_bridge.c')
| -rw-r--r-- | src/pdf_bridge.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/pdf_bridge.c b/src/pdf_bridge.c index 320919b1..0fcf74c4 100644 --- a/src/pdf_bridge.c +++ b/src/pdf_bridge.c @@ -231,6 +231,39 @@ pardes_pdf_close(pardes_pdf_document *document) } int +pardes_pdf_get_page_size( + pardes_pdf_document *document, + int page_number, + pardes_pdf_page_size *out) +{ + fz_context *ctx; + fz_rect bounds; + + if (document == NULL || out == NULL || page_number < 0 || + page_number >= document->page_count) + return PARDES_PDF_ERROR; + + memset(out, 0, sizeof(*out)); + ctx = document->ctx; + fz_try(ctx) + { + pardes_pdf_cache_page(document, page_number, 0); + bounds = document->cached_bounds; + out->width = bounds.x1 - bounds.x0; + out->height = bounds.y1 - bounds.y0; + if (!(out->width > 0.0f) || !(out->height > 0.0f)) + fz_throw(ctx, FZ_ERROR_FORMAT, "PDF page has empty bounds"); + } + fz_catch(ctx) + { + fz_report_error(ctx); + memset(out, 0, sizeof(*out)); + return PARDES_PDF_ERROR; + } + return PARDES_PDF_OK; +} + +int pardes_pdf_render( pardes_pdf_document *document, int page_number, |
