diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 16:53:33 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 16:53:33 +0300 |
commit | e463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (patch) | |
tree | d5e9f57c28f026cb21de3bd77cc10cd7f64aaa85 /sys/lib/ghostscript/pdfeof.ps | |
parent | b41b9034225ab3e49980d9de55c141011b6383b0 (diff) |
Import sources from 2011-03-30 iso image - sys/lib
Diffstat (limited to 'sys/lib/ghostscript/pdfeof.ps')
-rwxr-xr-x | sys/lib/ghostscript/pdfeof.ps | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/sys/lib/ghostscript/pdfeof.ps b/sys/lib/ghostscript/pdfeof.ps new file mode 100755 index 000000000..e08fd62eb --- /dev/null +++ b/sys/lib/ghostscript/pdfeof.ps @@ -0,0 +1,59 @@ +% Copyright (C) 2000 Aladdin Enterprises. All rights reserved. +% +% This file is part of Aladdin Ghostscript. +% +% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author +% or distributor accepts any responsibility for the consequences of using it, +% or for whether it serves any particular purpose or works at all, unless he +% or she says so in writing. Refer to the Aladdin Ghostscript Free Public +% License (the "License") for full details. +% +% Every copy of Aladdin Ghostscript must include a copy of the License, +% normally in a plain ASCII text file named PUBLIC. The License grants you +% the right to copy, modify and redistribute Aladdin Ghostscript, but only +% under certain conditions described in the License. Among other things, the +% License requires that the copyright notice and this notice be preserved on +% all copies. + +% $Id: pdfeof.ps,v 1.1 2000/03/09 08:40:40 lpd Exp $ +% Patch to allow garbage on the end of PDF files. + +.currentglobal true .setglobal +pdfdict begin + +% Skip backward over the %%EOF at the end of the PDF file. +% We put this in a separate procedure so we can easily offer the option +% of accepting garbage after the %%EOF, which the PDF specification +% unambiguously forbids but which some applications (including, apparently, +% Acrobat Distiller on the Macintosh) produce, and of accepting the +% xref position on the same line as startxref. +/findxref { % - findxref <xrefpos> + PDFfile dup dup 0 setfileposition bytesavailable + dup /PDFfilelen exch def + % Find the last %%EOF string (within 2048 bytes) + 2048 sub PDFoffset .max + 2 copy setfileposition + PDFfilelen exch sub string 1 index exch readstring pop { + (\015%%EO) search { % Adobe can handle truncated key string + pop pop % if found, keep searching 'post' string + } { + (\012%%EO) search + { pop pop } { exit } ifelse % exit if neither string found + } ifelse + } loop + PDFfilelen exch length sub 4 sub PDFoffset .max setfileposition + % Now read the startxref and xref start position. + prevline token not { null } if dup type /integertype eq { + exch pop cvi % xref start position + exch PDFfile exch setfileposition + prevline (startxref) linene { findxreferror } if + pop + } { % else, this file has 'startxref #####' format + (startxref) ne { findxreferror } if + cvi % xref start position + exch PDFfile exch setfileposition + } ifelse +} bind def + +end % pdfdict +.setglobal |