diff --git a/Dockerfile b/Dockerfile index a3c142f..98d039f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.9-slim LABEL maintainer "DataMade " RUN apt-get update && \ - apt-get install -y make libreoffice poppler-utils wget && \ + apt-get install -y make libreoffice poppler-utils qpdf wget && \ rm -rf /var/lib/apt/lists/* RUN mkdir /app diff --git a/Makefile b/Makefile index a1247a8..ceb5f15 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ SHELL := /bin/bash ATTACHMENTS := $(shell python scripts/download_attachments.py) +define decrypt +$(shell pdfinfo $(1) | grep "Encrypted: yes" > /dev/null 2>&1 && + qpdf --decrypt $(1) --replace-input) +endef + clean : find attachments -type f -not -name .gitkeep -delete find merged -type f -not -name .gitkeep -delete @@ -9,6 +14,7 @@ upload_% : merged/%.pdf aws s3 cp $< s3://$$S3_BUCKET_NAME --acl public-read merged/%.pdf : $(addsuffix .pdf,$(basename $(ATTACHMENTS))) + $(foreach attachment,$^,$(call decrypt,$(attachment))) pdfunite $^ $@ attachments/%.pdf : attachments/%.xlsx