Ghostscript, PDF/A: support pathlib

This commit is contained in:
James R. Barlow
2018-06-22 17:45:10 -07:00
parent 0aa51f0f3a
commit faaa4a1def
2 changed files with 5 additions and 3 deletions
+2 -2
View File
@@ -225,7 +225,7 @@ def generate_pdfa(pdf_pages, output_file, compression, log,
"-dPDFACompatibilityPolicy=1",
"-sOutputFile=" + gs_pdf.name,
]
args_gs.extend(pdf_pages)
args_gs.extend(fspath(s) for s in pdf_pages) # Stringify Path objs
log.debug(args_gs)
p = run(args_gs, stdout=PIPE, stderr=STDOUT,
universal_newlines=True)
@@ -246,7 +246,7 @@ def generate_pdfa(pdf_pages, output_file, compression, log,
if p.returncode == 0:
# Ghostscript does not change return code when it fails to create
# PDF/A - check PDF/A status elsewhere
copy(gs_pdf.name, output_file)
copy(gs_pdf.name, fspath(output_file))
else:
log.error('Ghostscript PDF/A rendering failed')
raise SubprocessOutputError()
+3 -1
View File
@@ -24,6 +24,8 @@ import pkg_resources
from libxmp.utils import file_to_dict
from libxmp import consts
from .helpers import universal_open
ICC_PROFILE_RELPATH = 'data/sRGB.icc'
SRGB_ICC_PROFILE = pkg_resources.resource_filename(
@@ -214,7 +216,7 @@ def generate_pdfa_ps(target_filename, pdfmark, icc='sRGB'):
# We should have encoded everything to pure ASCII by this point, and
# to be safe, only allow ASCII in PostScript
with open(target_filename, 'w', encoding='ascii') as f:
with universal_open(target_filename, 'w', encoding='ascii') as f:
f.write(ps)