summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz/document.h8
-rw-r--r--source/fitz/document.c6
-rw-r--r--source/html/epub-doc.c1
-rw-r--r--source/html/html-doc.c2
-rw-r--r--source/tools/murun.c15
5 files changed, 32 insertions, 0 deletions
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h
index f1a4a74f..b3ae4601 100644
--- a/include/mupdf/fitz/document.h
+++ b/include/mupdf/fitz/document.h
@@ -91,6 +91,7 @@ struct fz_document_s
fz_document_load_page_fn *load_page;
fz_document_lookup_metadata_fn *lookup_metadata;
int did_layout;
+ int is_reflowable;
};
typedef fz_document *(fz_document_open_fn)(fz_context *ctx, const char *filename);
@@ -197,6 +198,13 @@ int fz_authenticate_password(fz_context *ctx, fz_document *doc, const char *pass
fz_outline *fz_load_outline(fz_context *ctx, fz_document *doc);
/*
+ fz_is_document_reflowable: Is the document reflowable.
+
+ Returns 1 to indicate reflowable documents, otherwise 0.
+*/
+int fz_is_document_reflowable(fz_context *ctx, fz_document *doc);
+
+/*
fz_layout_document: Layout reflowable document types.
w, h: Page size in points.
diff --git a/source/fitz/document.c b/source/fitz/document.c
index b2590f07..116f38d8 100644
--- a/source/fitz/document.c
+++ b/source/fitz/document.c
@@ -164,6 +164,12 @@ fz_ensure_layout(fz_context *ctx, fz_document *doc)
}
int
+fz_is_document_reflowable(fz_context *ctx, fz_document *doc)
+{
+ return doc ? doc->is_reflowable : 0;
+}
+
+int
fz_needs_password(fz_context *ctx, fz_document *doc)
{
if (doc && doc->needs_password)
diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c
index 541fb7eb..ec506409 100644
--- a/source/html/epub-doc.c
+++ b/source/html/epub-doc.c
@@ -425,6 +425,7 @@ epub_init(fz_context *ctx, fz_archive *zip)
doc->super.count_pages = epub_count_pages;
doc->super.load_page = epub_load_page;
doc->super.lookup_metadata = epub_lookup_metadata;
+ doc->super.is_reflowable = 1;
fz_try(ctx)
{
diff --git a/source/html/html-doc.c b/source/html/html-doc.c
index 2e8b8ec4..f14ddc35 100644
--- a/source/html/html-doc.c
+++ b/source/html/html-doc.c
@@ -123,6 +123,7 @@ htdoc_open_document_with_stream(fz_context *ctx, fz_stream *file)
doc->super.layout = htdoc_layout;
doc->super.count_pages = htdoc_count_pages;
doc->super.load_page = htdoc_load_page;
+ doc->super.is_reflowable = 1;
doc->zip = fz_open_directory(ctx, ".");
doc->set = fz_new_html_font_set(ctx);
@@ -150,6 +151,7 @@ htdoc_open_document(fz_context *ctx, const char *filename)
doc->super.count_pages = htdoc_count_pages;
doc->super.load_page = htdoc_load_page;
doc->super.lookup_metadata = htdoc_lookup_metadata;
+ doc->super.is_reflowable = 1;
doc->zip = fz_open_directory(ctx, dirname);
doc->set = fz_new_html_font_set(ctx);
diff --git a/source/tools/murun.c b/source/tools/murun.c
index a1671bbd..e46033d9 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1435,6 +1435,20 @@ static void ffi_Document_getMetaData(js_State *J)
js_pushstring(J, info);
}
+static void ffi_Document_isReflowable(js_State *J)
+{
+ fz_context *ctx = js_getcontext(J);
+ fz_document *doc = js_touserdata(J, 0, "fz_document");
+ int is_reflowable;
+
+ fz_try(ctx)
+ is_reflowable = fz_is_document_reflowable(ctx, doc);
+ fz_catch(ctx)
+ rethrow(J);
+
+ js_pushboolean(J, is_reflowable);
+}
+
static void ffi_Document_layout(js_State *J)
{
fz_context *ctx = js_getcontext(J);
@@ -3438,6 +3452,7 @@ int murun_main(int argc, char **argv)
jsB_propfun(J, "Document.authenticatePassword", ffi_Document_authenticatePassword, 1);
//jsB_propfun(J, "Document.hasPermission", ffi_Document_hasPermission, 1);
jsB_propfun(J, "Document.getMetaData", ffi_Document_getMetaData, 1);
+ jsB_propfun(J, "Document.isReflowable", ffi_Document_isReflowable, 0);
jsB_propfun(J, "Document.layout", ffi_Document_layout, 3);
jsB_propfun(J, "Document.countPages", ffi_Document_countPages, 0);
jsB_propfun(J, "Document.loadPage", ffi_Document_loadPage, 1);