1 package SL::Template::HTML;
3 use SL::Template::LaTeX;
6 @ISA = qw(SL::Template::LaTeX);
13 return $type->SUPER::new(@_);
17 my ($self, $variable) = @_;
18 my $form = $self->{"form"};
20 $variable = $main::locale->quote_special_chars('Template/HTML', $variable);
22 # Allow some HTML markup to be converted into the output format's
23 # corresponding markup code, e.g. bold or italic.
24 my @markup_replace = ('b', 'i', 's', 'u', 'sub', 'sup');
26 foreach my $key (@markup_replace) {
27 $variable =~ s/\<(\/?)${key}\>/<$1${key}>/g;
36 if ($self->{"form"}->{"format"} =~ /postscript/i) {
37 return "application/postscript";
38 } elsif ($self->{"form"}->{"format"} =~ /pdf/i) {
39 return "application/pdf";
48 if ($self->{"form"}->{"format"} =~ /postscript/i) {
50 } elsif ($self->{"form"}->{"format"} =~ /pdf/i) {
57 sub convert_to_postscript {
59 my ($form, $userspath) = ($self->{"form"}, $self->{"userspath"});
61 # Convert the HTML file to postscript
63 if (!chdir("$userspath")) {
64 $self->{"error"} = "chdir : $!";
69 $form->{"tmpfile"} =~ s/\Q$userspath\E\///g;
70 my $psfile = $form->{"tmpfile"};
71 $psfile =~ s/.html/.ps/;
72 if ($psfile eq $form->{"tmpfile"}) {
76 system("html2ps -f html2ps-config < $form->{tmpfile} > $psfile");
78 $self->{"error"} = $form->cleanup();
83 $form->{"tmpfile"} = $psfile;
92 my ($form, $userspath) = ($self->{"form"}, $self->{"userspath"});
94 # Convert the HTML file to PDF
96 if (!chdir("$userspath")) {
97 $self->{"error"} = "chdir : $!";
102 $form->{"tmpfile"} =~ s/\Q$userspath\E\///g;
103 my $pdffile = $form->{"tmpfile"};
104 $pdffile =~ s/.html/.pdf/;
105 if ($pdffile eq $form->{"tmpfile"}) {
109 system("html2ps -f html2ps-config < $form->{tmpfile} | ps2pdf - $pdffile");
111 $self->{"error"} = $form->cleanup();
116 $form->{"tmpfile"} = $pdffile;