summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
diff options
context:
space:
mode:
authorLuigi Scarso <luigi.scarso@gmail.com>2020-02-15 12:45:08 +0000
committerLuigi Scarso <luigi.scarso@gmail.com>2020-02-15 12:45:08 +0000
commit1eb99bf05849e3108129d32eaacaa40c9e266c4b (patch)
tree23d14dd9414feedf2c78eb5029a5c7ed60c2bca2 /Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
parentc919a62f6a535e0c586534c9ac6d8f671d91c02c (diff)
sync with luatex rev. 7287
git-svn-id: svn://tug.org/texlive/trunk@53789 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/image/pdftoepdf.c')
-rw-r--r--Build/source/texk/web2c/luatexdir/image/pdftoepdf.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
index 547d0f67cac..a43f1dac4cc 100644
--- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
+++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
@@ -187,6 +187,9 @@ PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe, const cha
}
}
if (pdfe != NULL) {
+ if (ppdoc_crypt_status(pdfe) < 0 && userpassword==NULL) {
+ formatted_error("pdf inclusion","the pdf file '%s' is encrypted, passwords wrong",file_path);
+ }
if (ppdoc_crypt_status(pdfe) < 0) {
ppdoc_crypt_pass(pdfe,userpassword,strlen(userpassword),NULL,0);
}
@@ -250,7 +253,7 @@ PdfDocument *refMemStreamPdfDocument(char *docstream, unsigned long long streams
free(checksum);
}
if (pdf_doc->pdfe == NULL) {
- pdfe = ppdoc_mem(docstream, streamsize);
+ pdfe = ppdoc_mem(docstream, (size_t) streamsize);
pdf_doc->pc++;
if (pdfe == NULL) {
normal_error("pdf inclusion","reading pdf Stream failed");
@@ -367,24 +370,24 @@ static int addInObj(PDF pdf, PdfDocument * pdf_doc, ppref * ref)
static void copyObject(PDF, PdfDocument *, ppobj *);
-static void copyString(PDF pdf, ppstring str)
+static void copyString(PDF pdf, ppstring *str)
{
pdf_check_space(pdf);
- switch (ppstring_type((void *)(str))) {
+ switch (ppstring_type(str)) {
case PPSTRING_PLAIN:
pdf_out(pdf, '(');
- pdf_out_block(pdf, (const char *) str, ppstring_size((void *)(str)));
+ pdf_out_block(pdf, ppstring_data(str), ppstring_size(str));
pdf_out(pdf, ')');
break;
case PPSTRING_BASE16:
pdf_out(pdf, '<');
- pdf_out_block(pdf, (const char *) str, ppstring_size((void *)(str)));
+ pdf_out_block(pdf, ppstring_data(str), ppstring_size(str));
pdf_out(pdf, '>');
break;
case PPSTRING_BASE85:
pdf_out(pdf, '<');
pdf_out(pdf, '~');
- pdf_out_block(pdf, (const char *) str, ppstring_size((void *)(str)));
+ pdf_out_block(pdf, ppstring_data(str), ppstring_size(str));
pdf_out(pdf, '~');
pdf_out(pdf, '>');
break;
@@ -392,12 +395,10 @@ static void copyString(PDF pdf, ppstring str)
pdf_set_space(pdf);
}
-/*
static void copyName(PDF pdf, ppname *name)
{
- pdf_add_name(pdf, (const char *) name);
+ pdf_add_name(pdf, ppname_data(name));
}
-*/
static void copyArray(PDF pdf, PdfDocument * pdf_doc, pparray * array)
{
@@ -416,7 +417,8 @@ static void copyDict(PDF pdf, PdfDocument * pdf_doc, ppdict *dict)
int n = dict->size;
pdf_begin_dict(pdf);
for (i=0; i<n; ++i) {
- pdf_add_name(pdf, (const char *) ppdict_key(dict,i));
+ ppname *key = ppdict_key(dict,i);
+ pdf_add_name(pdf,ppname_data(key));
copyObject(pdf, pdf_doc, ppdict_at(dict,i));
}
pdf_end_dict(pdf);
@@ -462,9 +464,8 @@ static void copyStream(PDF pdf, PdfDocument * pdf_doc, ppstream * stream)
"FlateDecode", "LZWDecode", NULL
};
int k;
- const char *val = ppobj_get_name(obj);
for (k = 0; codecs[k] != NULL; k++) {
- if (strcmp(val,codecs[k]) == 0) {
+ if (strcmp(ppname_data(obj->name),codecs[k]) == 0) {
known = 1;
break;
}
@@ -478,17 +479,17 @@ static void copyStream(PDF pdf, PdfDocument * pdf_doc, ppstream * stream)
int i;
pdf_begin_dict(pdf);
for (i=0; i<dict->size; ++i) {
- const char *key = ppdict_key(dict,i);
+ ppname *key = ppdict_key(dict,i);
int copy = 1;
int k;
for (k = 0; ignoredkeys[k] != NULL; k++) {
- if (strcmp(key,ignoredkeys[k]) == 0) {
+ if (strcmp(ppname_data(key),ignoredkeys[k]) == 0) {
copy = 0;
break;
}
}
if (copy) {
- pdf_add_name(pdf, key);
+ pdf_add_name(pdf, ppname_data(key));
copyObject(pdf, pdf_doc, ppdict_at(dict,i));
}
}
@@ -523,7 +524,7 @@ static void copyObject(PDF pdf, PdfDocument * pdf_doc, ppobj * obj)
pdf_add_real(pdf,obj->number); /* ppobj_get_num_value(obj) */
break;
case PPNAME:
- pdf_add_name(pdf, (const char *) obj->name); /* ppobj_get_name(obj) */
+ copyName(pdf, obj->name);
break;
case PPSTRING:
copyString(pdf, obj->string); /* ppobj_get_string(obj) */
@@ -690,6 +691,9 @@ void read_pdf_info(image_dict * idict)
get the required page
*/
pageDict = get_pdf_page_dict(pdfe,img_pagenum(idict));
+ if (pageDict==NULL) {
+ formatted_error("pdf inclusion","unable to retrive dictionary for page '%i'",(int) img_pagenum(idict));
+ }
/*
get the pagebox coordinates (media, crop,...) to use
*/
@@ -802,6 +806,9 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
}
pdfe = pdf_doc->pdfe;
pageDict = get_pdf_page_dict(pdfe,img_pagenum(idict));
+ if (pageDict==NULL) {
+ formatted_error("pdf inclusion","unable to retrive dictionary for page '%i'",(int) img_pagenum(idict));
+ }
/*
write the Page header
*/