home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / gs403osk.tgz / gs403osk.tar / pdf2dsc.ps < prev    next >
Text File  |  1996-09-22  |  3KB  |  86 lines

  1. %    Copyright (C) 1994, 1995, 1996 Aladdin Enterprises.  All rights reserved.
  2.  
  3. % pdf2dsc.ps
  4. % read pdf file and produce DSC "index" file.
  5. %
  6. % Input  file is named PDFname
  7. % Output file is named DSCname
  8. %
  9. % Run using:
  10. %  gs -dNODISPLAY -sPDFname=pdffilename -sDSCname=tempfilename pdf2dsc.ps
  11. % Then display the PDF file with
  12. %  gs tempfilename
  13. %
  14. % Modified by Geoff Keating <Geoff.Keating@anu.edu.au> 7/3/96:
  15. %   include Title and CreationDate DSC comments (these are displayed by
  16. %     Ghostview);
  17. %   reduce the size of typical output files by a factor of about 3.
  18. % Modified by L. Peter Deutsch 3/18/96:
  19. %   Removes unnecessary and error-prone code duplicated from pdf_main.ps
  20. % Modified by L. Peter Deutsch for GS 3.33
  21. % Originally by Russell Lang  1995-04-26
  22.  
  23. /DSCfile DSCname (w) file def
  24. /DSCstring 255 string def
  25.    GS_PDF_ProcSet begin
  26.    pdfdict begin
  27.    PDFname (r) file
  28.    pdfopen begin
  29. % setup for loop  (init increment limit)
  30.    /FirstPage where { pop FirstPage } { 1 } ifelse
  31.    1
  32.    /LastPage where { pop LastPage } { pdfpagecount } ifelse
  33. % write header and prolog
  34. DSCfile (%!PS-Adobe-3.0\n) writestring
  35. Trailer /Info knownoget
  36.  {
  37.    dup /Title knownoget
  38.     {
  39.       DSCfile (%%Title: ) writestring
  40.       DSCfile exch write==
  41.     }
  42.    if
  43.    /CreationDate knownoget
  44.     {
  45.       DSCfile (%%CreationDate: ) writestring
  46.       DSCfile exch write==
  47.     }
  48.    if
  49.  }
  50. if
  51. DSCfile (%%Pages: ) writestring
  52. DSCfile 1 index 3 index sub 1 add DSCstring cvs writestring
  53. DSCfile (\n%%EndComments\n) writestring
  54. DSCfile (%%BeginProlog\n) writestring
  55. DSCfile (/Page null def\n/Page# 0 def\n/PDFSave null def\n/DSCPageCount 0 def\n) writestring
  56. DSCfile (/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage } def\n) writestring
  57. DSCfile (GS_PDF_ProcSet begin\npdfdict begin\n) writestring
  58. DSCfile (%%EndProlog\n) writestring
  59. DSCfile (%%BeginSetup\n) writestring
  60. DSCfile PDFname write==only
  61. DSCfile ( \(r\) file pdfopen begin\n) writestring
  62. DSCfile (%%EndSetup\n) writestring
  63. % process each page
  64.     {
  65. DSCfile (%%Page: ) writestring
  66. DSCfile 1 index DSCstring cvs writestring
  67. DSCfile ( ) writestring
  68. DSCfile 1 index DSCstring cvs writestring
  69. DSCfile (\n) writestring
  70. DSCfile exch DSCstring cvs writestring
  71. DSCfile ( DoPDFPage\n) writestring
  72.     } for
  73.    currentdict pdfclose
  74.    end
  75.    end
  76.    end
  77. % write trailer
  78. DSCfile (%%Trailer\n) writestring
  79. DSCfile (currentdict pdfclose\nend\nend\nend\n) writestring
  80. DSCfile (%%EOF\n) writestring
  81. % close output file and exit
  82. DSCfile closefile
  83. quit
  84. % end of pdf2dsc.ps
  85.  
  86.