Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Umlaute in PS
PostScript stammt aus dem Jahre 1988, deshalb kann es nur mit 1-Byte-Zeichensätzen (8 Bit pro Zeichen) umgehen. Das Bereitet enorme Schwierigkeiten, wenn man ihm Unicode-Zeichensätze beipulen will…
Um in PS/PDF-Dokumenten mit Umlauten schreiben zu können, muss man einen PS-Zeichensatz (in 8 Bit) mit Umlauten haben.
PS-Standard-Zeichensatz (ohne Umlaute): Adobe-ASCII (7 Bit)
> cat ps-test_ASCII.ps | iconv -f UTF-8 -t ASCII | magick -page a4 -colorspace RGB - ps-test_ASCII.png
Auch in PS eingebetteter Zeichensatz (mit Umlaute, ohne Eurozeichen): ISO-8859-1 (8 Bit)
Externer Zeichensatz (mit Umlaute, mit Eurozeichen): ISO-1252 (8 Bit)
Damit man hiermit auch Umlaute darstellen kann ist es zwingend erforderlich,
dass die PS-Datei im gleichen Zeichensatz abgespeichert wird, wie der ist, den wir mit Umlauten haben!
In diesem Fall habe ich den Zeichensatz WINDOWS-1252 (ISO-1252).
Er wurde seinerzeit von OpenOffice.org 1.0.3 verwendet, um Daten dem Drucker zu übergeben.
Die Handhabung kann beispielsweise so aussehen (72 DPI):
# die PS-Datei schreiben/erstellen: [user@rechner ~]$ vim Test.ps # die PS-Datei vom üblichen UTF-8-Encoding (Linux) ins WINDOWS-1252-Encoding überführen und direkt an ImageMagick übergeben: [user@rechner ~]$ cat Test.ps | iconv -f UTF-8 -t WINDOWS-1252 | # die neue PS-Datei einmal in das PDF-Format (Dokument) und einmal in das PNG-Format (Bild) umwandeln: [user@rechner ~]$ cat Test.ps | iconv -f UTF-8 -t WINDOWS-1252 | magick -gravity SouthWest -colorspace RGB -quality 100 - Test.pdf [user@rechner ~]$ cat Test.ps | iconv -f UTF-8 -t WINDOWS-1252 | magick -gravity SouthWest -colorspace RGB -quality 100 - Test.png
Ggf. kann man die PS-Datei auch im grafischen Editor GEdit schreiben/erstellen, denn hier kann man für die PS-Datei, beim abspeichern, das gewünschte Encoding auswählen.
So spart man sich den Umwandlungsschritt mit iconv.
Ein Beispiel mit Umlauten, Eurozeichen, Skalierung und Maßstab in PS
[user@rechner ~]$ cat Test_-_127dpi.ps | iconv -f UTF-8 -t WINDOWS-1252 | magick -gravity SouthWest -colorspace RGB -quality 100 -page 1050x1485 -density 127 - Test_in_127dpi.pdf [user@rechner ~]$ cat Test_-_254dpi.ps | iconv -f UTF-8 -t WINDOWS-1252 | magick -gravity SouthWest -colorspace RGB -quality 100 -page 2100x2970 -density 254 - Test_in_254dpi.pdf
Für dieses Beispiel habe ich mir ein Shell-Skript (Linux + FreeBSD) geschrieben, womit man ganz einfach aus dieser PS-Datei eine PDF- und eine PNG-Datei erzeugen kann.
[user@rechner ~]$ /usr/local/bin/PS2IMG.sh Test.ps
- /usr/local/bin/PS2IMG.sh
#!/bin/sh VERSION="v2025052200" # initial #------------------------------------------------------------------------------# ls "${1}" || exit 1 DATEI_NAME="$(echo "${1}" | grep -E '[.][Pp][Ss]$' | sed 's/[.][Pp][Ss]$//')" if [ x = "x${DATEI_NAME}" ] ; then echo "${0} [PS-Datei]" echo "${0} Test.ps" exit 1 fi #------------------------------------------------------------------------------# # A4 -> 210 x 297 mm -> 72 dpi (2,8346 mm je Pixel) -> 595,2756 x 841,8898 Pixel # A4 -> 210 x 297 mm -> 127 dpi (5,0000 mm je Pixel) -> 1050,0000 x 1485,0000 Pixel #------------------------------------------------------------------------------# seitengroesse() { SEITENGROESSE="$(echo "${AUFLOESUNG}" | awk '{printf "%.0fx%.0f\n", ($1*2100/254),($1*2970/254)}')" } ### suche nach soetwas wie: # 72 25.4 div massstab div dup scale # 127 25.4 div massstab div dup scale # 254 25.4 div massstab div dup scale # 381 25.4 div massstab div dup scale # 508 25.4 div massstab div dup scale AUFLOESUNG="$(grep -Ei '^[0-9][0-9]*[ \t]+.*[ \t]+scale' ${DATEI_NAME}.ps | grep -Fiv scalefont | head -n1 | awk '{print $1}')" if [ x = "x${AUFLOESUNG}" ] ; then ### wenn nichts gefunden wurde, dann suche nach soetwas wie: # /mm {2.834645669 mul} def # /mm {5 mul} def # /mm {10 mul} def # /mm {15 mul} def # /mm {20 mul} def AUFLOESUNG="$(grep -E '^[/]mm [{]10 mul[}] def' ${DATEI_NAME}.ps | awk -F'[{}]' '{print $2}' | awk '{print $1*254/10}')" if [ x = "x${AUFLOESUNG}" ] ; then AUFLOESUNG="72" seitengroesse else seitengroesse fi else seitengroesse fi #------------------------------------------------------------------------------# echo " # DATEI_NAME='${DATEI_NAME}.*' # AUFLOESUNG='${AUFLOESUNG} dpi' # SEITENGROESSE='${SEITENGROESSE} Pixel' " #------------------------------------------------------------------------------# # WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert" for ENDUNG in pdf png do cat ${DATEI_NAME}.ps | iconv -f UTF-8 -t WINDOWS-1252 | magick -gravity SouthWest -colorspace RGB -quality 100 -page ${SEITENGROESSE} -density ${AUFLOESUNG} - ${DATEI_NAME}.${ENDUNG} done #------------------------------------------------------------------------------#
- Test.ps
%!PS-Adobe 3.0 %%BeginProlog (OpenOffice.org 1.0.3) /ISO1252Encoding [ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quotesingle /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one /two /three /four /five /six /seven /eight /nine /colon /semicolon /less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore /grave /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright /asciitilde /unused /Euro /unused /quotesinglbase /florin /quotedblbase /ellipsis /dagger /daggerdbl /circumflex /perthousand /Scaron /guilsinglleft /OE /unused /Zcaron /unused /unused /quoteleft /quoteright /quotedblleft /quotedblright /bullet /endash /emdash /tilde /trademark /scaron /guilsinglright /oe /unused /zcaron /Ydieresis /space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright /ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf /threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] def /psp_definefont { exch dup findfont dup length dict begin { 1 index /FID ne { def } { pop pop } ifelse } forall /Encoding 3 -1 roll def currentdict end exch pop definefont pop } def /pathdict dup 8 dict def load begin /rcmd { { currentfile 1 string readstring pop 0 get dup 32 gt { exit } { pop } ifelse } loop dup 126 eq { pop exit } if 65 sub dup 16#3 and 1 add exch dup 16#C and -2 bitshift 16#3 and 1 add exch 16#10 and 16#10 eq 3 1 roll exch } def /rhex { dup 1 sub exch currentfile exch string readhexstring pop dup 0 get dup 16#80 and 16#80 eq dup 3 1 roll { 16#7f and } if 2 index 0 3 -1 roll put 3 1 roll 0 0 1 5 -1 roll { 2 index exch get add 256 mul } for 256 div exch pop exch { neg } if } def /xcmd { rcmd exch rhex exch rhex exch 5 -1 roll add exch 4 -1 roll add 1 index 1 index 5 -1 roll { moveto } { lineto } ifelse } def end /readpath { 0 0 pathdict begin { xcmd } loop end pop pop } def systemdict /languagelevel known not { /xshow { exch dup length 0 1 3 -1 roll 1 sub { dup 3 index exch get exch 2 index exch get 1 string dup 0 4 -1 roll put currentpoint 3 -1 roll show moveto 0 rmoveto } for pop pop } def /rectangle { 4 -2 roll moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath } def /rectfill { rectangle fill } def /rectstroke { rectangle stroke } def } if /psp_lzwfilter { currentfile /ASCII85Decode filter /LZWDecode filter } def /psp_ascii85filter { currentfile /ASCII85Decode filter } def /psp_lzwstring { psp_lzwfilter 1024 string readstring } def /psp_ascii85string { psp_ascii85filter 1024 string readstring } def /psp_imagedict { /psp_bitspercomponent { 3 eq { 1 }{ 8 } ifelse } def /psp_decodearray { [ [0 1 0 1 0 1] [0 255] [0 1] [0 255] ] exch get } def 7 dict dup /ImageType 1 put dup /Width 7 -1 roll put dup /Height 5 index put dup /BitsPerComponent 4 index psp_bitspercomponent put dup /Decode 5 -1 roll psp_decodearray put dup /ImageMatrix [1 0 0 1 0 0] dup 5 8 -1 roll put put dup /DataSource 4 -1 roll 1 eq { psp_lzwfilter } { psp_ascii85filter } ifelse put } def %%EndProlog (OpenOffice.org 1.0.3) /URWGothicL-Book-iso1252 /URWGothicL-Book ISO1252Encoding psp_definefont /URWGothicL-Demi-iso1252 /URWGothicL-Demi ISO1252Encoding psp_definefont /URWGothicL-BookObli-iso1252 /URWGothicL-BookObli ISO1252Encoding psp_definefont /URWGothicL-DemiObli-iso1252 /URWGothicL-DemiObli ISO1252Encoding psp_definefont /URWBookmanL-Ligh-iso1252 /URWBookmanL-Ligh ISO1252Encoding psp_definefont /URWBookmanL-DemiBold-iso1252 /URWBookmanL-DemiBold ISO1252Encoding psp_definefont /URWBookmanL-LighItal-iso1252 /URWBookmanL-LighItal ISO1252Encoding psp_definefont /URWBookmanL-DemiBoldItal-iso1252 /URWBookmanL-DemiBoldItal ISO1252Encoding psp_definefont /CharterBT-Bold-iso1252 /CharterBT-Bold ISO1252Encoding psp_definefont /CharterBT-BoldItalic-iso1252 /CharterBT-BoldItalic ISO1252Encoding psp_definefont /CharterBT-Roman-iso1252 /CharterBT-Roman ISO1252Encoding psp_definefont /CharterBT-Italic-iso1252 /CharterBT-Italic ISO1252Encoding psp_definefont /CenturySchL-Roma-iso1252 /CenturySchL-Roma ISO1252Encoding psp_definefont /CenturySchL-Bold-iso1252 /CenturySchL-Bold ISO1252Encoding psp_definefont /CenturySchL-Ital-iso1252 /CenturySchL-Ital ISO1252Encoding psp_definefont /CenturySchL-BoldItal-iso1252 /CenturySchL-BoldItal ISO1252Encoding psp_definefont /NimbusSanL-Regu-iso1252 /NimbusSanL-Regu ISO1252Encoding psp_definefont /NimbusSanL-Bold-iso1252 /NimbusSanL-Bold ISO1252Encoding psp_definefont /NimbusSanL-ReguItal-iso1252 /NimbusSanL-ReguItal ISO1252Encoding psp_definefont /NimbusSanL-BoldItal-iso1252 /NimbusSanL-BoldItal ISO1252Encoding psp_definefont /NimbusSanL-ReguCond-iso1252 /NimbusSanL-ReguCond ISO1252Encoding psp_definefont /NimbusSanL-BoldCond-iso1252 /NimbusSanL-BoldCond ISO1252Encoding psp_definefont /NimbusSanL-ReguCondItal-iso1252 /NimbusSanL-ReguCondItal ISO1252Encoding psp_definefont /NimbusSanL-BoldCondItal-iso1252 /NimbusSanL-BoldCondItal ISO1252Encoding psp_definefont /NimbusRomNo9L-Regu-iso1252 /NimbusRomNo9L-Regu ISO1252Encoding psp_definefont /NimbusRomNo9L-Medi-iso1252 /NimbusRomNo9L-Medi ISO1252Encoding psp_definefont /NimbusRomNo9L-ReguItal-iso1252 /NimbusRomNo9L-ReguItal ISO1252Encoding psp_definefont /NimbusRomNo9L-MediItal-iso1252 /NimbusRomNo9L-MediItal ISO1252Encoding psp_definefont /NimbusMonL-Regu-iso1252 /NimbusMonL-Regu ISO1252Encoding psp_definefont /NimbusMonL-Bold-iso1252 /NimbusMonL-Bold ISO1252Encoding psp_definefont /NimbusMonL-ReguObli-iso1252 /NimbusMonL-ReguObli ISO1252Encoding psp_definefont /NimbusMonL-BoldObli-iso1252 /NimbusMonL-BoldObli ISO1252Encoding psp_definefont /URWPalladioL-Roma-iso1252 /URWPalladioL-Roma ISO1252Encoding psp_definefont /URWPalladioL-Bold-iso1252 /URWPalladioL-Bold ISO1252Encoding psp_definefont /URWPalladioL-Ital-iso1252 /URWPalladioL-Ital ISO1252Encoding psp_definefont /URWPalladioL-BoldItal-iso1252 /URWPalladioL-BoldItal ISO1252Encoding psp_definefont /URWAntiquaT-RegularCondensed-iso1252 /URWAntiquaT-RegularCondensed ISO1252Encoding psp_definefont /URWGroteskT-Bold-iso1252 /URWGroteskT-Bold ISO1252Encoding psp_definefont /URWChanceryL-MediItal-iso1252 /URWChanceryL-MediItal ISO1252Encoding psp_definefont /Times-Bold-iso1252 /Times-Bold ISO1252Encoding psp_definefont /Times-BoldItalic-iso1252 /Times-BoldItalic ISO1252Encoding psp_definefont /Times-Italic-iso1252 /Times-Italic ISO1252Encoding psp_definefont /Times-Roman-iso1252 /Times-Roman ISO1252Encoding psp_definefont /Helvetica-iso1252 /Helvetica ISO1252Encoding psp_definefont /Helvetica-Bold-iso1252 /Helvetica-Bold ISO1252Encoding psp_definefont /Helvetica-Oblique-iso1252 /Helvetica-Oblique ISO1252Encoding psp_definefont /Courier-iso1252 /Courier ISO1252Encoding psp_definefont /Courier-Bold-iso1252 /Courier-Bold ISO1252Encoding psp_definefont /Courier-BoldOblique-iso1252 /Courier-BoldOblique ISO1252Encoding psp_definefont /Courier-Oblique-iso1252 /Courier-Oblique ISO1252Encoding psp_definefont %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Maßstab der Zeichnung /massstab {1} def % 1:1 - hierbei entspricht "1 Pixel" genau "1 mm" %/massstab {2} def % 1:2 - hierbei entsprechen "2 Pixel" genau "1 mm" %/massstab {3} def % 1:3 - hierbei entsprechen "3 Pixel" genau "1 mm" /mm {massstab mul} def % damit alles automatisch im richtien Maßstab angezeigt wird %72 25.4 div massstab div dup scale % 72 DPI (allgemeiner Standard) 127 25.4 div massstab div dup scale % 127 DPI %254 25.4 div massstab div dup scale % 254 DPI %381 25.4 div massstab div dup scale % 381 DPI %508 25.4 div massstab div dup scale % 508 DPI /Helvetica-iso1252 findfont % Schriftart in voller Größe %/Times-Roman-iso1252 findfont % Schriftart etwas kleiner mit Serifen %/Courier-iso1252 findfont % Schriftart mit fester Breite %/Courier-Oblique-iso1252 findfont % Schriftart mit fester Breite in Kursiv 5 mm scalefont setfont % Schriftgröße in Millimeter, damit sie nie skaliert und immer lesbar ist 0 setgray % Farbe (0=schwarz / 0.5=grau / 1=weiss) %0 setlinejoin % die Spitze eines Winkels wird spitz gezeichnet %1 setlinejoin % die Spitze eines Winkels wird abgerundet gezeichnet %2 setlinejoin % die Spitze eines Winkels wird abgeflacht gezeichnet /p-rand-links {10 mm} def /n-rand-links {p-rand-links neg} def /p-rand-unten {13 mm} def /n-rand-unten {p-rand-unten neg} def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %==============================================================================% newpath % neue Zeichnung beginnen .3 setlinewidth % Linienbreite %------------------------------------------------------------------------------% %%% Umrandung p-rand-links p-rand-unten moveto % Rahmen in Millimeter p-rand-links 284 mm lineto % Rahmen in Millimeter 200 mm 284 mm lineto % Rahmen in Millimeter 200 mm p-rand-unten lineto % Rahmen in Millimeter p-rand-links p-rand-unten lineto % Rahmen in Millimeter %------------------------------------------------------------------------------% %%% Legende p-rand-links 2 mm add p-rand-unten 2 mm add moveto % zur Startposition der Ausgabe gehen / in Millimeter auf dem Blatt, unabhängig von der Skalierung (Maßstab: 1:) show massstab 2 string cvs show % "2 string" bedutet, dass in "i" ein String mit 2 Zeichen steckt (das kann auch größer angegeben werden) %------------------------------------------------------------------------------% %%% Umlaute & Sonderzeichen 105 mm p-rand-unten 7 mm add moveto % zur Startposition der Ausgabe gehen / in Millimeter auf dem Blatt, unabhängig von der Skalierung (Umlaute: Ää Öö Üü) show % Umlaute 105 mm p-rand-unten 2 mm add moveto % zur Startposition der Ausgabe gehen / in Millimeter auf dem Blatt, unabhängig von der Skalierung (Sonderzeichen: & ß € µ é è ¹ ² ³ ¼ ½) show % Sonderzeichen %------------------------------------------------------------------------------% closepath % diese Zeichnung beenden stroke % alle aufgeführten Zeichenkomandos jetzt zeichnen %==============================================================================% newpath % neue Zeichnung beginnen % Kreis zeichnen - mit Millimeterangeben, dann skaliert die Größe NICHT mit dem Maßstab 150 mm 210 mm moveto % zur 3-Uhr-Position vom Kreis gehen 100 mm 210 mm 50 mm 0 360 arc % einen Vollkreis, links rum zeichnen % 3-Uhr-Position des Kreises: 150 mm von links und 210 mm von unten % Mittelpunkt des Kreises: 100 mm von links und 210 mm von unten % Radius vom Kreis: 50 mm % Startposition, um den Kreis zu zeichnen: 0° % Kreisbogen, der gezeichnet werden soll: 360° (links rum) closepath % diese Zeichnung beenden %------------------------------------------------------------------------------% %%% Füllen - Anfang gsave % Grafic-Save (sichern) 0.5 setgray % Füllfarbe festlegen fill % geschlossenes Objekt, in dieser Zeichnung, ausfüllen grestore % Grafic-Restore (zurückholen) %4 setlinewidth %0.75 setgray %%% Füllen - Ende %------------------------------------------------------------------------------% stroke % alle aufgeführten Zeichenkomandos jetzt ausführen %==============================================================================% newpath % neue Zeichnung beginnen .2 setlinewidth % Linienbreite % Viereck zeichnen - ohne Millimeterangeben, dann skaliert die Größe mit dem Maßstab 100 100 moveto % gehe zum Startpunkt 0 50 rlineto % zeichne eine Linie nach oben 50 0 rlineto % zeichne eine Linie nach rechts 0 -50 rlineto % zeichne eine Linie nach unten -50 0 rlineto % zeichne eine Linie nach links closepath % diese Zeichnung beenden %------------------------------------------------------------------------------% %%% Füllen - Anfang % Viereck ausfüllen gsave % Grafic-Save (sichern) 0.75 setgray % Füllfarbe festlegen fill % geschlossenes Objekt, in dieser Zeichnung, ausfüllen grestore % Grafic-Restore (zurückholen) %%% Füllen - Ende %------------------------------------------------------------------------------% stroke % alle aufgeführten Zeichenkomandos jetzt ausführen %==============================================================================% newpath % neue Zeichnung beginnen .1 setlinewidth % Linienbreite % 3 ineinander liegende Kreise zeichnen - ohne Millimeterangeben, dann skaliert die Größe mit dem Maßstab % 1. Kreis - größter, ganz außen 125 100 moveto % zur 3-Uhr-Position vom Kreis gehen 100 100 25 0 360 arc % einen Vollkreis, links rum zeichnen % 2. Kreis - mittlerer, in der Mitte 124.5 100 moveto % zur 3-Uhr-Position vom Kreis gehen 100 100 24.5 0 360 arc % einen Vollkreis, links rum zeichnen % 3. Kreis - kleinster, innen 124 100 moveto % zur 3-Uhr-Position vom Kreis gehen 100 100 24 0 360 arc % einen Vollkreis, links rum zeichnen closepath % diese Zeichnung beenden %------------------------------------------------------------------------------% %------------------------------------------------------------------------------% stroke % alle aufgeführten Zeichenkomandos jetzt ausführen %==============================================================================% showpage % Ausgabe der fertigen Seite
