home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
swCHIP 1991 January
/
swCHIP_95-1.bin
/
utility
/
gsview13
/
src
/
pdf2dsc.ps
< prev
next >
Wrap
Text File
|
1995-12-09
|
2KB
|
70 lines
%!
% pdf2dsc.ps
% read pdf file and produce DSC "index" file.
% by Russell Lang 1995-05-15
%
% modified from runpdf in gs 3.33 pdf_main.ps by Aladdin Enterprises.
%
% Input file is named PDFname
% Output file is named DSCname
%
% Run using:
% gs -dNODISPLAY -sPDFname=pdffilename -sDSCname=tempfilename pdf2dsc.ps
% Then display the PDF file with
% gs tempfilename
/DSCfile DSCname (w) file def
/DSCstring 255 string def
% put these in userdict so we can write to them later
/Page# null def
/Page null def
/PDFSave null def
%
GS_PDF_ProcSet begin
pdfdict begin
PDFname (r) file
pdfopen begin
% setup for loop (init increment limit)
/FirstPage where { pop FirstPage } { 1 } ifelse
1
/LastPage where { pop LastPage } { pdfpagecount } ifelse
% write header and prolog
DSCfile (%!PS-Adobe-3.0\n) writestring
DSCfile (%%Pages: ) writestring
DSCfile 1 index 3 index sub 1 add DSCstring cvs writestring
DSCfile (\n%%EndComments\n) writestring
DSCfile (%%BeginProlog\n) writestring
DSCfile (/Page null def\n/PDFSave null def\n) writestring
DSCfile (GS_PDF_ProcSet begin\npdfdict begin\n) writestring
DSCfile (%%EndProlog\n) writestring
DSCfile (%%BeginSetup\n) writestring
DSCfile PDFname write==only
DSCfile ( \(r\) file pdfopen begin\n) writestring
DSCfile (%%EndSetup\n) writestring
% process each page
{ dup /Page# exch store
DSCfile (%%Page: ) writestring
DSCfile 1 index DSCstring cvs writestring
DSCfile ( ) writestring
DSCfile 1 index DSCstring cvs writestring
DSCfile (\n) writestring
DSCfile exch DSCstring cvs writestring
DSCfile ( pdfgetpage /Page exch store\n) writestring
DSCfile (save /PDFSave exch store\n) writestring
DSCfile (Page pdfshowpage\n) writestring
DSCfile (PDFSave restore\n) writestring
} for
currentdict pdfclose
end
end
end
% write trailer
DSCfile (%%Trailer\n) writestring
DSCfile (currentdict pdfclose\nend\nend\nend\n) writestring
DSCfile (%%EOF\n) writestring
% close output file and exit
DSCfile closefile
quit
% end of pdf2dsc.ps