summaryrefslogtreecommitdiff
path: root/Resource
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2022-08-26 14:30:56 +0100
committerKen Sharp <ken.sharp@artifex.com>2022-08-26 14:32:06 +0100
commit1f56d7736465c45a2785d6bb3db1c37289599b40 (patch)
tree6577aae647e73dae62bf812577eef04d890339cc /Resource
parentaa6b1865f902a05d88590a8e4bdf5896ef6938f9 (diff)
downloadghostpdl-1f56d7736465c45a2785d6bb3db1c37289599b40.tar.gz
GhostPDF + GS - improve error handling
Arising from Bug #705784, if we hadn't built the PDF interpreter we would get typecheck errors which were somewhat misleading as to the source of the problem. This commit tidies up the error handling in the area of .PDFInit so that we not only detect the problem there but give a warning that it occurred. In addition, add a means to detect if the PDF interpreter is built in before we stat trying to process a PDF file and, if it is not, give a sensible error message. Tested with BUILD_PDF 0 and with NEWPDF true and false.
Diffstat (limited to 'Resource')
-rw-r--r--Resource/Init/pdf_main.ps56
1 files changed, 40 insertions, 16 deletions
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
index 0399efffb..f5fcdd62f 100644
--- a/Resource/Init/pdf_main.ps
+++ b/Resource/Init/pdf_main.ps
@@ -258,6 +258,9 @@ systemdict /NEWPDF known not {/NEWPDF //true def} if
% Uses currentdict as an argument to pdfclose, which closes /PDFfile. Also
% executes restore and various cleanup activities.
%
+% pdfavailable - pdfavailable <bool>
+% Determines if there is a PDF interpreter available
+%
% Also Used by gsview 5
% =====================
% pdfopen <file> pdfopen <dict>
@@ -878,22 +881,27 @@ currentdict /PDFSwitches undef
/newpdf_runpdf
{
runpdfbegin % <file> runpdfbegin -
- PDFInfo /Collection known
+ PDFInfo type /dicttype eq
{
- PDFInfo /Collection get
- pdfclose
- dup length 1 sub 0 2 3 -1 roll
+ PDFInfo /Collection known
{
- 1 index exch get (r) file runpdf
- } for
- pop
- }
- {
- process_trailer_attrs % - process_trailer_attrs -
- runpdfpagerange % - runpdfpagerange <int> <int>
- dopdfpages % <int> <int> dopdfpages -
- runpdfend % - runpdfend -
- } ifelse
+ PDFInfo /Collection get
+ pdfclose
+ dup length 1 sub 0 2 3 -1 roll
+ {
+ 1 index exch get (r) file runpdf
+ } for
+ pop
+ }
+ {
+ process_trailer_attrs % - process_trailer_attrs -
+ runpdfpagerange % - runpdfpagerange <int> <int>
+ dopdfpages % <int> <int> dopdfpages -
+ runpdfend % - runpdfend -
+ } ifelse
+ } {
+ pop pop
+ }ifelse
} bind def
/newpdf_runpdfbegin
@@ -939,6 +947,7 @@ currentdict /PDFSwitches undef
{
{.PDFInit} stopped
{
+ ( **** Error: Failed to initialise PDF interpreter.\n) newpdf_pdfformaterror
/PDFFile //null def
/PDFInfo //null def
}
@@ -1094,6 +1103,11 @@ currentdict /PDFSwitches undef
}ifelse
} bind def
+/pdfavailable
+{
+ .PDFAvailable NEWPDF not or
+} bind def
+
% <int> <int> dopdfpages -
% First Page and then LastPage
% If PDFPageList array exists, the parameters are 1 pdfpagecount and are ignored.
@@ -1199,10 +1213,20 @@ currentdict /PDFSwitches undef
% stack: tempname tempfile
dup 0 setfileposition
dup
- runpdf
+ pdfavailable {
+ runpdf
+ }{
+ closefile
+ (%stderr) (w) file ( **** ERROR: No PDF interpreter available, unable to process PDF files as input.\n)writestring
+ } ifelse
closefile deletefile
} {
- runpdf
+ pdfavailable {
+ runpdf
+ }{
+ closefile
+ (%stderr) (w) file ( **** ERROR: No PDF interpreter available, unable to process PDF files as input.\n)writestring
+ } ifelse
} ifelse
} {
pop pop pop pop cvx .runps % (%!PS) found first