summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-12-29 04:43:56 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-12-29 04:43:56 +0000
commiteab42d1eec7c5a1a356ca867b1f629d7fe97c543 (patch)
tree01b73d6c63afd24336082fc3d1f2189419575863 /Build/source
parent30274123203d7d0e1813438dca96e6a0b6447613 (diff)
texk/dvipdfm-x: patches by S. Hirata.
git-svn-id: svn://tug.org/texlive/trunk@39229 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog6
-rw-r--r--Build/source/texk/dvipdfm-x/dvi.c6
-rw-r--r--Build/source/texk/dvipdfm-x/dvipdfmx.c22
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdoc.c6
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdoc.h12
-rw-r--r--Build/source/texk/dvipdfm-x/pdfobj.c27
-rw-r--r--Build/source/texk/dvipdfm-x/pdfobj.h3
7 files changed, 53 insertions, 29 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index dfaf2a28938..78ceb3384b8 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-29 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
+
+ * dvipdfmx.c, dvi.c: Allow empty password in pdf:encrypt special.
+ * dvipdfmx.c, pdfdoc.[ch], pdfobj.[ch]: Add option to disable Xref
+ stream and object stream.
+
2015-12-28 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
* bmpimage.c, dvipdfmx.c, pdfobj.[ch], pngimage.c: Support for predictor
diff --git a/Build/source/texk/dvipdfm-x/dvi.c b/Build/source/texk/dvipdfm-x/dvi.c
index fedbc1dc837..d5db33825bf 100644
--- a/Build/source/texk/dvipdfm-x/dvi.c
+++ b/Build/source/texk/dvipdfm-x/dvi.c
@@ -2350,13 +2350,15 @@ scan_special (double *wd, double *ht, double *xo, double *yo, int *lm,
skip_white(&p, endptr);
if (!strcmp(kp, "ownerpw")) {
if ((obj = parse_pdf_string(&p, endptr))) {
- strncpy(owner_pw, pdf_string_value(obj), MAX_PWD_LEN);
+ if (pdf_string_value(obj))
+ strncpy(owner_pw, pdf_string_value(obj), MAX_PWD_LEN);
pdf_release_obj(obj);
} else
error = -1;
} else if (!strcmp(kp, "userpw")) {
if ((obj = parse_pdf_string(&p, endptr))) {
- strncpy(user_pw, pdf_string_value(obj), MAX_PWD_LEN);
+ if (pdf_string_value(obj))
+ strncpy(user_pw, pdf_string_value(obj), MAX_PWD_LEN);
pdf_release_obj(obj);
} else
error = -1;
diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.c b/Build/source/texk/dvipdfm-x/dvipdfmx.c
index 70cf84d4e5c..f4953d683d4 100644
--- a/Build/source/texk/dvipdfm-x/dvipdfmx.c
+++ b/Build/source/texk/dvipdfm-x/dvipdfmx.c
@@ -80,6 +80,7 @@ static int opt_flags = 0;
#define OPT_FONTMAP_FIRST_MATCH (1 << 3)
#define OPT_PDFDOC_NO_DEST_REMOVE (1 << 4)
#define OPT_PDFOBJ_NO_PREDICTOR (1 << 5)
+#define OPT_PDFOBJ_NO_OBJSTM (1 << 6)
static char ignore_colors = 0;
static double annot_grow = 0.0;
@@ -100,10 +101,13 @@ static int pdfdecimaldigits = 2;
static int image_cache_life = -2;
/* Encryption */
-static int do_encryption = 0;
+static int do_encryption = 0;
static int key_bits = 40;
static int32_t permission = 0x003C;
+/* Object stream */
+static int enable_objstm = 1;
+
/* Page device */
double paper_width = 595.0;
double paper_height = 842.0;
@@ -201,6 +205,7 @@ show_usage (void)
printf ("\t\t 0x0008 Do not replace duplicate fontmap entries.\n");
printf ("\t\t 0x0010 Do not optimize PDF destinations.\n");
printf ("\t\t 0x0020 Do not use predictor filter for Flate compression.\n");
+ printf ("\t\t 0x0040 Do not use object stream.\n");
printf ("\t\tPositive values are always ORed with previously given flags.\n");
printf ("\t\tAnd negative values replace old values.\n");
printf (" -D template\tPS->PDF conversion command line template [none]\n");
@@ -1015,12 +1020,12 @@ main (int argc, char *argv[])
if (do_encryption) {
if (!(key_bits >= 40 && key_bits <= 128 && (key_bits % 8 == 0)) &&
key_bits != 256)
- ERROR("Invalid encryption key length specified: %u", key_bits);
- else if (key_bits > 40 && pdf_get_version() < 4)
+ 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);
+ "Use \"-V 4\" to change.");
+ do_encryption = 1;
+ pdf_enc_set_passwd(key_bits, permission, owner_pw, user_pw);
}
}
if (landscape_mode) {
@@ -1030,11 +1035,14 @@ main (int argc, char *argv[])
pdf_files_init();
+ if (opt_flags & OPT_PDFOBJ_NO_OBJSTM)
+ enable_objstm = 0;
+
/* Set default paper size here so that all page's can inherite it.
* annot_grow: Margin of annotation.
* bookmark_open: Miximal depth of open bookmarks.
*/
- pdf_open_document(pdf_filename, do_encryption,
+ pdf_open_document(pdf_filename, do_encryption, enable_objstm,
paper_width, paper_height, annot_grow, bookmark_open,
!(opt_flags & OPT_PDFDOC_NO_DEST_REMOVE));
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.c b/Build/source/texk/dvipdfm-x/pdfdoc.c
index af60d898f98..ecda8351ff3 100644
--- a/Build/source/texk/dvipdfm-x/pdfdoc.c
+++ b/Build/source/texk/dvipdfm-x/pdfdoc.c
@@ -2470,14 +2470,14 @@ static char *doccreator = NULL; /* Ugh */
void
pdf_open_document (const char *filename,
- int do_encryption,
+ int enable_encrypt, int enable_objstm,
double media_width, double media_height,
double annot_grow_amount, int bookmark_open_depth,
int check_gotos)
{
pdf_doc *p = &pdoc;
- pdf_out_init(filename, do_encryption);
+ pdf_out_init(filename, enable_encrypt, enable_objstm);
pdf_doc_init_catalog(p);
@@ -2505,7 +2505,7 @@ pdf_open_document (const char *filename,
pdf_doc_set_bgcolor(NULL);
- if (do_encryption) {
+ if (enable_encrypt) {
pdf_obj *encrypt = pdf_encrypt_obj();
pdf_set_encrypt(encrypt);
pdf_release_obj(encrypt);
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.h b/Build/source/texk/dvipdfm-x/pdfdoc.h
index 1b68fd29338..61a806e9c8d 100644
--- a/Build/source/texk/dvipdfm-x/pdfdoc.h
+++ b/Build/source/texk/dvipdfm-x/pdfdoc.h
@@ -31,15 +31,17 @@
extern void pdf_doc_set_verbose (void);
extern void pdf_open_document (const char *filename,
- int do_encryption,
- double media_width, double media_height,
- double annot_grow_amount, int bookmark_open_depth,
- int check_gotos);
+ int enable_encrypt,
+ int enable_objstm,
+ double media_width, double media_height,
+ double annot_grow_amount,
+ int bookmark_open_depth,
+ int check_gotos);
extern void pdf_close_document (void);
/* PDF document metadata */
-extern void pdf_doc_set_creator (const char *creator);
+extern void pdf_doc_set_creator (const char *creator);
/* They just return PDF dictionary object.
diff --git a/Build/source/texk/dvipdfm-x/pdfobj.c b/Build/source/texk/dvipdfm-x/pdfobj.c
index d11ab132660..c1b18278f34 100644
--- a/Build/source/texk/dvipdfm-x/pdfobj.c
+++ b/Build/source/texk/dvipdfm-x/pdfobj.c
@@ -125,11 +125,11 @@ struct pdf_dict
struct pdf_stream
{
- struct pdf_obj *dict;
- unsigned char *stream;
- int *objstm_data; /* used for object streams */
- unsigned int stream_length;
- unsigned int max_length;
+ struct pdf_obj *dict;
+ unsigned char *stream;
+ int *objstm_data; /* used for object streams */
+ unsigned int stream_length;
+ unsigned int max_length;
int32_t _flags;
struct decode_parms decodeparms;
};
@@ -320,7 +320,7 @@ add_xref_entry (unsigned label, unsigned char type, unsigned int field2, unsigne
#define BINARY_MARKER "%\344\360\355\370\n"
void
-pdf_out_init (const char *filename, int do_encryption)
+pdf_out_init (const char *filename, int do_encryption, int enable_objstm)
{
char v;
@@ -330,11 +330,16 @@ pdf_out_init (const char *filename, int do_encryption)
next_label = 1;
if (pdf_version >= 5) {
- xref_stream = pdf_new_stream(STREAM_COMPRESS);
- xref_stream->flags |= OBJ_NO_ENCRYPT;
- trailer_dict = pdf_stream_dict(xref_stream);
- pdf_add_dict(trailer_dict, pdf_new_name("Type"), pdf_new_name("XRef"));
- do_objstm = 1;
+ if (enable_objstm) {
+ xref_stream = pdf_new_stream(STREAM_COMPRESS);
+ xref_stream->flags |= OBJ_NO_ENCRYPT;
+ trailer_dict = pdf_stream_dict(xref_stream);
+ pdf_add_dict(trailer_dict, pdf_new_name("Type"), pdf_new_name("XRef"));
+ do_objstm = 1;
+ } else {
+ trailer_dict = pdf_new_dict();
+ do_objstm = 0;
+ }
} else {
xref_stream = NULL;
trailer_dict = pdf_new_dict();
diff --git a/Build/source/texk/dvipdfm-x/pdfobj.h b/Build/source/texk/dvipdfm-x/pdfobj.h
index 8c47f27ba69..c18ab25ff26 100644
--- a/Build/source/texk/dvipdfm-x/pdfobj.h
+++ b/Build/source/texk/dvipdfm-x/pdfobj.h
@@ -56,7 +56,8 @@ extern int pdf_obj_get_verbose (void);
extern void pdf_obj_set_verbose (void);
extern void pdf_error_cleanup (void);
-extern void pdf_out_init (const char *filename, int do_encryption);
+extern void pdf_out_init (const char *filename,
+ int enable_encrypt, int enable_objstm);
extern void pdf_out_flush (void);
extern void pdf_set_version (unsigned version);
extern unsigned pdf_get_version (void);