#!/usr/bin/perl -s ### NOT IN DISTRO our ($m,$o,$v); $m ||= 1000; my $tmx=shift or die("usage:\n\t$0 file.tmx\n"); my $tmp=$o; my @u=(); ## unlink list unless($o){ if($tmx =~ /(.*\/)?(.*).tmx$/){$tmp = "${1}__$2.pdf"} else {$tmp = "/tmp/_tmxpdf_$$_.pdf"; # @u=($tmp); } } use strict; if(not -d "$ENV{HOME}/.gwb"){ mkdir("$ENV{HOME}/.gwb"); } if(not -f "$ENV{HOME}/.gwb/tmx.css"){ open(F,">","$ENV{HOME}/.gwb/tmx.css") or die("cant create'$ENV{HOME}/.gwb/tmx.css'\n"); while(){ last if /END/; print F $_} close F; } system("prince -s $ENV{HOME}/.gwb/tmx.css '$tmx' -o '$tmp' 2> /dev/null"); if($v){ system("xpdf -z width -cont -g 1500x1050 '$tmp'")} ; unlink (@u); __DATA__ @charset "UTF-8"; prop { display: none; } tu { display: block; border-top: solid red 1px; padding: 2pt; counter-increment: num; page-break-inside: avoid; columns:2; } tuv { display: block; page-break-inside: avoid; margin-bottom: 4pt; } tuv {color:orange; font-size:70% ; } /* tuv:lang(pt) {color:olive; } */ tuv:lang(pt) {color:LightSeaGreen; } tuv:lang(pt_pt){color:LightSeaGreen; } tuv:lang(pt-pt){color:LightSeaGreen; } tuv:lang(PT_PT){color:LightSeaGreen; } tuv:lang(PT-PT){color:LightSeaGreen; } tuv:lang(en) {color:DarkCyan; } tuv:lang(fr) {color:OrangeRed; } strong, emph, b { font-weight: bold; } tuv::before {color: black; font-size:70%; } tuv[lang]::before { content:counter(num) " " attr(lang) " "; } tuv[xml\:lang]::before { content:counter(num) " " attr(xml\:lang) " "; } tuv:lang(pt)::before { content:counter(num) " PT "; } tuv:lang(en)::before { content:counter(num) " EN "; } tuv:lang(es)::before { content:counter(num) " ES "; } tuv:lang(fr)::before { content:counter(num) " FR "; } tuv:lang(de)::before { content:counter(num) " DE "; } tuv:lang(en_GB)::before { content:counter(num) " EN "; } tuv:lang(en_US)::before { content:counter(num) " EN "; } seg { } header{ display:none; } @page{ margin: 10mm 10mm 10mm 10mm; columns:2; size:A4; } @screen{ margin: 8mm 8mm 8mm 8mm; columns:2; size:screen; } /* END */ =head1 NAME tmx2pdf-prince - convert TMX files to PDF =head1 SYNOPSIS tmx2pdf-prince file.tmx tmx2pdf-prince -v file.tmx =head1 DESCRIPTION =head2 Options -v show generated PDF -m=20 just process first 20 lines -o=file.pdf define outour file (def: "__file.pdf") =head2 Dependencies C converter must be installed xpdf =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). prince xpdf =cut