Newsgroup: it.comp.software.tex
Titolo: pdx2ps

Visto che parlavate di Mayura Draw, ho qui uno script Perl che
converte i file generati dal programma (formato pdx piu' o meno
equivalente a un EPS) in (plain) Postscript.
Credo si trovi facilmente in rete, ma essendo breve, lo posto:
Scusate l'impaginazione barbara, ma cosi' e' memorizzato!
| #!/usr/local/bin/perl # # pdx2ps - convert pdx file to a plain postscript
| template # this assumes tokens are identified by the characters "pdx-"
| before their names # # Peter Bisset # Fri Mar 20 08:11:06 EST 1998 #
| $USAGE = "usage: $0 [-i input-file] [-o output-file]\n"; # get args and
| check usage while(@ARGV) { $_ = shift; if (/^--$/) { break; } if (/^-i$/)
| { $opt_i = shift; next; } if (/^-o$/) { $opt_o = shift; next; } die "$0:
| option $_ not understood\n${USAGE}" } if ($opt_i) { $input_file = $opt_i;
| } else { die $USAGE; } if ($opt_o) { $output_file = $opt_o; } else { die
| $USAGE; } $tail_file = "/tmp/.pdxtail$$"; # temp file to hold main
| document $head_file = "/tmp/.pdxhead$$"; # temp file to hold header
| open(PDX,$input_file) || die "Cannot read $input_file\n"; open(HEAD, ">
| $head_file") || die "Cannot create temp file: $head_file\n"; open(TAIL, ">
| $tail_file") || die "Cannot open temp file: $tail_file\n"; while () { #
| Font names used by mdraw are different to standard ps font names if
| (/^WinAnsiEncoding.*/) { s/ArialMT RE/Helvetica RE/; s/Arial-BoldMT
| RE/Helvetica-Bold RE/; s/Arial-ItalicMT RE/Helvetica-Oblique RE/;
| s/Arial-BoldItalicMT RE/Helvetica-Bold-Oblique RE/; s/CourierNewPSMT
| RE/Courier RE/; s/CourierNewPS-BoldMT RE/Courier-Bold RE/;
| s/CourierNewPS-ItalicMT RE/Courier-Oblique RE/;
| s/CourierNewPS-BoldItalicMT RE/Courier-Bold-Oblique RE/;
| s/TimesNewRomanPSMT RE/Times-Roman RE/; s/TimesNewRomanPS-BoldMT
| RE/Times-Bold RE/; s/TimesNewRomanPS-BoldItalicMT RE/Times-BoldItalic RE/;
| s/TimesNewRomanPS-ItalicMT RE/Times-Italic RE/; s/BookmanOldStyle-Italic
| RE/Bookman-Light-Italic RE/; s/Wingdings-Regular RE/ZapfDingbats RE/; }
| print HEAD; if (/^%%Copyright:/) { # This next line is needed to tell the
| printer that we are using # A4. The drawing package doesn't put any
| commands in to select # select paper size even though the page setup of
| the drawing does. # The figures are simply the number of points (72 per
| inch). print HEAD "<> setpagedevice\n"; } if (/%%EndPageSetup/) { #
| produce reset-names procedure print HEAD "/reset-names { \%def\n"; #
| produce display-page procedure print TAIL "\n/display-page { \%def\n";
| last; } } # Use two loops because we change where $_ goes in each one. #
| The rest of the file is converted into two procedures. The first one is #
| called reset-names and this pushes onto the dictionary stack blank values
| # for all the tokens used on the page. This allows the Progress procedure
| # to just produce the tokens needed, rather than having to output every
| one. # In order to do this we have to get all the tokens, write them to
| the end of # HEAD in the reset-names procedure. Using an array means that
| we can then get # the unique names only. # The second procedure is just
| the code that draws the blank form on the page. # Doing this allows the
| printing of multiple pages without the need to resend # a pile of
| postscript. while () { # DSC says this goes at end of each page if
| (/%%PageTrailer/) { last; } if (/^\(pdx-(.*)\) t$/) { # find matching
| lines print TAIL "$1 t\n"; # the converted line - name t # $placeholders
| keeps track of what has been seen - avoid duplicates # just print the name
| definition print HEAD "\t/$1 () def\n" unless $placeholders{$1}++; } else
| { print TAIL; # print every other line except the converted ones } } #
| close reset-names procedure definition and include the message for
| printing # on the top of the page print HEAD "\t/message (VOID) def\n} def
| \% end of reset-names\n\n"; # now add proc to print void message. This
| works by getting a large font # and printing just the outline of the font.
| We do this at the end of # display-page so it overwrites anything on the
| page. print HEAD "/print-wm { gsave /Times-Roman findfont 200 scalefont
| setfont 1 setlinewidth 0 setgray newpath 50 100 moveto message true
| charpath stroke grestore } def \% end of print-wm\n"; # close display-page
| procedure definition, but add overlay message call print TAIL
| "\nprint-wm\n} def \% end of display-page\n"; close TAIL; close HEAD;
| close PDX; # now create combined file system "cat $head_file $tail_file >
| $output_file" || die "Unable to create $output_file\n"; unlink $head_file,
| $tail_file; 
Byez
un DeK con la faccia da PERL
-- 
DeK - Delirio & Kaos
FAN n.1 del CrossPost e dell' OT :)
Visita One Big Mob - 
http://dek.hey.to
 [
http://dek.interfree.it
]

 
[snippato]
Nella maniera postata non č utilizzabile, poiché sono spariti gli 
acapo ed i commenti finiscono con il diventare comandi. Probabilmente 
un erroro di terminatori di linea (sembrerebbe terminatori Unix su un 
sistema MS o Mac).
-- 
Giuseppe "Oblomov" Bilotta
Axiom I of the Giuseppe Bilotta
theory of IT:
Anything is better than MS

acapo ed i commenti finiscono con il diventare comandi.
Sorry... Software troppo zelanti...
Ho ritrovato l'URLo comunque:
| 
http://www.fast4gl.com/downloads/pdx2ps
Byez
un DeK feroce
