Bauteile-Verwaltung part-db

miscellaneous stuff

Some tricks with GNU ghostscript

Convert PDF fonts to paths

For example, when importing from the PDF into Inkscape smashes the fonts, one possible solution is to convert the PDF fonts into paths.

This is achieved by a solution I found somewhere on the web a long time ago.

pdftops -level3 x.pdf
gs -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dPDFSETTINGS=/prepress \
	-dAutoRotatePages=/None -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode \
	-sOutputFile=myfile-curves.pdf -c "/show { true charpath currentpoint /jy exch def /jx exch def fill jx jy moveto} bind def /ashow {exch pop exch /j_ax exch def show /j_ax {0} def } bind def /widthshow { show pop pop pop} bind def /awidthshow {ashow pop pop pop} bind def" -f
(TODO: verify that it works also with the backslashes used to break the lines)

Crop PDF pages

pdfcrop is a very useful tool. It sets the "bounding box" of a PDF page to the smallest possible one.

To clip away some contents, one can specify negative values, as described in a thread in the ubuntu forums.

For example pdfcrop --margins '0 -350 0 -50' myfile-curves.pdf output.pdf. The unit is points, and the order of the numbers is left, top, right, bottom.
The very old version PDFCROP 1.20 appears to have a problem when the output file already exists. Then it might happen, that the already existing output file is not overwritten. But while doing so, no error message is printed.