Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/lib/ghostscript/pdf2dsc.ps – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
%    Copyright (C) 1994, 1995, 1996, 1997, 1998 Aladdin Enterprises.  All rights reserved.
2
% 
3
% This software is provided AS-IS with no warranty, either express or
4
% implied.
5
% 
6
% This software is distributed under license and may not be copied,
7
% modified or distributed except as expressly authorized under the terms
8
% of the license contained in the file LICENSE in this distribution.
9
% 
10
% For more information about licensing, please refer to
11
% http://www.ghostscript.com/licensing/. For information on
12
% commercial licensing, go to http://www.artifex.com/licensing/ or
13
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
% San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
 
16
% $Id: pdf2dsc.ps,v 1.7 2002/03/30 23:39:15 raph Exp $
17
% pdf2dsc.ps
18
% read pdf file and produce DSC "index" file.
19
%
20
% Input  file is named PDFname
21
% Output file is named DSCname
22
%
23
% Run using:
24
%  gs -dNODISPLAY -sPDFname=pdffilename -sDSCname=tempfilename pdf2dsc.ps
25
% Then display the PDF file with
26
%  gs tempfilename
27
%
28
% Modified by Geoff Keating <geoffk@ozemail.com.au> 21/12/98:
29
%	Add DocumentMedia, PageMedia comments
30
%	Use inherited BoundingBox and Orientation
31
%	Reformat, add new macro 'puts', generally clean up
32
% Modified by Johannes Plass <plass@dipmza.physik.uni-mainz.de> 1996-11-05:
33
%	Adds BoundingBox and Orientation if available.
34
% Modified by rjl/lpd 9/19/96
35
%	Updates for compatibility with modified pdf_*.ps code for handling
36
%	  page ranges (i.e., partial files) better.
37
% Modified by Geoff Keating <Geoff.Keating@anu.edu.au> 7/3/96:
38
%	include Title and CreationDate DSC comments (these are displayed by
39
%	  Ghostview);
40
%	reduce the size of typical output files by a factor of about 3.
41
% Modified by L. Peter Deutsch 3/18/96:
42
%	Removes unnecessary and error-prone code duplicated from pdf_main.ps
43
% Modified by L. Peter Deutsch for GS 3.33
44
% Originally by Russell Lang  1995-04-26
45
 
46
/PDFfile PDFname (r) file def
47
/DSCfile DSCname (w) file def
48
systemdict /.setsafe known { .setsafe } if
49
 
50
/puts { DSCfile exch writestring } bind def
51
/DSCstring 255 string def
52
/MediaTypes 10 dict def
53
 
54
% (str1) (str2)  concatstr  (str1str2)
55
/concatstr {
56
  2 copy length exch length add string
57
  dup dup 5 2 roll copy length
58
% stack: newstring newstring str2 str1-length
59
  exch putinterval
60
} bind def
61
 
62
   GS_PDF_ProcSet begin
63
   pdfdict begin
64
   PDFfile
65
   pdfopen begin
66
   /FirstPage where { pop } { /FirstPage 1 def } ifelse
67
   /LastPage where { pop } { /LastPage pdfpagecount def } ifelse
68
 
69
% scan through for media sizes, keep them in the dictionary
70
   FirstPage 1 LastPage {
71
      pdfgetpage /MediaBox pget pop   % MediaBox is a required attribute
72
      aload pop 
73
      3 -1 roll sub 3 1 roll exch sub exch
74
      2 array astore 
75
      aload 3 1 roll 10 string cvs exch 10 string cvs
76
      (x) exch concatstr concatstr cvn
77
      MediaTypes 3 1 roll exch put
78
   } for
79
 
80
% write header and prolog
81
   (%!PS-Adobe-3.0\n) puts
82
   Trailer /Info knownoget
83
    {
84
      dup /Title knownoget
85
       {
86
         (%%Title: ) puts
87
         DSCfile exch write==
88
       }
89
      if
90
      /CreationDate knownoget
91
       {
92
         (%%CreationDate: ) puts
93
         DSCfile exch write==
94
       }
95
      if
96
    }
97
   if
98
   % This is really supposed to be sorted by frequency of usage...
99
   (%%DocumentMedia: )
100
   MediaTypes { 
101
      exch pop
102
      1 index puts
103
      (y) puts dup 1 get DSCstring cvs puts
104
      (x) puts dup 0 get DSCstring cvs puts 
105
      ( ) puts dup 0 get DSCstring cvs puts
106
      ( ) puts 1 get DSCstring cvs puts 
107
      ( 70 white ()\n) puts
108
      pop (%%+ )
109
   } forall
110
   pop
111
 
112
   (%%Pages: ) puts
113
   LastPage FirstPage sub 1 add DSCstring cvs puts
114
   (\n%%EndComments\n) puts
115
   (%%BeginProlog\n) puts
116
   (/Page null def\n/Page# 0 def\n/PDFSave null def\n) puts
117
   (/DSCPageCount 0 def\n) puts
118
   (/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage } def\n) puts
119
   (GS_PDF_ProcSet begin\npdfdict begin\n) puts
120
   (%%EndProlog\n) puts
121
   (%%BeginSetup\n) puts
122
   DSCfile PDFname write==only
123
   ( \(r\) file { DELAYSAFER { .setsafe } if } stopped pop\n) puts
124
   ( pdfopen begin\n) puts
125
   (%%EndSetup\n) puts
126
   % process each page
127
   FirstPage 1 LastPage {
128
       (%%Page: ) puts
129
       dup DSCstring cvs puts
130
       ( ) puts
131
       dup DSCstring cvs puts
132
       (\n) puts
133
 
134
       dup pdfgetpage
135
       dup /MediaBox pget pop
136
         (%%PageMedia: y) puts
137
	 aload pop 3 -1 roll sub DSCstring cvs puts
138
	 (x) puts exch sub DSCstring cvs puts
139
	 (\n) puts
140
       dup /CropBox pget {
141
         (%%PageBoundingBox: ) puts
142
         {DSCfile exch write=only ( ) puts} forall
143
         (\n) puts
144
       } if
145
       /Rotate pget {
146
         (%%PageOrientation: ) puts
147
         90 div cvi 4 mod dup 0 lt {4 add} if
148
         [(Portrait) (Landscape) (UpsideDown) (Seascape)] exch get puts
149
         (\n) puts
150
       } if
151
 
152
       DSCfile exch DSCstring cvs writestring
153
       ( DoPDFPage\n) puts
154
    } for
155
   currentdict pdfclose
156
   end
157
   end
158
   end
159
% write trailer
160
(%%Trailer\n) puts
161
(currentdict pdfclose\nend\nend\nend\n) puts
162
(%%EOF\n) puts
163
% close output file and exit
164
DSCfile closefile
165
quit
166
% end of pdf2dsc.ps