Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
%    Copyright (C) 2000 Aladdin Enterprises.  All rights reserved.
2
% 
3
% This file is part of Aladdin Ghostscript.
4
% 
5
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
6
% or distributor accepts any responsibility for the consequences of using it,
7
% or for whether it serves any particular purpose or works at all, unless he
8
% or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
9
% License (the "License") for full details.
10
% 
11
% Every copy of Aladdin Ghostscript must include a copy of the License,
12
% normally in a plain ASCII text file named PUBLIC.  The License grants you
13
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
14
% under certain conditions described in the License.  Among other things, the
15
% License requires that the copyright notice and this notice be preserved on
16
% all copies.
17
 
18
% $Id: pdfeof.ps,v 1.1 2000/03/09 08:40:40 lpd Exp $
19
% Patch to allow garbage on the end of PDF files.
20
 
21
.currentglobal true .setglobal
22
pdfdict begin
23
 
24
% Skip backward over the %%EOF at the end of the PDF file.
25
% We put this in a separate procedure so we can easily offer the option
26
% of accepting garbage after the %%EOF, which the PDF specification
27
% unambiguously forbids but which some applications (including, apparently,
28
% Acrobat Distiller on the Macintosh) produce, and of accepting the
29
% xref position on the same line as startxref.
30
/findxref {		% - findxref <xrefpos>
31
  PDFfile dup dup 0 setfileposition bytesavailable
32
  dup /PDFfilelen exch def
33
	% Find the last %%EOF string (within 2048 bytes)
34
  2048 sub PDFoffset .max
35
  2 copy setfileposition
36
  PDFfilelen exch sub string 1 index exch readstring pop {
37
    (\015%%EO) search {		% Adobe can handle truncated key string
38
      pop pop			% if found, keep searching 'post' string
39
    } {
40
      (\012%%EO) search
41
	{ pop pop } { exit } ifelse	% exit if neither string found
42
    } ifelse
43
  } loop
44
  PDFfilelen exch length sub 4 sub PDFoffset .max setfileposition
45
	% Now read the startxref and xref start position.
46
  prevline token not { null } if dup type /integertype eq {
47
    exch pop cvi		% xref start position
48
    exch PDFfile exch setfileposition
49
    prevline (startxref) linene { findxreferror } if
50
    pop
51
  } {	% else, this file has 'startxref #####' format
52
    (startxref) ne { findxreferror } if
53
    cvi		% xref start position
54
    exch PDFfile exch setfileposition
55
  } ifelse
56
} bind def
57
 
58
end			% pdfdict
59
.setglobal