Skip to content

Commit

Permalink
Merge pull request #399 from sbrunner/ps2pdf
Browse files Browse the repository at this point in the history
Add ps2pdf post-processor to get smaller files
  • Loading branch information
sbrunner committed Oct 22, 2021
2 parents 418dd7d + 7d2aa95 commit 18f90af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN \
apt install --assume-yes --no-install-recommends \
graphicsmagick pdftk-java \
tesseract-ocr tesseract-ocr-fra tesseract-ocr-deu tesseract-ocr-eng \
libimage-exiftool-perl software-properties-common python3-pip && \
libimage-exiftool-perl software-properties-common python3-pip ghostscript && \
apt clean && \
rm --recursive --force /var/lib/apt/lists/* /root/.cache /var/cache/*

Expand Down
8 changes: 6 additions & 2 deletions scan_to_paperless/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,11 +1044,15 @@ def finalize(
call(CONVERT + [img, "+repage", file_name])
pdf.append(file_name)

call(["pdftk"] + pdf + ["output", destination, "compress"])
intermediate_file = os.path.join(root_folder, "intermediate.pdf")
call(["pdftk"] + pdf + ["output", intermediate_file, "compress"])

exiftool_cmd = ["exiftool", "-overwrite_original_in_place"]
exiftool_cmd.append(destination)
exiftool_cmd.append(intermediate_file)
call(exiftool_cmd)

call(["ps2pdf", intermediate_file, destination])


def write_error(root_folder: str, message: str) -> None:
"""Write the exception in an error file."""
Expand Down

0 comments on commit 18f90af

Please sign in to comment.