From c5851efd3df0b3952cfbddbdabb3704ef7b8fd97 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sun, 27 Apr 2025 20:59:59 +0200 Subject: [PATCH] embed factur-x in pdf output --- index.cgi | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/index.cgi b/index.cgi index 09d07c3..8fde919 100755 --- a/index.cgi +++ b/index.cgi @@ -78,17 +78,26 @@ fi >&2 type="$(DB3 get type)" . "${_EXEC}/${type}/form.sh" . "${_EXEC}/${type}/print.sh" + . "${_EXEC}/factur-x.sh" - yield_html >"$_DATA/export/${id}.html" - lowriter --convert-to pdf --outdir "export/" "export/${id}.html" >/dev/null + rm -f -- "$_DATA/export/${id}.pdf" + mkdir -p "$_DATA/export/${id}/" + yield_html >"$_DATA/export/${id}/body.html" + yield_xml >"$_DATA/export/${id}/factur-x.xml" + lowriter --convert-to pdf --outdir "$_DATA/export/${id}" "$_DATA/export/${id}/body.html" >/dev/null if [ -f "$_EXEC/$type/print.pdf" ]; then - pdftk "export/${id}.pdf" burst output "export/${id}_%04d.pdf" - pdftk "export/${id}_0001.pdf" background "$_EXEC/$type/print.pdf" output "export/${tmp}.pdf" - mv -- "export/${tmp}.pdf" "export/${id}_0001.pdf" - pdftk "export/${id}"_*.pdf cat output "export/${id}.pdf" - rm -- "export/${id}"_*.pdf "export/doc_data.txt" + pdftk "$_DATA/export/${id}/body.pdf" burst output "$_DATA/export/${id}/body_%04d.pdf" + pdftk "$_DATA/export/${id}/body_0001.pdf" background "$_EXEC/$type/print.pdf" output "$_DATA/export/${tmp}.pdf" + mv -- "$_DATA/export/${tmp}.pdf" "$_DATA/export/${id}/body_0001.pdf" + pdftk "$_DATA/export/${id}/"body_*.pdf cat output "$_DATA/export/${id}/body.pdf" + rm -- "$_DATA/export/${id}/"body_*.pdf "$_DATA/export/${id}/doc_data.txt" fi - rm -- "export/${id}.html" + pdftk "$_DATA/export/${id}/body.pdf" \ + attach_files "$_DATA/export/${id}/factur-x.xml" \ + output "$_DATA/export/${id}.pdf" + # mv -- "$_DATA/export/${id}/body.pdf" "$_DATA/export/${id}.pdf" + rm -- "$_DATA/export/${id}/body.html" "$_DATA/export/${id}/body.pdf" "$_DATA/export/${id}/factur-x.xml" + rmdir -- "$_DATA/export/${id}/" REDIRECT "${_BASE}/pdf/${id}/$(URL "${filenamestring}.pdf")" ;; *) -- 2.39.5