1 package SL::Template::HTML;
3 use parent qw(SL::Template::LaTeX);
10 return $type->SUPER::new(@_);
14 my ($self, $variable) = @_;
15 my $form = $self->{"form"};
17 $variable = $main::locale->quote_special_chars('Template/HTML', $variable);
19 # Allow some HTML markup to be converted into the output format's
20 # corresponding markup code, e.g. bold or italic.
21 my @markup_replace = ('b', 'i', 's', 'u', 'sub', 'sup');
23 foreach my $key (@markup_replace) {
24 $variable =~ s/\<(\/?)${key}\>/<$1${key}>/g;
33 if ($self->{"form"}->{"format"} =~ /postscript/i) {
34 return "application/postscript";
35 } elsif ($self->{"form"}->{"format"} =~ /pdf/i) {
36 return "application/pdf";
45 if ($self->{"form"}->{"format"} =~ /postscript/i) {
47 } elsif ($self->{"form"}->{"format"} =~ /pdf/i) {
54 sub convert_to_postscript {
56 my ($form, $userspath) = ($self->{"form"}, $self->{"userspath"});
58 # Convert the HTML file to postscript
60 if (!chdir("$userspath")) {
61 $self->{"error"} = "chdir : $!";
66 $form->{"tmpfile"} =~ s/\Q$userspath\E\///g;
67 my $psfile = $form->{"tmpfile"};
68 $psfile =~ s/.html/.ps/;
69 if ($psfile eq $form->{"tmpfile"}) {
73 if (system($::lx_office_conf{applications}->{html2ps} . " -f html2ps-config < $form->{tmpfile} > $psfile") == -1) {
74 die "system call to $::lx_office_conf{applications}->{html2ps} failed: $!";
77 $self->{"error"} = $form->cleanup($::lx_office_conf{applications}->{html2ps});
81 $form->{"tmpfile"} = $psfile;
90 my ($form, $userspath) = ($self->{"form"}, $self->{"userspath"});
92 # Convert the HTML file to PDF
94 if (!chdir("$userspath")) {
95 $self->{"error"} = "chdir : $!";
100 $form->{"tmpfile"} =~ s/\Q$userspath\E\///g;
101 my $pdffile = $form->{"tmpfile"};
102 $pdffile =~ s/.html/.pdf/;
103 if ($pdffile eq $form->{"tmpfile"}) {
107 if (system($::lx_office_conf{applications}->{html2ps} . " -f html2ps-config < $form->{tmpfile} | ps2pdf - $pdffile") == -1) {
108 die "system call to $::lx_office_conf{applications}->{html2ps} failed: $!";
111 $self->{"error"} = $form->cleanup($::lx_office_conf{applications}->{html2ps});
115 $form->{"tmpfile"} = $pdffile;