summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2004-01-11 23:59:24 +0000
committerivan <ivan>2004-01-11 23:59:24 +0000
commitd173866aa911877663c3350dbedff2413b1cd5d3 (patch)
treefc7e5d941b12781e6007ff2bb06b386ef9f35b6b
parentc56c1d651c6384fdc7d7bf8909061f3b0cd0b26a (diff)
typeset invoice view in web UI uses pdf instead of postscript, closes Bug#614
-rw-r--r--FS/FS/cust_bill.pm84
-rwxr-xr-xhttemplate/view/cust_bill.cgi2
2 files changed, 76 insertions, 10 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 3f4166d4e..cde1853c0 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1280,9 +1280,12 @@ sub print_text {
}
-=item print_ps [ TIME [ , TEMPLATE ] ]
+=item print_latex [ TIME [ , TEMPLATE ] ]
-Returns an postscript invoice, as a scalar.
+Internal method - returns a filename of a filled-in LaTeX template for this
+invoice (Note: add ".tex" to get the actual filename).
+
+See print_ps and print_pdf for methods that return PostScript and PDF output.
TIME an optional value used to control the printing of overdue messages. The
default is now. It isn't the date of the invoice; that's the `_date' field.
@@ -1292,7 +1295,7 @@ L<Time::Local> and L<Date::Parse> for conversion functions.
=cut
#still some false laziness w/print_text
-sub print_ps {
+sub print_latex {
my( $self, $today, $template ) = @_;
$today ||= time;
@@ -1462,17 +1465,37 @@ sub print_ps {
print TEX join("\n", @filled_in ), "\n";
close TEX;
+ return $file;
+
+}
+
+=item print_ps [ TIME [ , TEMPLATE ] ]
+
+Returns an postscript invoice, as a scalar.
+
+TIME an optional value used to control the printing of overdue messages. The
+default is now. It isn't the date of the invoice; that's the `_date' field.
+It is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
+L<Time::Local> and L<Date::Parse> for conversion functions.
+
+=cut
+
+sub print_ps {
+ my $self = shift;
+
+ my $file = $self->print_latex(@_);
+
#error checking!!
system('pslatex', "$file.tex");
system('pslatex', "$file.tex");
- #system('dvips', '-t', 'letter', "$file.dvi", "$file.ps");
- system('dvips', '-t', 'letter', "$file.dvi", '-o', "$file.ps" );
+ system('dvips', '-q', '-t', 'letter', "$file.dvi", '-o', "$file.ps" );
- open(POSTSCRIPT, "<$file.ps") or die "can't open $file.ps (probable error in LaTeX template): $!\n";
+ open(POSTSCRIPT, "<$file.ps")
+ or die "can't open $file.ps (probable error in LaTeX template): $!\n";
#rm $file.dvi $file.log $file.aux
- #unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps");
- unlink("$file.dvi", "$file.log", "$file.aux");
+ unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps");
+ #unlink("$file.dvi", "$file.log", "$file.aux");
my $ps = '';
while (<POSTSCRIPT>) {
@@ -1485,7 +1508,50 @@ sub print_ps {
}
-# quick subroutine for print_ps
+=item print_pdf [ TIME [ , TEMPLATE ] ]
+
+Returns an PDF invoice, as a scalar.
+
+TIME an optional value used to control the printing of overdue messages. The
+default is now. It isn't the date of the invoice; that's the `_date' field.
+It is specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
+L<Time::Local> and L<Date::Parse> for conversion functions.
+
+=cut
+
+sub print_pdf {
+ my $self = shift;
+
+ my $file = $self->print_latex(@_);
+
+ #system('pdflatex', "$file.tex");
+ #system('pdflatex', "$file.tex");
+ #! LaTeX Error: Unknown graphics extension: .eps.
+
+ #error checking!!
+ system('pslatex', "$file.tex");
+ system('pslatex', "$file.tex");
+
+ #system('dvipdf', "$file.dvi", "$file.pdf" );
+ system("dvips -q -t letter -f $file.dvi | gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$file.pdf -c save pop -");
+
+ open(PDF, "<$file.pdf")
+ or die "can't open $file.pdf (probably error in LaTeX tempalte: $!\n";
+
+ unlink("$file.dvi", "$file.log", "$file.aux", "$file.pdf");
+
+ my $pdf = '';
+ while (<PDF>) {
+ $pdf .= $_;
+ }
+
+ close PDF;
+
+ return $pdf;
+
+}
+
+# quick subroutine for print_latex
#
# There are ten characters that LaTeX treats as special characters, which
# means that they do not simply typeset themselves:
diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi
index ddc92748d..4e0c4383b 100755
--- a/httemplate/view/cust_bill.cgi
+++ b/httemplate/view/cust_bill.cgi
@@ -23,7 +23,7 @@ print qq!<A HREF="${p}edit/cust_pay.cgi?$invnum">Enter payments (check/cash) aga
print qq!<A HREF="${p}misc/print-invoice.cgi?$invnum">Reprint this invoice</A>!. '<BR><BR>';
print menubar(
- 'View typeset invoice' => "${p}view/cust_bill-ps.cgi?$invnum",
+ 'View typeset invoice' => "${p}view/cust_bill-pdf.cgi?$invnum",
), '<BR><BR>';
#false laziness with search/cust_bill_event.cgi