From 7198221904de877d9b28fb906f850c7b05750477 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 16 Mar 2018 12:23:44 +0100 Subject: Fall back to PDF document handler if no handler is found. --- source/fitz/document.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/fitz/document.c') diff --git a/source/fitz/document.c b/source/fitz/document.c index 2b494c62..b74f7de5 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -124,6 +124,9 @@ fz_recognize_document(fz_context *ctx, const char *magic) return dc->handler[best_i]; } +#ifdef FZ_ENABLE_PDF +extern fz_document_handler pdf_document_handler; +#endif fz_document * fz_open_document_with_stream(fz_context *ctx, const char *magic, fz_stream *stream) @@ -135,7 +138,11 @@ fz_open_document_with_stream(fz_context *ctx, const char *magic, fz_stream *stre handler = fz_recognize_document(ctx, magic); if (!handler) +#ifdef FZ_ENABLE_PDF + handler = &pdf_document_handler; +#else fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find document handler for file type: %s", magic); +#endif return handler->open_with_stream(ctx, stream); } @@ -152,7 +159,11 @@ fz_open_document(fz_context *ctx, const char *filename) handler = fz_recognize_document(ctx, filename); if (!handler) +#ifdef FZ_ENABLE_PDF + handler = &pdf_document_handler; +#else fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find document handler for file: %s", filename); +#endif if (handler->open) return handler->open(ctx, filename); -- cgit v1.2.3