8 |
8 |
use Cwd;
|
9 |
9 |
use English qw(-no_match_vars);
|
10 |
10 |
use File::Basename;
|
|
11 |
use File::Path;
|
|
12 |
use File::Spec;
|
11 |
13 |
use File::Temp;
|
12 |
14 |
use HTML::Entities ();
|
13 |
15 |
use List::MoreUtils qw(any);
|
... | ... | |
532 |
534 |
return join(':', grep({ $_ } ('.', $exe_dir . '/texmf', $exe_dir . '/users', $templates_path, $ENV{TEXINPUTS})), '');
|
533 |
535 |
}
|
534 |
536 |
|
|
537 |
sub _setup_env {
|
|
538 |
my ($self) = @_;
|
|
539 |
|
|
540 |
my $userspath = $::lx_office_conf{paths}->{userspath};
|
|
541 |
$ENV{openin_any} = "r";
|
|
542 |
$ENV{TEXINPUTS} = $self->_texinputs_path($self->{form}->{templates});
|
|
543 |
$ENV{TEXMFHOME} = File::Spec->rel2abs($userspath . "/texmf", SL::System::Process::exe_dir());
|
|
544 |
$ENV{TEXMFVAR} = $ENV{TEXMFHOME} . "/var";
|
|
545 |
|
|
546 |
File::Path::make_path($ENV{TEXMFVAR});
|
|
547 |
}
|
|
548 |
|
535 |
549 |
sub convert_to_postscript {
|
536 |
550 |
my ($self) = @_;
|
537 |
551 |
my ($form, $userspath) = ($self->{"form"}, $self->{"userspath"});
|
538 |
552 |
|
539 |
553 |
# Convert the tex file to postscript
|
540 |
|
local $ENV{TEXINPUTS} = $self->_texinputs_path($form->{templates});
|
|
554 |
local ($ENV{TEXINPUTS}, $ENV{TEXMFHOME}, $ENV{TEXMFVAR}, $ENV{openin_any});
|
|
555 |
$self->_setup_env;
|
541 |
556 |
|
542 |
557 |
if (!chdir("$userspath")) {
|
543 |
558 |
$self->{"error"} = "chdir : $!";
|
... | ... | |
548 |
563 |
$form->{tmpfile} =~ s/\Q$userspath\E\///g;
|
549 |
564 |
|
550 |
565 |
my $latex = $self->_get_latex_path();
|
551 |
|
my $old_home = $ENV{HOME};
|
552 |
|
my $old_openin_any = $ENV{openin_any};
|
553 |
|
$ENV{HOME} = $userspath =~ m|^/| ? $userspath : getcwd();
|
554 |
|
$ENV{openin_any} = "r";
|
555 |
566 |
|
556 |
567 |
for (my $run = 1; $run <= 2; $run++) {
|
557 |
568 |
if (system("${latex} --interaction=nonstopmode $form->{tmpfile} " .
|
... | ... | |
559 |
570 |
die "system call to $latex failed: $!";
|
560 |
571 |
}
|
561 |
572 |
if ($?) {
|
562 |
|
$ENV{HOME} = $old_home;
|
563 |
|
$ENV{openin_any} = $old_openin_any;
|
564 |
573 |
$self->{"error"} = $form->cleanup($latex);
|
565 |
574 |
return 0;
|
566 |
575 |
}
|
... | ... | |
571 |
580 |
if (system("dvips $form->{tmpfile} -o -q > /dev/null") == -1) {
|
572 |
581 |
die "system call to dvips failed: $!";
|
573 |
582 |
}
|
574 |
|
$ENV{HOME} = $old_home;
|
575 |
|
$ENV{openin_any} = $old_openin_any;
|
576 |
583 |
|
577 |
584 |
if ($?) {
|
578 |
585 |
$self->{"error"} = "dvips : $?";
|
... | ... | |
591 |
598 |
my ($form, $userspath) = ($self->{"form"}, $self->{"userspath"});
|
592 |
599 |
|
593 |
600 |
# Convert the tex file to PDF
|
594 |
|
local $ENV{TEXINPUTS} = $self->_texinputs_path($form->{templates});
|
|
601 |
local ($ENV{TEXINPUTS}, $ENV{TEXMFHOME}, $ENV{TEXMFVAR}, $ENV{openin_any});
|
|
602 |
$self->_setup_env;
|
595 |
603 |
|
596 |
604 |
if (!chdir("$userspath")) {
|
597 |
605 |
$self->{"error"} = "chdir : $!";
|
... | ... | |
602 |
610 |
$form->{tmpfile} =~ s/\Q$userspath\E\///g;
|
603 |
611 |
|
604 |
612 |
my $latex = $self->_get_latex_path();
|
605 |
|
my $old_home = $ENV{HOME};
|
606 |
|
my $old_openin_any = $ENV{openin_any};
|
607 |
|
$ENV{HOME} = $userspath =~ m|^/| ? $userspath : getcwd();
|
608 |
|
$ENV{openin_any} = "r";
|
609 |
613 |
|
610 |
614 |
for (my $run = 1; $run <= 2; $run++) {
|
611 |
615 |
if (system("${latex} --interaction=nonstopmode $form->{tmpfile} " .
|
... | ... | |
614 |
618 |
}
|
615 |
619 |
|
616 |
620 |
if ($?) {
|
617 |
|
$ENV{HOME} = $old_home;
|
618 |
|
$ENV{openin_any} = $old_openin_any;
|
619 |
621 |
$self->{error} = $form->cleanup($latex);
|
620 |
622 |
return 0;
|
621 |
623 |
}
|
622 |
624 |
}
|
623 |
625 |
|
624 |
|
$ENV{HOME} = $old_home;
|
625 |
|
$ENV{openin_any} = $old_openin_any;
|
626 |
626 |
$form->{tmpfile} =~ s/tex$/pdf/;
|
627 |
627 |
|
628 |
628 |
$self->cleanup();
|
LaTeX: TeX-Var-Verzeichnis permanent im users-Verzeichnis belassen
Bisher lag es bei PDF-Erzeugung im temporären Verzeichnis
users/kivitendo-print-…, das anschließend wieder gelöscht wurde. Das
bedeutete, dass Font-Caching bei jeder PDF-Erstellung erfolgen
musste.
Nach dieser Umstellung wird ein Verzeichnis …/users/texmf/var angelegt
& die entsprechenden Umgebungsvariablen so gesetzt, dass TeX dort die
temporären Dateien ablegt. Dieses Verzeichnis kann dauerhaft bestehen
bleiben, sodass tatsächlich gecachet wird.