home *** CD-ROM | disk | FTP | other *** search
- % Copyright (C) 1994, 1995 Aladdin Enterprises. All rights reserved.
-
- % pdf2dsc.ps
- % read pdf file and produce DSC "index" file.
- % originally by Russell Lang 1995-04-26
- %
- % 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
-
-