pdf2dsc.ps

来自「遗传算法工具箱 希望高手指点 GATOOLS」· PS 代码 · 共 86 行

PS
86
字号
%    Copyright (C) 1994, 1995, 1996 Aladdin Enterprises.  All rights reserved.

% pdf2dsc.ps
% read pdf file and produce DSC "index" file.
%
% 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
%
% Modified by Geoff Keating <Geoff.Keating@anu.edu.au> 7/3/96:
%	include Title and CreationDate DSC comments (these are displayed by
%	  Ghostview);
%	reduce the size of typical output files by a factor of about 3.
% Modified by L. Peter Deutsch 3/18/96:
%	Removes unnecessary and error-prone code duplicated from pdf_main.ps
% Modified by L. Peter Deutsch for GS 3.33
% Originally by Russell Lang  1995-04-26

/DSCfile DSCname (w) file def
/DSCstring 255 string 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
Trailer /Info knownoget
 {
   dup /Title knownoget
    {
      DSCfile (%%Title: ) writestring
      DSCfile exch write==
    }
   if
   /CreationDate knownoget
    {
      DSCfile (%%CreationDate: ) writestring
      DSCfile exch write==
    }
   if
 }
if
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/Page# 0 def\n/PDFSave null def\n/DSCPageCount 0 def\n) writestring
DSCfile (/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage } 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
    {
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 ( DoPDFPage\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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?