diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c561650 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.icc filter=lfs diff=lfs merge=lfs -text diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 225861c..98aa701 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -7,6 +7,7 @@ RUN set -ex; \ ghostscript \ inotify-tools \ make \ + patch \ ; \ \ tlmgr update --self; \ @@ -20,6 +21,12 @@ RUN set -ex; \ COPY src/usr /usr +RUN set -ex; \ + \ + cp /usr/share/ghostscript/lib/PDFA_def.ps /usr/local/share/autodoc/; \ + patch -d /usr/local/share/autodoc < /usr/local/share/autodoc/PDFA_def.ps.patch; \ + rm /usr/local/share/autodoc/PDFA_def.ps.patch; + WORKDIR /docs ENTRYPOINT ["autodoc"] CMD ["-bw"] @@ -37,7 +44,6 @@ RUN set -ex; \ apk add --no-cache \ chromium \ npm \ - patch \ ; \ \ npm install --global @mermaid-js/mermaid-cli; \ diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index d213449..fc89cc0 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -8,6 +8,7 @@ RUN set -ex; \ ghostscript \ inotify-tools \ make \ + patch \ ; rm -rf /var/lib/apt/lists/*; \ \ tlmgr update --self; \ @@ -21,6 +22,12 @@ RUN set -ex; \ COPY src/usr /usr +RUN set -ex; \ + \ + cp /usr/share/ghostscript/10.02.1/lib/PDFA_def.ps /usr/local/share/autodoc/; \ + patch -d /usr/local/share/autodoc < /usr/local/share/autodoc/PDFA_def.ps.patch; \ + rm /usr/local/share/autodoc/PDFA_def.ps.patch; + WORKDIR /docs ENTRYPOINT ["autodoc"] CMD ["-bw"] @@ -45,7 +52,6 @@ RUN set -ex; \ libxkbcommon0 \ libxrandr2 \ npm \ - patch \ ; rm -rf /var/lib/apt/lists/*; \ \ npm install --global @mermaid-js/mermaid-cli; \ diff --git a/src/diagram.lua.patch b/src/diagram.lua.patch index 3e991d7..acfe7f2 100644 --- a/src/diagram.lua.patch +++ b/src/diagram.lua.patch @@ -1,5 +1,5 @@ ---- diagram.lua 2024-11-18 23:55:02.673989033 +0100 -+++ diagram.patched.lua 2024-11-19 00:10:14.359878550 +0100 +--- diagram.lua ++++ diagram.lua @@ -158,7 +158,7 @@ write_file(infile, code) pipe( diff --git a/src/usr/local/share/autodoc/PDFA_def.ps.patch b/src/usr/local/share/autodoc/PDFA_def.ps.patch new file mode 100644 index 0000000..680bb29 --- /dev/null +++ b/src/usr/local/share/autodoc/PDFA_def.ps.patch @@ -0,0 +1,11 @@ +--- PDFA_def.ps ++++ PDFA_def.ps +@@ -9,7 +9,7 @@ + /DOCINFO pdfmark + + % Define an ICC profile : +-/ICCProfile (srgb.icc) % Customise ++/ICCProfile (/usr/local/share/autodoc/compatibleWithAdobeRGB1998.icc) % Customise + def + + [/_objdef {icc_PDFA} /type /stream /OBJ pdfmark diff --git a/src/usr/local/share/autodoc/compatibleWithAdobeRGB1998.icc b/src/usr/local/share/autodoc/compatibleWithAdobeRGB1998.icc new file mode 100644 index 0000000..1c6795c --- /dev/null +++ b/src/usr/local/share/autodoc/compatibleWithAdobeRGB1998.icc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76f4ad83ad4726d33e2291a5b3e3bf4f30b2f723c65a583b74a9365e30e097c7 +size 580 diff --git a/src/usr/local/share/autodoc/pdftools.mk b/src/usr/local/share/autodoc/pdftools.mk new file mode 100644 index 0000000..e30bd0e --- /dev/null +++ b/src/usr/local/share/autodoc/pdftools.mk @@ -0,0 +1,46 @@ +############# +# FUNCTIONS # +############# + +PDFTOOLS_GSFLAGS := \ + -sDEVICE=pdfwrite \ + -dNOOUTERSAVE \ + -dNOPAUSE \ + -dQUIET \ + -dBATCH + +pdftools_pdfcat = gs \ + $(PDFTOOLS_GSFLAGS) \ + -sPAPERSIZE=a4 \ + -dFIXEDMEDIA \ + -dPDFFitPage \ + -dCompatibilityLevel=1.7 \ + -dPDFSETTINGS=/ebook \ + -sOutputFile=$(2) \ + $(1) + +pdftools_mkpdfa = gs \ + $(PDFTOOLS_GSFLAGS) \ + -dPDFA=$(1) \ + -sColorConversionStrategy=RGB \ + -dPDFACompatibilityPolicy=1 \ + --permit-file-read=/usr/local/share/autodoc/ \ + -sOutputFile=$(3) \ + /opt/pdfa/PDFA_def.ps \ + $(2) + +############ +# PATTERNS # +############ + +# convert PDF to PDF/A-2B +%_pdfa2.pdf: %.pdf + $(call convert_pdfa,2,$<,$@) + +# convert PDF to PDF/A-3B +%_pdfa3.pdf: %.pdf + $(call convert_pdfa,3,$<,$@) + +# convert PDF to PDF/A (default variant 3B) +%_pdfa.pdf: %.pdf + $(call convert_pdfa,3,$<,$@)