From ec19caddb60e748115adb562b46d007598dcdb95 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 2 Aug 2026 21:28:49 -0300 Subject: render PDFs as a continuous vertical page strip --- src/pdf_bridge.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/pdf_bridge.c') 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 @@ -230,6 +230,39 @@ pardes_pdf_close(pardes_pdf_document *document) free(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, -- cgit v1.3