summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Resource/Init/pdf_main.ps')
-rw-r--r--Resource/Init/pdf_main.ps156
1 files changed, 122 insertions, 34 deletions
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
index 038c19d1..3259c0fe 100644
--- a/Resource/Init/pdf_main.ps
+++ b/Resource/Init/pdf_main.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2022 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -218,7 +218,7 @@ DingbatsEncoding pop
% Redefine 'run' so it recognizes PDF files.
systemdict begin
-systemdict /NEWPDF known not {/NEWPDF //false def} if
+systemdict /NEWPDF known not {/NEWPDF //true def} if
% PostScript interface to the ghostpdf C-based interpreter
%
@@ -405,8 +405,7 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
% Stack - box boxwidth boxheight mediawidth mediaheight
% Incorporate up any offset from 0,0
- 4 index aload pop pop pop neg exch neg exch
- 2 copy exch
+ 4 index aload pop pop pop neg exch neg
translate
% Now use the box and media values to calculate the required x/y scale factors
@@ -419,7 +418,6 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
gt {exch} if % select smallest scale factor
pop %
dup scale % and scale page isomorphically
- pop pop
} bind def
/newpdf_get_media_box { % <pagedict> get_media_box <box> <bool>
@@ -444,32 +442,78 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
( Output may be incorrect.\n) newpdf_pdfformaterror
[ 0 0 currentpagedevice /PageSize get aload pop ] //false
} ifelse
-%(newpdf_get_media_box end) == flush
+} bind executeonly def
+
+% [llx lly urx ury] newpdf_check_empty_box [llx lly urx ury] true | false
+% rturns true and the original array if its valid, otherwise returns false
+/newpdf_check_empty_box
+{
+ dup type /arraytype eq
+ {
+ dup aload pop
+ dup 3 index eq
+ {
+ //true
+ }
+ {
+ 1 index 4 index eq
+ } ifelse
+ {
+ pop pop pop pop
+ ( **** Warning: File has an empty Box parameter.\n) print
+ ( Using the MediaBox instead.\n) print
+ ( Output may be incorrect.\n) print flush
+ pop //false
+ }
+ {
+ pop pop pop pop
+ //true
+ } ifelse
+ }
+ {
+ ( **** Warning: File has an invalid Box parameter.\n) print
+ ( Using the MediaBox instead.\n) print
+ ( Output may be incorrect.\n) print flush
+ pop //false
+ } ifelse
} bind executeonly def
/newpdf_get_any_box { % <pagedict> get_any_box <box name> <box>
-%(newpdf_get_any_box start) == flush
//systemdict /UseBleedBox .knownget dup { and } if {
- dup /BleedBox get {
- /BleedBox exch
+ dup /BleedBox .knownget {
+ newpdf_check_empty_box
+ {
+ /BleedBox exch
+ } if
} if
} if
- //systemdict /UseTrimBox .knownget dup { and } if {
- dup /TrimBox get {
- /TrimBox exch
+ dup type /arraytype ne {
+ //systemdict /UseTrimBox .knownget dup { and } if {
+ dup /TrimBox .knownget {
+ newpdf_check_empty_box
+ {
+ /TrimBox exch
+ } if
+ } if
} if
} if
dup type /arraytype ne {
//systemdict /UseArtBox .knownget dup { and } if {
- dup /ArtBox get {
- /ArtBox exch
+ dup /ArtBox .knownget {
+ newpdf_check_empty_box
+ {
+ /ArtBox exch
+ } if
} if
} if
} if
dup type /arraytype ne {
//systemdict /UseCropBox .knownget dup { and } if {
- dup /CropBox get {
- /CropBox exch
+ dup /CropBox .knownget {
+ newpdf_check_empty_box
+ {
+ /CropBox exch
+ } if
} if
} if
} if
@@ -484,6 +528,7 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
%% content when we st up the CTM, but we do need to make sure that we clamp
%% the BoundingBox, and that means we need to take direcitonality into account...
+ aload pop
6 -1 roll newpdf_get_media_box { % /SomeBox x0 y0 x1 y1 [MediaBox]
aload pop % /SomeBox x0 y0 x1 y1 X0 Y0 X1 Y1
@@ -556,6 +601,30 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
dup
dup newpdf_get_any_box % Stack: pdfpagedict pdfpagedict /BoxName [box]
+ % Check that the box is 'normal' and make it so if not
+ % Also check the array is 4 elements and if it isn't then use the
+ % current PageSize. The normalise arithmetic assumes the array is a 4
+ % element array.
+ dup length 4 ne {
+ % Invalid size of mediabox
+ pop currentpagedevice /PageSize get
+ } {
+ aload 5 1 roll % array x1 y1 x2 y2
+ exch % array x1 y1 y2 x2
+ 4 -1 roll % array y1 y2 x2 x1
+ 2 copy gt {
+ exch % array y1 y2 xmin xmax
+ } if
+ 4 -2 roll % array xmin xmax y1 y2
+ 2 copy gt {
+ exch % array xmin xmax ymin ymax
+ } if
+ 4 1 roll
+ exch 4 -1 roll
+ 5 -1 roll
+ astore
+ } ifelse
+
//systemdict /PDFFitPage known {
NewPDF_FitPage
} {
@@ -688,7 +757,9 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
} {
pop
} ifelse
- } if
+ } {
+ pop
+ }ifelse
pop
} bind executeonly def
@@ -704,10 +775,11 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
/newpdf_gather_parameters
{
10 dict begin
- /PDFSwitches [ /PDFPassword /PDFDEBUG /PDFSTOPONERROR /PDFSTOPONWARNING /NOTRANSPARENCY /FirstPage /LastPage
- /NOCIDFALLBACK /NO_PDFMARK_OUTLINES /NO_PDFMARK_DESTS /PDFFitPage /Printed
+ /PDFSwitches [ /QUIET /PDFPassword /PDFDEBUG /PDFSTOPONERROR /PDFSTOPONWARNING /NOTRANSPARENCY /FirstPage /LastPage
+ /PDFNOCIDFALLBACK /NO_PDFMARK_OUTLINES /NO_PDFMARK_DESTS /PDFFitPage /Printed /UsePDFX3Profile
/UseBleedBox /UseCropBox /UseArtBox /UseTrimBox /ShowAcroForm /ShowAnnots /PreserveAnnots
- /NoUserUnit /RENDERTTNOTDEF /DOPDFMARKS /PDFINFO /SHOWANNOTTYPES /PRESERVEANNOTTYPES] def
+ /NoUserUnit /RENDERTTNOTDEF /DOPDFMARKS /PDFINFO /SHOWANNOTTYPES /PRESERVEANNOTTYPES
+ /CIDSubstPath /CIDSubstFont /IgnoreToUnicode /NONATIVEFONTMAP ] def
0 1 PDFSwitches length 1 sub {
PDFSwitches exch get dup where {
@@ -935,8 +1007,8 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
% These are also for the benefit of pdf2dsc, which assumes they
% are available.
- /knownoget {2 copy known {get //true}{pop //false}ifelse} bind def
- /pget {2 copy known {get //true}{pop //false}ifelse}bind def
+ /knownoget {2 copy known {get //true}{pop pop //false}ifelse} bind def
+ /pget {2 copy known {get //true}{pop pop //false}ifelse}bind def
newpdf_gather_parameters
{.PDFInit} stopped
@@ -986,7 +1058,11 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
( **** Error: Page drawing error occured.\n) newpdf_pdfformaterror
( Output may be incorrect.\n) newpdf_pdfformaterror
} if
- showpage
+ {showpage} stopped
+ {
+ ( **** Error: Page drawing error occured.\n) newpdf_pdfformaterror
+ ( Could not draw this page at all, page will be missing in the output.\n) newpdf_pdfformaterror
+ } if
grestore
} bind def
@@ -1053,7 +1129,6 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if
{//true} ifelse
{
- QUIET not { (Page ) print dup //== exec flush } if
dup pdfgetpage
dup //null ne {
exch 1 index
@@ -3567,11 +3642,9 @@ currentdict /PDF2PS_matrix_key undef
% the pages resources. It may be high if a spot color is in a resource but
% is not actually used on the page.
currentpagedevice /PageSpotColors known {
- /PageSpotColors 2 index countspotcolors
- userdict /PageSpotColors 2 index put
- def
+ /PageSpotColors 2 index countspotcolors def
+ /SeparationColorNames userdict 1 index get def
} if
-
% If the user told us to use a named OutputIntent
systemdict /UseOutputIntent .knownget {
cvn
@@ -3640,7 +3713,7 @@ currentdict /PDF2PS_matrix_key undef
% Overprint is /enable, so the device might need the overprint compositor
% if it does not support spot colors, thus check if overprint is used so
% overprint simulation can be done with the pdf14 compositor
- 1 index countspotcolors userdict exch /PageSpotColors exch put % save it in a known place
+ 1 index countspotcolors pop
1 index pageusesoverprint
1 index /ProcessColorModel get /DeviceCMYK eq {
PageSpotColors 0 gt % count of colorants NOT including CMYK
@@ -3949,9 +4022,11 @@ currentdict /PDF2PS_matrix_key undef
not
and
//systemdict /PreserveAnnots .knownget not {//true} if and {
- mark exch {preserveannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse {cleartomark} stopped pop
+ mark exch {preserveannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse {cleartomark} stopped
+ {(Error: Failed to clean up after annotation, output may be incorrect.\n) pdfformaterror}if
}{
- mark exch {drawannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse {cleartomark} stopped pop
+ mark exch {drawannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse {cleartomark} stopped
+ {(Error: Failed to clean up after annotation, output may be incorrect.\n) pdfformaterror}if
} ifelse
} {
pop
@@ -4497,11 +4572,22 @@ currentdict /PDF2PS_matrix_key undef
% Note: This count does not include Cyan, Magenta, Yellow, or Black
/countspotcolors { % <pagedict> countspotcolors <count>
pagespotcolors % Get dict with all spot colors
- dup length % spot color dict length
% Remove CMYK from the spot color count.
[ /Cyan /Magenta /Yellow /Black ]
- { 2 index exch known { 1 sub } if } forall
- exch pop % Remove spot color dict
+ {
+ dup 2 index exch known {
+ 1 index exch undef
+ } {
+ pop
+ } ifelse
+ } forall
+ dup length dup
+ userdict exch /PageSpotColors exch put % save it in a known place
+ exch
+ userdict /SeparationColorNames 2 index
+ [ exch { pop } forall ]
+ put % and save the SpotColorNames array in a known place
+ pop % done with spot color dict
} bind executeonly def
% ------ ColorSpace substitution support ------ %
@@ -4834,6 +4920,8 @@ currentdict /PDF2PS_matrix_key undef
pop
}bind readonly def
+/NestedPatterns <<>> def
+
end % pdfdict