summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-03-16 12:23:44 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-03-22 14:58:01 +0100
commit7198221904de877d9b28fb906f850c7b05750477 (patch)
treeca0081dba6df26c889d96b74da170b42988065fc
parentdd0badd75b48f50e7bd9f15c0ebafcdb48e16e66 (diff)
downloadmupdf-7198221904de877d9b28fb906f850c7b05750477.tar.xz
Fall back to PDF document handler if no handler is found.
-rw-r--r--source/fitz/document.c11
1 files changed, 11 insertions, 0 deletions
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);