How to comment on PS or PDF from the command line (Linux) without losing quality?

Is there any command line tool for Linux that allows me to annotate a PS or PDF file with text or a specific font, color and size without losing quality? I tried to convert ImageMagick, and the resulting PDF file is of rather poor quality.

I have a template originally created in Adobe Illustrator, and I would like to generate PDF files from it with names in specific places. I have a huge list of names, so I would like to do this in a package (not interactively).

If anyone has any ideas, I would be happy to hear them. Thanks Carl

+4
source share
2 answers

I think it’s better to create a PDF form and fill it with pdftk fill_form in batch mode:

$ pdftk form.pdf fill_form data.fdf output out.pdf flatten 

The form data should be in the Form Data Form (this is just an XML file with the specified field names and values).
Pay attention to the flatten command. It is required to convert the completed form into a regular document.

Another way is to create a set of PDF documents "with names in specific places" and a transparent background, and pdftk stamp each of them is a template:

 $ pdftk template.pdf stamp words.pdf output out.pdf 
+2
source

Another way to achieve this would be to hack the postscript file itself. It used to be that AI files are postscript files, and you can modify them directly; I do not know if this is true. Therefore, you may have to export it.

For simplicity, I assume one page. Therefore, at the very end there will be one call to showpage (possibly through a different name). Any drawing commands executed before displaying will be displayed on the page.

You may need to reinitialize the state of the graphics ( initgraphics ), as the rest of the document may have left it funny, waiting for the showpage to clear before anyone notices.

To accommodate the text, you will need to install a new font (the old initgraphics was canceled) to measure the location in points (72 dpi, 28.3465 dots / cm).

 /Palatino-Roman 17 selectfont %so much prettier than Times xy moveto (new text) show 

To perform a merge, you can use perl: emit the beginning of the document as an HERE document, construct some text lines in the program, emit the tail of the document. Here is an example postscript generation with PERL

Or you can take data from the command line (using ghostscript) using the -- parameter ( $gs -q -- program.ps arg1 arg2 ... argn ). These arguments are available to the program through an array named / ARGUMENTS.

So, let's say you have good graphics of a scary clown holding a blank sign about 1 inch wide, 3 inches high, the top left corner 4 inches to the left, 4 inches from the base. You can paste this code into the ps program just before the showpage .

 initgraphics /Palatino-Roman 12 selectfont 4 72 mul 4 72 mul moveto ARGUMENTS { gsave show grestore 0 -14 rmoveto } forall 

Now you can make him say funny things ( $gs -- clown.ps "On a dark," "and stormy night..." ).

+3
source

Source: https://habr.com/ru/post/1384446/


All Articles