%!PS % PostScript Search & Replace and Disk Access Demo % ================================================ % by Don Lancaster % Copyright c 2002 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % PostScript-as-language utility allows a search and replace of any PDF file % of 65K or fewer characters without trashing any control commands or linefeed % conventions. Useful for gaining PostScript-->Distiller transparency. % A PDF xref rebuild should not be needed if search and replace are equal length. % WARNING: Watch for inadvertent similar text strings! These can be modified by % kerning. As in changing "4 0 R" to "4 0 |kR". % Presently limited to PDF files of several megs or fewer. % An "empty" and unused PDF file is also an expected result. % Also shows typical PostScript-as-language disk read and write routines. % ========= % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: (C:\\windows\\desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. % ======== /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def guru % activate gonzo utilities % ========= % input search and replace data. /diskfileheader (C:\\WINDOWS\\Desktop\\gurugrams\\pstrans\\inherit\\) store /diskfilesourcename (g9demoyx.pdf) store /diskfiletargetname (g9demozz.pdf) store /wuz ( 4 0 R) store % string to search -- DO NOT OMIT LEADING SPACE!!! /wilby ( 3 0 R) store % string to replace -- RETAIN CHARACTER COUNT!!! /workstring 60000 string store % length of workstring /sourcefilename diskfileheader diskfilesourcename mergestr store /targetfilename diskfileheader diskfiletargetname mergestr store /oops 1000 store % emergency breakout % create PostScript file objects.. /readfile sourcefilename (r) file store % establish input read file /writefile targetfilename (w+) file store % establish input read file /processgrab { oops { wuz search { writefile exch writestring % save previous (\nReplaced ) exch mergestr ( with ) mergestr % optional report wilby mergestr (.\n) mergestr = /noflag false store (dummy) pop wilby writefile exch writestring} % do replacement { writefile exch writestring exit } % nothing left ifelse } repeat } def /noflag true store oops { readfile workstring readstring {processgrab} {processgrab exit} ifelse } repeat noflag {(\nSorry, no replacements made.\n) ==} if % EOF