From dbdc191b257bc6e8cc6e3f4133eae543e397e5aa Mon Sep 17 00:00:00 2001 From: Ken Sharp Date: Thu, 12 May 2022 12:10:10 +0100 Subject: Fix GhostPDF integration with GS - Use of /Page# We added /Page# to the dictionary returned from pdfgetpage in order to get pdf2dsc.ps to work (it relies upon that key being present) and potentially other PostScript programs as well. The key was added to the dictionary in pdfdopages. However, after adding it, we then proceeded to assume it would always be present, even if we called pdfpage and friends directly, rather than using pdfdopages. Fix that assumption here by adding the key to the dictionary in pdfgetpage instead of pdfdopages. There's no way (using the old PostScript code) to use any of the other functions without using pdfgetpage first. --- Resource/Init/pdf_main.ps | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Resource') diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps index c12fc3693..bb62bcc37 100644 --- a/Resource/Init/pdf_main.ps +++ b/Resource/Init/pdf_main.ps @@ -1026,13 +1026,17 @@ currentdict /PDFSwitches undef /newpdf_pdfgetpage { - PDFFile exch 1 sub {.PDFPageInfo} stopped + dup 1 sub + PDFFile exch {.PDFPageInfo} stopped { pop pop ( **** Error: Couldn't get page info.\n) newpdf_pdfformaterror ( Output may be incorrect.\n) newpdf_pdfformaterror //null - } if + }{ + dup 3 -1 roll + /Page# exch put + } ifelse } bind def /newpdf_process_trailer_attrs @@ -1135,10 +1139,8 @@ currentdict /PDFSwitches undef {//true} ifelse { - dup pdfgetpage + pdfgetpage dup //null ne { - exch 1 index - /Page# 3 -1 roll put pdfshowpage } { PDFSTOPONERROR { -- cgit v1.2.1