[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1854-g6690c60
[email protected] (Ken Sharp) Wed, 13 Nov 2019 14:15:12 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via 6690c60c3e1be875134150fa4909bff0de7d583f (commit)
from 9e1d2f76cabf84576424af0c38dceef5881c2b21 (commit)
----------------------------------------------------------------------
commit 6690c60c3e1be875134150fa4909bff0de7d583f
Author: Ken Sharp <[email protected]>
Date: Wed Nov 13 14:03:25 2019 +0000
pdfwrite - For PDF input, copy any UserUnit to the output
If the input is PDF, and the input file uses the ugly UserUnit hack to
work around MediaBox limits in Acrobat, and the CompatibilityLevel of
the output is at least PDF 1.6, then do not apply the UserUnit to the
MediaBox and do not scale the content. Instead pass the value of
UserUnit to the pdfwrite device and insert it into the output page.
We use a special_op to inquire whether the device would like us to pass
it the UserUnit. The pdfwrite device checks the current PDF level
being emitted and either returns true, or false if too low a level is
requested.
If it returns true the PDF interpreter does not apply the UserUnit
scaling but instead uses a second special_op to inform the device what
of the value of UserUnit.
The pdfwrite device adds any non-unity value of UserUnit to the page
dictionary when emitting it.
If -dNoUserUnit is set we neither apply the UserUnit scaling nor pass it
to the device.
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index f7fb843..2f8b610 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -3104,7 +3104,10 @@ end
% Scaling due to -dPDFFitPage is not undone, to keep the correct border width
% compared to the size of the surrounding marks.
//systemdict /NoUserUnit .knownget not { //false } if not
- //systemdict /PDFFitPage known not and { % UserUnit is ignored if -dPDFFitPage
+ //systemdict /PDFFitPage known not and
+ % Don't apply USerUnit if we are passing it to the device
+ /PassUserUnit /GetDeviceParam .special_op {exch pop} {//false} ifelse not and
+ { % UserUnit is ignored if -dPDFFitPage
Page /UserUnit knownoget { div } if
} if
{} 2 index /S knownoget {
@@ -3148,7 +3151,10 @@ end
% Scaling due to -dPDFFitPage is not undone, to keep the correct border width
% compared to the size of the surrounding marks.
//systemdict /NoUserUnit .knownget not { //false } if not
- //systemdict /PDFFitPage known not and { % UserUnit is ignored if -dPDFFitPage
+ //systemdict /PDFFitPage known not and
+ % Don't apply USerUnit if we are passing it to the device
+ /PassUserUnit /GetDeviceParam .special_op {exch pop} {//false} ifelse not and
+ { % UserUnit is ignored if -dPDFFitPage
Page /UserUnit knownoget { div } if
} if
{} 2 index /S knownoget {
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
index 7c608c8..d771b1e 100644
--- a/Resource/Init/pdf_main.ps
+++ b/Resource/Init/pdf_main.ps
@@ -2505,9 +2505,26 @@ end readonly def
1
} {
1 index /UserUnit knownoget {
- PDFDEBUG { (Scaling due to UserUnit by ) print dup = flush } if
+ /PassUserUnit /GetDeviceParam .special_op {
+ exch pop dup {
+ [ /UserUnit 4 -1 roll .pdfputparams pop pop 1 exch
+ } if
+ }{
+ //false
+ }ifelse
+
+ not {
+ PDFDEBUG { (Scaling due to UserUnit by ) print dup = flush } if
+ } if
} {
- 1
+ /PassUserUnit /GetDeviceParam .special_op {
+ exch pop {
+ [ /UserUnit 1 .pdfputparams pop pop
+ } if
+ 1
+ }{
+ 1
+ } ifelse
} ifelse
} ifelse
} ifelse
@@ -2585,8 +2602,23 @@ currentdict /PDF2PS_matrix_key undef
% Set the page size.
//systemdict /NoUserUnit .knownget not { //false } if not {
3 index /UserUnit knownoget {
- dup 4 -1 roll mul 3 1 roll mul
- } if
+ /PassUserUnit /GetDeviceParam .special_op {
+ exch pop dup {
+ [ /UserUnit 4 -1 roll .pdfputparams pop pop
+ } if
+ }{
+ //false
+ }ifelse
+ not {
+ dup 4 -1 roll mul 3 1 roll mul
+ } if
+ } {
+ /PassUserUnit /GetDeviceParam .special_op {
+ exch pop {
+ [ /UserUnit 1 .pdfputparams pop pop
+ } if
+ }if
+ } ifelse
} if
} ifelse
2 array astore /PageSize exch def
diff --git a/devices/vector/gdevpdf.c b/devices/vector/gdevpdf.c
index d918d60..b25a4a6 100644
--- a/devices/vector/gdevpdf.c
+++ b/devices/vector/gdevpdf.c
@@ -1020,6 +1020,7 @@ pdf_close_page(gx_device_pdf * pdev, int num_copies)
page->contents_id = pdev->contents_id;
page->NumCopies_set = pdev->NumCopies_set;
page->NumCopies = pdev->NumCopies;
+ page->UserUnit = pdev->UserUnit;
pdf_record_usage(pdev, pdev->contents_id, pdev->next_page);
pdf_record_usage(pdev, pdev->contents_length_id, pdev->next_page);
pdf_record_usage(pdev, page->Page->id, pdev->next_page);
@@ -1337,6 +1338,9 @@ pdf_write_page(gx_device_pdf *pdev, int page_num)
bleedbox[0], bleedbox[1], bleedbox[2], bleedbox[3]);
}
pdf_print_orientation(pdev, page);
+ if (page->UserUnit != 1)
+ pprintg1(s, "/UserUnit %g\n", page->UserUnit);
+
pprintld1(s, "/Parent %ld 0 R\n", pdev->Pages->id);
if (pdev->ForOPDFRead && pdev->DoNumCopies && !pdev->ProduceDSC) {
if (page->NumCopies_set)
diff --git a/devices/vector/gdevpdfb.h b/devices/vector/gdevpdfb.h
index a47fec8..e1ca236 100644
--- a/devices/vector/gdevpdfb.h
+++ b/devices/vector/gdevpdfb.h
@@ -289,7 +289,8 @@ const gx_device_pdf PDF_DEVICE_IDENT =
-1, /* Last Form ID, start with -1 which means 'none' */
0, /* ExtensionMetadata */
0, /* PDFFormName */
- 0 /* PassThroughWriter */
+ 0, /* PassThroughWriter */
+ 1.0 /* UserUnit */
};
#else
diff --git a/devices/vector/gdevpdfp.c b/devices/vector/gdevpdfp.c
index df2ff37..2f29dba 100644
--- a/devices/vector/gdevpdfp.c
+++ b/devices/vector/gdevpdfp.c
@@ -127,6 +127,7 @@ static const gs_param_item_t pdf_param_items[] = {
pi("FastWebView", gs_param_type_bool, Linearise),
pi("NoOutputFonts", gs_param_type_bool, FlattenFonts),
pi("WantsPageLabels", gs_param_type_bool, WantsPageLabels),
+ pi("UserUnit", gs_param_type_float, UserUnit),
#undef pi
gs_param_item_end
};
@@ -237,6 +238,14 @@ gdev_pdf_get_param(gx_device *dev, char *Param, void *list)
if (strcmp(Param, "ForOPDFRead") == 0) {
return(param_write_bool(plist, "ForOPDFRead", &pdev->ForOPDFRead));
}
+ if (strcmp(Param, "PassUserUnit") == 0) {
+ bool dummy;
+ if (pdev->CompatibilityLevel > 1.5)
+ dummy = true;
+ else
+ dummy = false;
+ return(param_write_bool(plist, "PassUserUnit", &dummy));
+ }
if (!pdev->is_ps2write) {
if (strcmp(Param, "pdfmark") == 0){
return(param_write_null(plist, "pdfmark"));
@@ -559,6 +568,16 @@ gdev_pdf_put_params_impl(gx_device * dev, const gx_device_pdf * save_dev, gs_par
if (cl < 1.2) {
pdev->HaveCFF = false;
}
+
+ ecode = param_read_float(plist, "UserUnit", &pdev->UserUnit);
+ if (ecode < 0)
+ goto fail;
+ if (pdev->UserUnit == 0 || (pdev->UserUnit != 1 && pdev->CompatibilityLevel < 1.6)) {
+ ecode = gs_note_error(gs_error_rangecheck);
+ param_signal_error(plist, "UserUnit", ecode);
+ goto fail;
+ }
+
ecode = gdev_psdf_put_params(dev, plist);
if (ecode < 0)
goto fail;
diff --git a/devices/vector/gdevpdfx.h b/devices/vector/gdevpdfx.h
index f42d9f1..ad484ed 100644
--- a/devices/vector/gdevpdfx.h
+++ b/devices/vector/gdevpdfx.h
@@ -326,6 +326,7 @@ typedef struct pdf_page_s {
pdf_page_dsc_info_t dsc_info;
bool NumCopies_set; /* ps2write only. */
int NumCopies; /* ps2write only. */
+ float UserUnit; /* pdfwrite only */
} pdf_page_t;
#define private_st_pdf_page() /* in gdevpdf.c */\
gs_private_st_ptrs2(st_pdf_page, pdf_page_t, "pdf_page_t",\
@@ -901,6 +902,7 @@ struct gx_device_pdf_s {
* doing JPEG pass through we write the JPEG data here, and don't write
* anything in the image processing routines.
*/
+ float UserUnit;
};
#define is_in_page(pdev)\
Summary of changes:
Resource/Init/pdf_draw.ps | 10 ++++++++--
Resource/Init/pdf_main.ps | 40 ++++++++++++++++++++++++++++++++++++----
devices/vector/gdevpdf.c | 4 ++++
devices/vector/gdevpdfb.h | 3 ++-
devices/vector/gdevpdfp.c | 19 +++++++++++++++++++
devices/vector/gdevpdfx.h | 2 ++
6 files changed, 71 insertions(+), 7 deletions(-)