[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Silencing output from pstopdf for use in LedgerSMB/Form.pm?



Jeff Kowalczyk wrote:
I needed to use pst-barcode in Latex templates with branches/1.2.

Per pstricks documentation, pdflatex alone will not work. The latex,
dvips, pstopdf workflow is required.

Fortunately, this leads to a small de-duplication of code, see[1].

However, the texlive-packaged pstopdf apparently lacks a quiet output
mode, causing error[2]. Appending " > /dev/null" wasn't working for me,
that probably redirected the output pdf.

I worked around it by using the ghostscript-packaged ps2pdf utility, which
works fine with the single argument and doesn't create a dependency
problem for me personally, but it could be avoided.

If anyone has an idea to silence or ignore pstopdf output in the system()
call, perhaps this would be good commit to branches/1.2 and trunk,
facilitating use of additional advanced-graphics CTAN packages.

How about using -o and -l? -o output filename (otherwise it is munged from the input filename) and -l specifies that any messages generated
during file conversion be written to a log file (/dev/null).

Untested.  Just a theory.


Rod
--

Let me know if I should commit a variation of [1].

[1] LedgerSMB/Form.pm |   37 ++++++++++++++-----------------------
    1 files changed, 14 insertions(+), 23 deletions(-)

  diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
  index 85aec60..192ea06 100755
  --- a/LedgerSMB/Form.pm
  +++ b/LedgerSMB/Form.pm
  @@ -971,40 +971,31 @@ sub parse_template {
           $self->{errfile} =~ s/tex$/err/;
my $r = 1;
  -        if ( $self->{format} eq 'postscript' ) {
- system(
  +        system(
   "latex --interaction=nonstopmode $self->{tmpfile} > $self->{errfile}"
               );
- while ( $self->rerun_latex ) {
  -                system(
  +        while ( $self->rerun_latex ) {
  +            system(
   "latex --interaction=nonstopmode $self->{tmpfile} > $self->{errfile}"
                   );
  -                last if ++$r > 4;
  -            }
  +            last if ++$r > 4;
  +        }
- $self->{tmpfile} =~ s/tex$/dvi/;
  -            $self->error( $self->cleanup ) if !( -f $self->{tmpfile} );
  +        $self->{tmpfile} =~ s/tex$/dvi/;
  +        $self->error( $self->cleanup ) if !( -f $self->{tmpfile} );
- system("dvips $self->{tmpfile} -o -q");
  -            $self->error( $self->cleanup . "dvips : $!" ) if ($?);
  -            $self->{tmpfile} =~ s/dvi$/ps/;
  -        }
  +        system("dvips $self->{tmpfile} -o -q");
  +        $self->error( $self->cleanup . "dvips : $!" ) if ($?);
  +        $self->{tmpfile} =~ s/dvi$/ps/;
+ # convert postscript to pdf
           if ( $self->{format} eq 'pdf' ) {
  -            system(
  -"pdflatex --interaction=nonstopmode $self->{tmpfile} > $self->{errfile}"
  -            );
  -
  -            while ( $self->rerun_latex ) {
  -                system(
  -"pdflatex --interaction=nonstopmode $self->{tmpfile} > $self->{errfile}"
  -                );
  -                last if ++$r > 4;
  -            }
- $self->{tmpfile} =~ s/tex$/pdf/;
  +            system("ps2pdf $self->{tmpfile}");
  +            $self->error( $self->cleanup . "ps2pdf :$!" ) if ($?);
  +            $self->{tmpfile} =~ s/ps$/pdf/;
               $self->error( $self->cleanup ) if !( -f $self->{tmpfile} );
           }
       }



[2] malformed header from script.
    Bad header=PsToPdf | converting ps (ps) i: is.pl




------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Ledger-smb-devel mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel