From: Moritz Bunkus Date: Mon, 2 Mar 2020 16:21:52 +0000 (+0100) Subject: ZUGFeRD: nicht nach \documentclass, sondern \begin{document} suchen X-Git-Tag: release-3.5.6.1~245^2~23 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5e9f08d41ced9d75d868621c43b9b639e9e1b781;p=kivitendo-erp.git ZUGFeRD: nicht nach \documentclass, sondern \begin{document} suchen \documentclass steht evtl. in einem Include. --- diff --git a/SL/Template/LaTeX.pm b/SL/Template/LaTeX.pm index 303fb7f37..422a2932b 100644 --- a/SL/Template/LaTeX.pm +++ b/SL/Template/LaTeX.pm @@ -428,39 +428,22 @@ sub _force_mandatory_packages { if ($line =~ m/\\usepackage[^\{]*{(.*?)}/) { $used_packages{$1} = 1; - } elsif (($line =~ m/\\documentclass/) && $self->{pdf_a}) { - my $version = $self->{pdf_a}->{version} // '3a'; - - if ($self->{pdf_a}->{xmp}) { + } elsif ($line =~ m/\\begin\{document\}/) { + if ($self->{pdf_a} && $self->{pdf_a}->{xmp}) { + my $version = $self->{pdf_a}->{version} // '3a'; my $xmp_file_name = $self->{userspath} . "/pdfa.xmp"; my $out = IO::File->new($xmp_file_name, ">:encoding(utf-8)") || croak "Error creating ${xmp_file_name}: $!"; $out->print(Encode::encode('utf-8', $self->{pdf_a}->{xmp})); $out->close; - } else { - my $meta = $self->{pdf_a}->{meta_data} // {}; - push @new_lines, ( - "\\RequirePackage{filecontents}\n", - "\\begin{filecontents*}{\\jobname.xmpdata}\n", - ($meta->{title} ? sprintf("\\Title{%s}\n", $meta->{title}) : ""), - ($meta->{author} ? sprintf("\\Author{%s}\n", $meta->{author}) : ""), - ($meta->{language} ? sprintf("\\Language{%s}\n", $meta->{language}) : ""), - "\\end{filecontents*}\n", + "\\usepackage[a-${version},mathxmp]{pdfx}[2018/12/22]\n", + "\\usepackage[genericmode]{tagpdf}\n", + "\\tagpdfsetup{activate-all}\n", + "\\hypersetup{pdfstartview=}\n", ); } - push @new_lines, ( - $line, - "\\usepackage[a-${version},mathxmp]{pdfx}[2018/12/22]\n", - "\\usepackage[genericmode]{tagpdf}\n", - "\\tagpdfsetup{activate-all}\n", - "\\hypersetup{pdfstartview=}\n", - ); - - next; - - } elsif ($line =~ m/\\begin\{document\}/) { push @new_lines, map { "\\usepackage{$_}\n" } grep { !$used_packages{$_} } @required_packages; push @new_lines, $line; push @new_lines, map { $self->_embed_file_directive($_) } @{ $self->{pdf_attachments} // [] };