summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-06-01 16:06:07 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-06-06 14:53:23 +0200
commitcc1fd2ff2a440a7fdb2a30ef66aba31043c4ba92 (patch)
tree52dc8114ef259825dad3d2c7cc929aa71fcc6c16
parentae64e55878766478f536a0b2158e0a29f5cf00ed (diff)
downloadmupdf-cc1fd2ff2a440a7fdb2a30ef66aba31043c4ba92.tar.xz
Add FZ_ENABLE_JS configuration define.
-rw-r--r--Makefile12
-rw-r--r--Makethird5
-rw-r--r--docs/mutool/examples/pdf-merge.js1
-rw-r--r--include/mupdf/fitz/config.h9
-rw-r--r--platform/win32/generate.bat2
-rw-r--r--platform/win32/libmupdf.vcproj20
-rw-r--r--source/pdf/js/pdf-js-none.c31
-rw-r--r--source/pdf/pdf-js-util.js (renamed from source/pdf/js/pdf-util.js)0
-rw-r--r--source/pdf/pdf-js.c (renamed from source/pdf/js/pdf-js.c)16
-rw-r--r--source/tools/mutool.c2
10 files changed, 44 insertions, 54 deletions
diff --git a/Makefile b/Makefile
index e240f876..be1cdfe2 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,7 @@ RM_CMD = $(QUIET_RM) rm -f $@
# --- File lists ---
ALL_DIR := $(OUT)/fitz
-ALL_DIR += $(OUT)/pdf $(OUT)/pdf/js
+ALL_DIR += $(OUT)/pdf
ALL_DIR += $(OUT)/xps
ALL_DIR += $(OUT)/svg
ALL_DIR += $(OUT)/cbz
@@ -99,12 +99,6 @@ CBZ_OBJ := $(subst source/, $(OUT)/, $(addsuffix .o, $(basename $(CBZ_SRC))))
HTML_OBJ := $(subst source/, $(OUT)/, $(addsuffix .o, $(basename $(HTML_SRC))))
GPRF_OBJ := $(subst source/, $(OUT)/, $(addsuffix .o, $(basename $(GPRF_SRC))))
-ifeq "$(HAVE_MUJS)" "yes"
-PDF_OBJ += $(OUT)/pdf/js/pdf-js.o
-else
-PDF_OBJ += $(OUT)/pdf/js/pdf-js-none.o
-endif
-
$(FITZ_OBJ) : $(FITZ_HDR) $(FITZ_SRC_HDR)
$(PDF_OBJ) : $(FITZ_HDR) $(PDF_HDR) $(PDF_SRC_HDR)
$(XPS_OBJ) : $(FITZ_HDR) $(XPS_HDR) $(XPS_SRC_HDR)
@@ -224,7 +218,7 @@ NAME_GEN := include/mupdf/pdf/name-table.h source/pdf/pdf-name-table.h
$(NAME_GEN) : resources/pdf/names.txt
$(QUIET_GEN) $(NAMEDUMP) resources/pdf/names.txt $(NAME_GEN)
-JAVASCRIPT_SRC := source/pdf/js/pdf-util.js
+JAVASCRIPT_SRC := source/pdf/pdf-js-util.js
JAVASCRIPT_GEN := $(GEN)/gen_js_util.h
$(JAVASCRIPT_GEN) : $(JAVASCRIPT_SRC)
$(QUIET_GEN) $(CQUOTE) $@ $(JAVASCRIPT_SRC)
@@ -246,7 +240,7 @@ generate: $(CMAP_GEN) $(FONT_GEN) $(JAVASCRIPT_GEN) $(ADOBECA_GEN) $(NAME_GEN)
$(OUT)/pdf/pdf-cmap-table.o : $(CMAP_GEN)
$(OUT)/pdf/pdf-pkcs7.o : $(ADOBECA_GEN)
-$(OUT)/pdf/js/pdf-js.o : $(JAVASCRIPT_GEN)
+$(OUT)/pdf/pdf-js.o : $(JAVASCRIPT_GEN)
$(OUT)/pdf/pdf-object.o : source/pdf/pdf-name-table.h
$(OUT)/cmapdump.o : include/mupdf/pdf/cmap.h source/fitz/context.c source/fitz/error.c source/fitz/memory.c source/fitz/output.c source/fitz/string.c source/fitz/buffer.c source/fitz/stream-open.c source/fitz/stream-read.c source/fitz/strtod.c source/fitz/strtof.c source/fitz/ftoa.c source/fitz/printf.c source/fitz/time.c source/pdf/pdf-lex.c source/pdf/pdf-cmap.c source/pdf/pdf-cmap-parse.c source/pdf/pdf-name-table.h
diff --git a/Makethird b/Makethird
index 3a40fcb6..dd6c54e6 100644
--- a/Makethird
+++ b/Makethird
@@ -35,7 +35,10 @@ $(MUJS_OUT)/%.o: $(MUJS_DIR)/%.c | $(MUJS_OUT)
MUJS_CFLAGS := -I$(MUJS_DIR)
-HAVE_MUJS := yes
+else
+
+MUJS_CFLAGS := -DFZ_ENABLE_JS=0
+
endif
# --- FreeType 2 ---
diff --git a/docs/mutool/examples/pdf-merge.js b/docs/mutool/examples/pdf-merge.js
index dd5fb2a5..d8cdcfcb 100644
--- a/docs/mutool/examples/pdf-merge.js
+++ b/docs/mutool/examples/pdf-merge.js
@@ -35,6 +35,7 @@ function copyPage(dstDoc, srcDoc, pageNumber, map) {
var srcPage, dstPage
srcPage = srcDoc.findPage(pageNumber)
dstPage = dstDoc.newDictionary()
+ dstPage.Type = dstDoc.newName("Page")
if (srcPage.MediaBox) dstPage.MediaBox = graftObject(dstDoc, srcDoc, srcPage.MediaBox, map)
if (srcPage.Rotate) dstPage.Rotate = graftObject(dstDoc, srcDoc, srcPage.Rotate, map)
if (srcPage.Resources) dstPage.Resources = graftObject(dstDoc, srcDoc, srcPage.Resources, map)
diff --git a/include/mupdf/fitz/config.h b/include/mupdf/fitz/config.h
index 98262ac3..69f38292 100644
--- a/include/mupdf/fitz/config.h
+++ b/include/mupdf/fitz/config.h
@@ -30,6 +30,12 @@
/* #define FZ_ENABLE_GPRF 1 */
/*
+ Choose whether to enable JavaScript.
+ By default JavaScript is enabled both for mutool and PDF interactivity.
+*/
+/* #define FZ_ENABLE_JS 1 */
+
+/*
Choose which fonts to include.
By default we include the base 14 PDF fonts,
DroidSansFallback from Android for CJK, and
@@ -120,6 +126,9 @@
#define FZ_ENABLE_GPRF 0
#endif /* FZ_ENABLE_GPRF */
+#ifndef FZ_ENABLE_JS
+#define FZ_ENABLE_JS 1
+#endif /* FZ_ENABLE_JS */
/* If Epub and HTML are both disabled, disable SIL fonts */
#if FZ_ENABLE_HTML == 0 && FZ_ENABLE_EPUB == 0
diff --git a/platform/win32/generate.bat b/platform/win32/generate.bat
index 52a00ca5..819a2b2f 100644
--- a/platform/win32/generate.bat
+++ b/platform/win32/generate.bat
@@ -27,7 +27,7 @@ if not exist generated/gen_cmap_japan.h cmapdump.exe generated/gen_cmap_japan.h
if not exist generated/gen_cmap_korea.h cmapdump.exe generated/gen_cmap_korea.h resources\cmaps\korea\*
if not exist generated/gen_adobe_ca.h bin2hex.exe generated/gen_adobe_ca.h resources/certs/AdobeCA.p7c
-if not exist generated/gen_js_util.h cquote.exe generated/gen_js_util.h source/pdf/js/pdf-util.js
+if not exist generated/gen_js_util.h cquote.exe generated/gen_js_util.h source/pdf/pdf-js-util.js
if not exist generated/DroidSansFallback.c fontdump.exe generated/DroidSansFallback.c resources/fonts/droid/DroidSansFallback.ttc
if not exist generated/DroidSansFallbackFull.c fontdump.exe generated/DroidSansFallbackFull.c resources/fonts/droid/DroidSansFallbackFull.ttc
diff --git a/platform/win32/libmupdf.vcproj b/platform/win32/libmupdf.vcproj
index 724ba412..14656640 100644
--- a/platform/win32/libmupdf.vcproj
+++ b/platform/win32/libmupdf.vcproj
@@ -1239,6 +1239,14 @@
>
</File>
<File
+ RelativePath="..\..\source\pdf\pdf-js.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\pdf\pdf-js-util.js"
+ >
+ </File>
+ <File
RelativePath="..\..\source\pdf\pdf-lex.c"
>
</File>
@@ -1334,18 +1342,6 @@
RelativePath="..\..\source\pdf\pdf-xref.c"
>
</File>
- <Filter
- Name="js"
- >
- <File
- RelativePath="..\..\source\pdf\js\pdf-js.c"
- >
- </File>
- <File
- RelativePath="..\..\source\pdf\js\pdf-util.js"
- >
- </File>
- </Filter>
</Filter>
<Filter
Name="!include"
diff --git a/source/pdf/js/pdf-js-none.c b/source/pdf/js/pdf-js-none.c
deleted file mode 100644
index 7cce12be..00000000
--- a/source/pdf/js/pdf-js-none.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "mupdf/pdf.h"
-
-void pdf_enable_js(fz_context *ctx, pdf_document *doc)
-{
-}
-
-void pdf_disable_js(fz_context *ctx, pdf_document *doc)
-{
-}
-
-int pdf_js_supported(fz_context *ctx, pdf_document *doc)
-{
- return 0;
-}
-
-void pdf_js_setup_event(pdf_js *js, pdf_js_event *e)
-{
-}
-
-pdf_js_event *pdf_js_get_event(pdf_js *js)
-{
- return NULL;
-}
-
-void pdf_js_execute(pdf_js *js, char *code)
-{
-}
-
-void pdf_js_execute_count(pdf_js *js, char *code, int count)
-{
-}
diff --git a/source/pdf/js/pdf-util.js b/source/pdf/pdf-js-util.js
index 299f80ac..299f80ac 100644
--- a/source/pdf/js/pdf-util.js
+++ b/source/pdf/pdf-js-util.js
diff --git a/source/pdf/js/pdf-js.c b/source/pdf/pdf-js.c
index 57a0191b..259a9b7a 100644
--- a/source/pdf/js/pdf-js.c
+++ b/source/pdf/pdf-js.c
@@ -1,4 +1,7 @@
#include "mupdf/pdf.h"
+
+#if FZ_ENABLE_JS
+
#include "mujs.h"
struct pdf_js_s
@@ -716,3 +719,16 @@ int pdf_js_supported(fz_context *ctx, pdf_document *doc)
{
return doc->js != NULL;
}
+
+#else /* FZ_ENABLE_JS */
+
+void pdf_drop_js(fz_context *ctx, pdf_js *js) { }
+void pdf_enable_js(fz_context *ctx, pdf_document *doc) { }
+void pdf_disable_js(fz_context *ctx, pdf_document *doc) { }
+int pdf_js_supported(fz_context *ctx, pdf_document *doc) { return 0; }
+void pdf_js_setup_event(pdf_js *js, pdf_js_event *e) { }
+pdf_js_event *pdf_js_get_event(pdf_js *js) { return NULL; }
+void pdf_js_execute(pdf_js *js, char *code) { }
+void pdf_js_execute_count(pdf_js *js, char *code, int count) { }
+
+#endif /* FZ_ENABLE_JS */
diff --git a/source/tools/mutool.c b/source/tools/mutool.c
index 95c49fa1..20f4f957 100644
--- a/source/tools/mutool.c
+++ b/source/tools/mutool.c
@@ -28,7 +28,9 @@ static struct {
} tools[] = {
{ muconvert_main, "convert", "convert document" },
{ mudraw_main, "draw", "convert document" },
+#if FZ_ENABLE_JS
{ murun_main, "run", "run javascript" },
+#endif
#if FZ_ENABLE_PDF
{ pdfclean_main, "clean", "rewrite pdf file" },
{ pdfextract_main, "extract", "extract font and image resources" },