Search code examples
postscript

How to exchange text in PostScript


I do have the following content of PostScript code that is originally generated by the Ghostscript Printer on Windows XP.

/Euro /Times-BoldItalic /Times-BoldItalic-Copy BuildNewFont
} if
F /F1 0 /256 T /Times-BoldItalic mF 
/F1S52 F1 [82.664 0 0 -82.664 0 0 ] mFS
F1S52 Ji 
581 547 M (This is just a little test content)[55 42 42 23 46 37 42 37 28 21 51 42 21 51 46 42 32 66 42 21 60 42 55 21 21 21 55 37 32 46 55 42
23  0]xS 
; 

I just want to edit the text but if I try to change the text between the brackets the text gets distorted no matter if the new text is longer or shorter.

I tried to understand what the code above does, but I didn't find an appropriative documentation for that.

Could you please help me to understand what the code - especially the line starting with '581' means and how I can edit the text without destroying the layout?

Thank you in advance!

PS: I need this for a python script that automatically exchanges some paragraphs and therefore am not looking for a third party tool for editing, a PDF editing tool or something like that ;)


Solution

  • The line starting with '581' apparently moves to the point 581 547 then pushes a string and and array which is used by xS somehow. I suspect that xS is an extended version of show that uses that array, but I don't know how. You'd have to look at the beginning of the PS file to find the definition of xS. Also mFS seems like a transformation because it gets a matrix.

    Anyway, if the PS file contains typeset text, it's unlikely that you'll be able to change the text inside it without breaking the typesetting.