summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdvipdfmx/src/dvipdfmx.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/xdvipdfmx/src/dvipdfmx.c')
-rw-r--r--Build/source/texk/xdvipdfmx/src/dvipdfmx.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/Build/source/texk/xdvipdfmx/src/dvipdfmx.c b/Build/source/texk/xdvipdfmx/src/dvipdfmx.c
index 5e7e8c8abaf..6e0431b7791 100644
--- a/Build/source/texk/xdvipdfmx/src/dvipdfmx.c
+++ b/Build/source/texk/xdvipdfmx/src/dvipdfmx.c
@@ -140,7 +140,7 @@ usage (int exit_code)
fprintf (stdout, "\nThis is %s-%s by Jonathan Kew and Jin-Hwan Cho,\n", PACKAGE, VERSION);
fprintf (stdout, "an extended version of DVIPDFMx, which in turn was\n");
fprintf (stdout, "an extended version of dvipdfm-0.13.2c developed by Mark A. Wicks.\n");
- fprintf (stdout, "\nCopyright (c) 2006-2008 SIL International and Jin-Hwan Cho.\n");
+ fprintf (stdout, "\nCopyright (c) 2006-2011 SIL International and Jin-Hwan Cho.\n");
fprintf (stdout, "\nThis is free software; you can redistribute it and/or modify\n");
fprintf (stdout, "it under the terms of the GNU General Public License as published by\n");
fprintf (stdout, "the Free Software Foundation; either version 2 of the License, or\n");
@@ -175,7 +175,7 @@ usage (int exit_code)
fprintf (stdout, "\t\tAnd negative values replace old values.\n");
fprintf (stdout, "-D template\tPS->PDF conversion command line template [none]\n");
fprintf (stdout, "-E \t\tAlways try to embed fonts, regardless of licensing flags.\n");
- fprintf (stdout, "-K number\tEncryption key bits [40]\n");
+ fprintf (stdout, "-K number\tEncryption key length [40]\n");
fprintf (stdout, "-O number\tSet maximum depth of open bookmark items [0]\n");
fprintf (stdout, "-P number\tSet permission flags for PDF encryption [0x003C]\n");
fprintf (stdout, "-S \t\tEnable PDF encryption\n");
@@ -511,10 +511,10 @@ do_args (int argc, char *argv[])
do_encryption = 1;
break;
case 'K':
- CHECK_ARG(1, "encryption key bits");
+ CHECK_ARG(1, "encryption key length");
key_bits = (unsigned) atoi(argv[1]);
- if (key_bits < 40 || key_bits > 128)
- ERROR("Invalid encryption key bits specified: %s", argv[1]);
+ if (key_bits < 40 || key_bits > 128 || (key_bits & 0x7))
+ ERROR("Invalid encryption key length specified: %s", argv[1]);
POP_ARG();
break;
case 'P':
@@ -708,7 +708,7 @@ do_dvi_pages (void)
page_width = paper_width; page_height = paper_height;
w = page_width; h = page_height; lm = landscape_mode;
xo = x_offset; yo = y_offset;
- dvi_scan_specials(page_no, &w, &h, &xo, &yo, &lm, NULL);
+ dvi_scan_specials(page_no, &w, &h, &xo, &yo, &lm, NULL, NULL, NULL, NULL, NULL, NULL);
if (lm != landscape_mode) {
SWAP(w, h);
landscape_mode = lm;
@@ -859,7 +859,7 @@ main (int argc, char *argv[])
set_default_pdf_filename();
if (do_encryption) {
- pdf_enc_set_passwd(key_bits, permission, dvi_filename, pdf_filename);
+ pdf_enc_set_passwd(key_bits, permission, NULL, NULL);
if (key_bits > 40 && pdf_get_version() < 4)
pdf_set_version(4);
}
@@ -870,6 +870,7 @@ main (int argc, char *argv[])
dvi2pts = 0.01; /* dvi2pts controls accuracy. */
} else {
unsigned ver_minor = 0;
+ char owner_pw[MAX_PWD_LEN], user_pw[MAX_PWD_LEN];
/* Dependency between DVI and PDF side is rather complicated... */
dvi2pts = dvi_init(dvi_filename, mag);
if (dvi2pts == 0.0)
@@ -877,7 +878,23 @@ main (int argc, char *argv[])
pdf_doc_set_creator(dvi_comment());
- dvi_scan_specials(0, &paper_width, &paper_height, &x_offset, &y_offset, &landscape_mode, &ver_minor);
+ if (do_encryption)
+ /* command line takes precedence */
+ dvi_scan_specials(0, &paper_width, &paper_height, &x_offset, &y_offset, &landscape_mode,
+ &ver_minor, NULL, NULL, NULL, NULL, NULL);
+ else {
+ dvi_scan_specials(0, &paper_width, &paper_height, &x_offset, &y_offset, &landscape_mode,
+ &ver_minor, &do_encryption, &key_bits, &permission, owner_pw, user_pw);
+ if (do_encryption) {
+ if (key_bits < 40 || key_bits > 128 || (key_bits & 0x7))
+ ERROR("Invalid encryption key length specified: %u", key_bits);
+ else if (key_bits > 40 && pdf_get_version() < 4)
+ ERROR("Chosen key length requires at least PDF 1.4. "
+ "Use \"-V 4\" to change.");
+ do_encryption = 1;
+ pdf_enc_set_passwd(key_bits, permission, owner_pw, user_pw);
+ }
+ }
if (ver_minor >= PDF_VERSION_MIN && ver_minor <= PDF_VERSION_MAX) {
pdf_set_version(ver_minor);
}