-
Notifications
You must be signed in to change notification settings - Fork 0
/
dvipdfmx.patch
621 lines (591 loc) · 19.8 KB
/
dvipdfmx.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
diff --git a/texk/dvipdfm-x/epdf.c b/texk/dvipdfm-x/epdf.c
index 95094823..f0651934 100644
--- a/texk/dvipdfm-x/epdf.c
+++ b/texk/dvipdfm-x/epdf.c
@@ -129,8 +129,9 @@ pdf_include_page (pdf_ximage *ximage,
if (options.page_no == 0)
options.page_no = 1;
page = pdf_doc_get_page(pf,
- options.page_no, options.bbox_type,
- &info.bbox, &info.matrix, &resources);
+ options.page_no, options.page_name,
+ options.bbox_type, &info.bbox, &info.matrix,
+ &resources);
if(!page)
goto error_silent;
@@ -304,7 +305,7 @@ pdf_copy_clip (FILE *image_file, int pageNo, double x_user, double y_user)
pdf_invertmatrix(&M);
M.e += x_user; M.f += y_user;
- page_tree = pdf_doc_get_page(pf, pageNo, 0, &bbox, &mtrx, NULL);
+ page_tree = pdf_doc_get_page(pf, pageNo, NULL, 0, &bbox, &mtrx, NULL);
if (!page_tree) {
pdf_close(pf);
return -1;
diff --git a/texk/dvipdfm-x/pdfdoc.c b/texk/dvipdfm-x/pdfdoc.c
index 75ed8179..870eee8c 100644
--- a/texk/dvipdfm-x/pdfdoc.c
+++ b/texk/dvipdfm-x/pdfdoc.c
@@ -1024,6 +1024,19 @@ set_transform_matrix (pdf_tmatrix *matrix, pdf_rect *bbox, pdf_obj *rotate)
return 0;
}
+/* Stores references to the needed boxes and resources for a page */
+typedef struct pdf_boxes {
+ pdf_obj *page_tree;
+ pdf_obj *resources;
+ pdf_obj *rotate;
+ pdf_obj *art_box;
+ pdf_obj *trim_box;
+ pdf_obj *bleed_box;
+ pdf_obj *media_box;
+ pdf_obj *crop_box;
+} pdf_boxes;
+
+
/*
* From PDFReference15_v6.pdf (p.119 and p.834)
*
@@ -1046,7 +1059,7 @@ set_transform_matrix (pdf_tmatrix *matrix, pdf_rect *bbox, pdf_obj *rotate)
* in the absence of additional information (such as imposition instructions
* specified in a JDF or PJTF job ticket), the crop box will determine how
* the page's contents are to be positioned on the output medium. The default
- * value is the page's media box.
+ * value is the page's media box.
*
* BleedBox rectangle (Optional; PDF 1.3)
*
@@ -1055,14 +1068,14 @@ set_transform_matrix (pdf_tmatrix *matrix, pdf_rect *bbox, pdf_obj *rotate)
* include any extra "bleed area" needed to accommodate the physical
* limitations of cutting, folding, and trimming equipment. The actual printed
* page may include printing marks that fall outside the bleed box.
- * The default value is the page's crop box.
+ * The default value is the page's crop box.
*
* TrimBox rectangle (Optional; PDF 1.3)
*
* The trim box (PDF 1.3) defines the intended dimensions of the finished page
* after trimming. It may be smaller than the media box, to allow for
* production-related content such as printing instructions, cut marks, or
- * color bars. The default value is the page's crop box.
+ * color bars. The default value is the page's crop box.
*
* ArtBox rectangle (Optional; PDF 1.3)
*
@@ -1075,28 +1088,230 @@ set_transform_matrix (pdf_tmatrix *matrix, pdf_rect *bbox, pdf_obj *rotate)
* The number of degrees by which the page should be rotated clockwise when
* displayed or printed. The value must be a multiple of 90. Default value: 0.
*/
+static void
+get_page_properties (pdf_boxes *boxes) {
+ pdf_obj *tmp;
-/* count_p removed: Please use different interface if you want to get total page
- * number. pdf_doc_get_page() is obviously not an interface to do such.
- */
-pdf_obj *
-pdf_doc_get_page (pdf_file *pf,
- int page_no, enum pdf_page_boundary opt_bbox, /* load options */
- pdf_rect *bbox, pdf_tmatrix *matrix, /* returned value */
- pdf_obj **resources_p /* returned values */
- ) {
- pdf_obj *catalog = NULL, *page_tree = NULL;
- pdf_obj *resources = NULL, *rotate = NULL;
- pdf_obj *art_box = NULL, *trim_box = NULL, *bleed_box = NULL;
- pdf_obj *media_box = NULL, *crop_box = NULL;
- int error = 0;
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(boxes->page_tree, "MediaBox")))) {
+ if (boxes->media_box)
+ pdf_release_obj(boxes->media_box);
+ boxes->media_box = tmp;
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(boxes->page_tree, "CropBox")))) {
+ if (boxes->crop_box)
+ pdf_release_obj(boxes->crop_box);
+ boxes->crop_box = tmp;
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(boxes->page_tree, "ArtBox")))) {
+ if (boxes->art_box)
+ pdf_release_obj(boxes->art_box);
+ boxes->art_box = tmp;
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(boxes->page_tree, "TrimBox")))) {
+ if (boxes->trim_box)
+ pdf_release_obj(boxes->trim_box);
+ boxes->trim_box = tmp;
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(boxes->page_tree, "BleedBox")))) {
+ if (boxes->bleed_box)
+ pdf_release_obj(boxes->bleed_box);
+ boxes->bleed_box = tmp;
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(boxes->page_tree, "Rotate")))) {
+ if (boxes->rotate)
+ pdf_release_obj(boxes->rotate);
+ boxes->rotate = tmp;
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(boxes->page_tree, "Resources")))) {
+ if (boxes->resources)
+ pdf_release_obj(boxes->resources);
+ boxes->resources = tmp;
+ }
+}
- catalog = pdf_file_get_catalog(pf);
- page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages"));
+/*
+ * Gets the page dictionary that a PDF "named destination" points to.
+ */
+static void
+page_by_name (pdf_obj * catalog, char * page_name, pdf_boxes * boxes) {
+ pdf_obj *page = NULL;
+
+ /* Get the top-level /Names dict */
+ pdf_obj *names = pdf_deref_obj(pdf_lookup_dict(catalog, "Names"));
+ if (!PDF_OBJ_DICTTYPE(names)) {
+ if (names)
+ pdf_release_obj(names);
+ goto error_exit;
+ }
- if (!PDF_OBJ_DICTTYPE(page_tree))
+ /* The /Names dict should have a /Dests child */
+ pdf_obj *dests = pdf_deref_obj(pdf_lookup_dict(names, "Dests"));
+ pdf_release_obj(names);
+ if (!PDF_OBJ_DICTTYPE(dests)) {
+ if (dests)
+ pdf_release_obj(dests);
goto error_exit;
+ }
+
+ /* Loop over all the destinations until we find a matching one */
+ pdf_obj *up_dests;
+ int pos[] = {0, 0, 0, 0, 0};
+ int level = 0;
+
+ for (int i = 0; i < 1000; i++) {
+ if (level < 0 || level >= sizeof(pos) / sizeof(pos[0]))
+ goto error_exit;
+
+ int recurse;
+
+ if (i == 0) {
+ /* No /Limits for the root */
+ recurse = true;
+ } else {
+ if (!dests)
+ goto error_exit;
+
+ pdf_obj *limits = pdf_deref_obj(pdf_lookup_dict(dests, "Limits"));
+ if (!PDF_OBJ_ARRAYTYPE(limits)) {
+ if (limits)
+ pdf_release_obj(limits);
+ goto error_exit;
+ }
+
+ /* Get the current limits */
+ pdf_obj *start_obj = pdf_deref_obj(pdf_get_array(limits, 0));
+ pdf_obj *end_obj = pdf_deref_obj(pdf_get_array(limits, 1));
+ pdf_release_obj(limits);
+ if (!PDF_OBJ_STRINGTYPE(start_obj) || !PDF_OBJ_STRINGTYPE(end_obj)) {
+ if (start_obj)
+ pdf_release_obj(start_obj);
+ if (end_obj)
+ pdf_release_obj(end_obj);
+ goto error_exit;
+ }
+ char *start = pdf_string_value(start_obj);
+ char *end = pdf_string_value(end_obj);
+ pdf_release_obj(start_obj);
+ pdf_release_obj(end_obj);
+
+ recurse = strcmp(page_name, start) >= 0 && strcmp(page_name, end) <= 0;
+ }
+
+ /* If the name is between the current limits, search the list */
+ if (recurse) {
+ names = pdf_deref_obj(pdf_lookup_dict(dests, "Names"));
+ if (!PDF_OBJ_ARRAYTYPE(names)) {
+ if (names)
+ pdf_release_obj(names);
+ } else {
+ goto found;
+ }
+
+ pdf_obj *kids = pdf_deref_obj(pdf_lookup_dict(dests, "Kids"));
+ if (!PDF_OBJ_ARRAYTYPE(kids)) {
+ if (kids)
+ pdf_release_obj(kids);
+ goto error_exit;
+ }
+
+ int kids_length = pdf_array_length(kids);
+ for (; pos[level] < kids_length; pos[level]++) {
+ up_dests = dests;
+ dests = pdf_deref_obj(pdf_get_array(kids, pos[level]));
+ level++;
+ goto continue_outer;
+ }
+ } else {
+ if (--level >= 0)
+ pos[level]++;
+ pdf_release_obj(dests);
+ dests = up_dests;
+ }
+ continue_outer: ;
+ }
+ goto error_exit;
+
+ /* Loop over the bottom-level Names array */
+found:
+ int names_length = pdf_array_length(names);
+ for (int i = 0; i < names_length; i++) {
+ pdf_obj *name_obj = pdf_deref_obj(pdf_get_array(names, i));
+ if (!PDF_OBJ_STRINGTYPE(name_obj)) {
+ if (name_obj)
+ pdf_release_obj(name_obj);
+ continue;
+ }
+
+ char *name = pdf_string_value(name_obj);
+ pdf_release_obj(name_obj);
+
+ if (strcmp(page_name, name) != 0)
+ continue;
+
+ pdf_obj *dest = pdf_deref_obj(pdf_get_array(names, ++i));
+ pdf_obj *dest_inner;
+ if (PDF_OBJ_DICTTYPE(dest)) {
+ dest_inner = pdf_deref_obj(pdf_lookup_dict(dest, "D"));
+ pdf_release_obj(dest);
+ if (!PDF_OBJ_ARRAYTYPE(dest_inner)) {
+ if (dest_inner)
+ pdf_release_obj(dest_inner);
+ goto error_exit;
+ }
+ } else if (PDF_OBJ_ARRAYTYPE(dest)) {
+ dest_inner = dest;
+ } else {
+ if (dest)
+ pdf_release_obj(dest);
+ continue;
+ }
+
+ page = pdf_deref_obj(pdf_get_array(dest_inner, 0));
+ pdf_release_obj(dest_inner);
+ if (!PDF_OBJ_DICTTYPE(page)) {
+ if (page)
+ pdf_release_obj(page);
+ goto error_exit;
+ }
+
+ break;
+ }
+
+ /* Traverse back upwards to get any inherited boxes */
+ boxes->page_tree = page;
+
+ while (true) {
+ get_page_properties(boxes);
+
+ if (boxes->media_box)
+ break;
+
+ boxes->page_tree = pdf_deref_obj(pdf_lookup_dict(boxes->page_tree, "Parent"));
+ if (!PDF_OBJ_DICTTYPE(boxes->page_tree)) {
+ if (boxes->page_tree)
+ pdf_release_obj(boxes->page_tree);
+ goto error_exit;
+ }
+ };
+
+ /* Set the page back to the current page (not the parent) */
+ boxes->page_tree = page;
+ return;
+
+error_exit:
+ WARN("Bad named destination: %s", page_name);
+ return;
+}
+
+
+/*
+ * Gets the page dictionary by the page's number.
+ */
+static void
+page_by_number (pdf_obj *page_tree, int page_no, pdf_boxes *boxes) {
+ pdf_obj *catalog = NULL;
+ int error = 0;
{
int count;
@@ -1110,7 +1325,7 @@ pdf_doc_get_page (pdf_file *pf,
pdf_release_obj(tmp);
if (page_no <= 0 || page_no > count) {
WARN("Page %ld does not exist.", page_no);
- goto error_silent;
+ goto error_exit;
}
}
@@ -1124,41 +1339,8 @@ pdf_doc_get_page (pdf_file *pf,
int page_idx = page_no - 1, kids_length = 1, i = 0;
while (--depth && i != kids_length) {
- if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "MediaBox")))) {
- if (media_box)
- pdf_release_obj(media_box);
- media_box = tmp;
- }
- if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "CropBox")))) {
- if (crop_box)
- pdf_release_obj(crop_box);
- crop_box = tmp;
- }
- if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "ArtBox")))) {
- if (art_box)
- pdf_release_obj(art_box);
- art_box = tmp;
- }
- if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) {
- if (trim_box)
- pdf_release_obj(trim_box);
- trim_box = tmp;
- }
- if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox")))) {
- if (bleed_box)
- pdf_release_obj(bleed_box);
- bleed_box = tmp;
- }
- if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Rotate")))) {
- if (rotate)
- pdf_release_obj(rotate);
- rotate = tmp;
- }
- if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Resources")))) {
- if (resources)
- pdf_release_obj(resources);
- resources = tmp;
- }
+ boxes->page_tree = page_tree;
+ get_page_properties(boxes);
kids = pdf_deref_obj(pdf_lookup_dict(page_tree, "Kids"));
if (!kids)
@@ -1199,17 +1381,61 @@ pdf_doc_get_page (pdf_file *pf,
goto error_exit;
}
- if (!PDF_OBJ_DICTTYPE(resources))
+ boxes->page_tree = page_tree;
+
+ return;
+
+error_exit:
+ WARN("Error found in including PDF image.");
+ if (page_tree)
+ pdf_release_obj(page_tree);
+
+ return;
+}
+
+
+/* count_p removed: Please use different interface if you want to get total page
+ * number. pdf_doc_get_page() is obviously not an interface to do such.
+ */
+pdf_obj *
+pdf_doc_get_page (pdf_file *pf,
+ int page_no, char * page_name,
+ enum pdf_page_boundary opt_bbox, /* load options */
+ pdf_rect *bbox, pdf_tmatrix *matrix, /* returned value */
+ pdf_obj **resources_p /* returned values */
+ ) {
+ pdf_obj *catalog = NULL, *page_tree = NULL;
+ pdf_boxes boxes = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+ int error = 0;
+
+ catalog = pdf_file_get_catalog(pf);
+
+ if (page_name) {
+ page_by_name(catalog, page_name, &boxes);
+ } else if (page_no > 0) {
+ page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages"));
+ page_by_number(page_tree, page_no, &boxes);
+ } else {
+ WARN("Invalid page number: %d", page_no);
+ goto error_exit;
+ }
+
+ page_tree = boxes.page_tree;
+
+ if (!PDF_OBJ_DICTTYPE(page_tree))
+ goto error_exit;
+
+ if (!PDF_OBJ_DICTTYPE(boxes.resources))
goto error_exit;
if (resources_p)
- *resources_p = pdf_link_obj(resources);
+ *resources_p = pdf_link_obj(boxes.resources);
/* Select page boundary box */
- error = set_bounding_box(bbox, opt_bbox, media_box, crop_box, art_box, trim_box, bleed_box);
+ error = set_bounding_box(bbox, opt_bbox, boxes.media_box, boxes.crop_box, boxes.art_box, boxes.trim_box, boxes.bleed_box);
if (error)
goto error_exit;
/* Set transformation matrix */
- error = set_transform_matrix(matrix, bbox, rotate);
+ error = set_transform_matrix(matrix, bbox, boxes.rotate);
if (error)
goto error_exit;
@@ -1223,20 +1449,20 @@ goto clean_exit; /* Success */
page_tree = NULL;
clean_exit:
- if (crop_box)
- pdf_release_obj(crop_box);
- if (bleed_box)
- pdf_release_obj(bleed_box);
- if (trim_box)
- pdf_release_obj(trim_box);
- if (art_box)
- pdf_release_obj(art_box);
- if (media_box)
- pdf_release_obj(media_box);
- if (rotate)
- pdf_release_obj(rotate);
- if (resources)
- pdf_release_obj(resources);
+ if (boxes.crop_box)
+ pdf_release_obj(boxes.crop_box);
+ if (boxes.bleed_box)
+ pdf_release_obj(boxes.bleed_box);
+ if (boxes.trim_box)
+ pdf_release_obj(boxes.trim_box);
+ if (boxes.art_box)
+ pdf_release_obj(boxes.art_box);
+ if (boxes.media_box)
+ pdf_release_obj(boxes.media_box);
+ if (boxes.rotate)
+ pdf_release_obj(boxes.rotate);
+ if (boxes.resources)
+ pdf_release_obj(boxes.resources);
return page_tree;
}
diff --git a/texk/dvipdfm-x/pdfdoc.h b/texk/dvipdfm-x/pdfdoc.h
index bd8bf3be..85e05bf9 100644
--- a/texk/dvipdfm-x/pdfdoc.h
+++ b/texk/dvipdfm-x/pdfdoc.h
@@ -94,7 +94,8 @@ extern pdf_obj *pdf_doc_get_reference(const char *category);
#define pdf_doc_this_page() pdf_doc_get_dictionary("@THISPAGE")
extern int pdf_doc_get_page_count(pdf_file *pf);
-extern pdf_obj *pdf_doc_get_page(pdf_file *pf, int page_no, enum pdf_page_boundary opt_bbox,
+extern pdf_obj *pdf_doc_get_page(pdf_file *pf, int page_no, char * page_name,
+ enum pdf_page_boundary opt_bbox,
pdf_rect *bbox, pdf_tmatrix *matrix, pdf_obj **resources_p);
extern int pdf_doc_current_page_number(void);
diff --git a/texk/dvipdfm-x/pdfximage.c b/texk/dvipdfm-x/pdfximage.c
index 92ee5142..016583fd 100644
--- a/texk/dvipdfm-x/pdfximage.c
+++ b/texk/dvipdfm-x/pdfximage.c
@@ -79,6 +79,7 @@ struct attr_
int bbox_type; /* Ugh */
pdf_obj *dict;
char tempfile;
+ char *page_name;
};
struct pdf_ximage_
@@ -143,6 +144,8 @@ pdf_init_ximage_struct (pdf_ximage *I)
I->attr.dict = NULL;
I->attr.tempfile = 0;
+
+ I->attr.page_name = NULL;
}
static void
@@ -302,6 +305,7 @@ load_image (const char *ident, const char *filename, const char *fullname, int f
}
I->attr.page_no = options.page_no;
+ I->attr.page_name = options.page_name;
I->attr.bbox_type = options.bbox_type;
I->attr.dict = options.dict; /* unsafe? */
@@ -411,6 +415,7 @@ pdf_ximage_load_image (const char *ident, const char *filename, load_options opt
}
if (id >= 0) {
if (I->attr.page_no == options.page_no &&
+ strcmp(I->attr.page_name, options.page_name) == 0 &&
!pdf_compare_object(I->attr.dict, options.dict) && /* ????? */
I->attr.bbox_type == options.bbox_type) {
return id;
diff --git a/texk/dvipdfm-x/pdfximage.h b/texk/dvipdfm-x/pdfximage.h
index 6cd99055..92f9021d 100644
--- a/texk/dvipdfm-x/pdfximage.h
+++ b/texk/dvipdfm-x/pdfximage.h
@@ -54,6 +54,7 @@ typedef struct {
int page_no;
enum pdf_page_boundary bbox_type;
pdf_obj *dict;
+ char *page_name;
} load_options;
typedef struct pdf_ximage_ pdf_ximage;
diff --git a/texk/dvipdfm-x/spc_pdfm.c b/texk/dvipdfm-x/spc_pdfm.c
index f6375cdc..fffe2714 100644
--- a/texk/dvipdfm-x/spc_pdfm.c
+++ b/texk/dvipdfm-x/spc_pdfm.c
@@ -1235,7 +1235,7 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
char *ident = NULL;
pdf_obj *fspec;
transform_info ti;
- load_options options = {1, 0, NULL};
+ load_options options = {1, 0, NULL, NULL};
skip_white(&args->curptr, args->endptr);
if (args->curptr[0] == '@') {
@@ -1250,7 +1250,8 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
*/
transform_info_clear(&ti);
if (spc_util_read_blahblah(spe, &ti,
- &options.page_no, &options.bbox_type, args) < 0) {
+ &options.page_no, &options.bbox_type,
+ &options.page_name, args) < 0) {
spc_warn(spe, "Reading option field in pdf:image failed.");
if (ident)
RELEASE(ident);
diff --git a/texk/dvipdfm-x/spc_util.c b/texk/dvipdfm-x/spc_util.c
index efe44bef..de13c584 100644
--- a/texk/dvipdfm-x/spc_util.c
+++ b/texk/dvipdfm-x/spc_util.c
@@ -898,6 +898,7 @@ int
spc_util_read_blahblah (struct spc_env *spe,
transform_info *p, int *page_no,
enum pdf_page_boundary *bbox_type,
+ char **page_name,
struct spc_arg *ap)
{
int has_scale, has_xscale, has_yscale, has_rotate, has_matrix;
@@ -912,6 +913,8 @@ spc_util_read_blahblah (struct spc_env *spe,
"page",
#define K__PAGEBOX 12
"pagebox",
+#define K__NAMED 13
+ "named",
NULL
};
double xscale, yscale, rotate;
@@ -1055,6 +1058,11 @@ spc_util_read_blahblah (struct spc_env *spe,
}
}
break;
+ case K__NAMED:
+ {
+ *page_name = parse_c_string (&ap->curptr, ap->endptr);
+ }
+ break;
default:
error = -1;
diff --git a/texk/dvipdfm-x/spc_util.h b/texk/dvipdfm-x/spc_util.h
index 63ec8f83..6310477e 100644
--- a/texk/dvipdfm-x/spc_util.h
+++ b/texk/dvipdfm-x/spc_util.h
@@ -45,6 +45,7 @@ extern int spc_util_read_blahblah (struct spc_env *spe,
transform_info *dimtrns,
int *page_no,
enum pdf_page_boundary *bbox_type,
+ char **page_name,
struct spc_arg *args);
diff --git a/texk/dvipdfm-x/xbb.c b/texk/dvipdfm-x/xbb.c
index e3a9c8da..1786396a 100644
--- a/texk/dvipdfm-x/xbb.c
+++ b/texk/dvipdfm-x/xbb.c
@@ -260,7 +260,7 @@ static void do_pdf (FILE *fp, char *filename)
return;
}
count = pdf_doc_get_page_count(pf);
- page = pdf_doc_get_page(pf, page_no, PageBox, &bbox, &matrix, NULL);
+ page = pdf_doc_get_page(pf, page_no, NULL, PageBox, &bbox, &matrix, NULL);
pdf_close(pf);