aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben2018-09-28 22:55:53 +0200
committerben2018-09-28 22:55:53 +0200
commit7e962d60ad8f4eaf9defa1cc017d61a8ada4dc47 (patch)
tree096db297bfaf9d203d3c8b178b4b20b93c9bd615
parent79ddd879c3bd0cbd80d6332d4d046e2e10a5405f (diff)
downloadtruepolyglot-1.4.1.tar.gz
truepolyglot-1.4.1.tar.bz2
truepolyglot-1.4.1.tar.xz
Add acrobat reader compatibility for szipdf format1.4.1
-rw-r--r--PolyglotFile/polyglotszippdf.py9
-rwxr-xr-xtruepolyglot12
2 files changed, 16 insertions, 5 deletions
diff --git a/PolyglotFile/polyglotszippdf.py b/PolyglotFile/polyglotszippdf.py
index 0796946..eadf5d0 100644
--- a/PolyglotFile/polyglotszippdf.py
+++ b/PolyglotFile/polyglotszippdf.py
@@ -28,8 +28,9 @@ from PdfFileTransformer import Pdf
class PolyglotSZipPdf(PolyglotPdfZip):
- def __init__(self, Pdf, Zip):
+ def __init__(self, Pdf, Zip, acrobat_compatibility):
super().__init__(Pdf, Zip)
+ self.acrobat_compatibility = acrobat_compatibility
def get_rebuild_zip_first_part_size(self):
@@ -82,7 +83,11 @@ class PolyglotSZipPdf(PolyglotPdfZip):
new_pdf.file_offset = offset
pdf_buffer = new_pdf.get_build_buffer()
j2 = pdf_buffer[k2_stream_offset + size_k2_stream:]
- new_zip.add_data_to_file(b'', j2, True)
+
+ if self.acrobat_compatibility:
+ new_zip.add_data_to_file(b'\x00', j2, True)
+ else:
+ new_zip.add_data_to_file(b'', j2, True)
return new_zip.buffer
diff --git a/truepolyglot b/truepolyglot
index 2ff9269..4b4075f 100755
--- a/truepolyglot
+++ b/truepolyglot
@@ -19,7 +19,7 @@ def main():
' The format is strictly a ZIP.' +
' Archive is modified.')
usage_str = '%(prog)s format [options] output-file'
- epilog_str = 'TruePolyglot v1.3'
+ epilog_str = 'TruePolyglot v1.4.1'
frm = argparse.RawTextHelpFormatter
parser = argparse.ArgumentParser(description=description_str,
epilog=epilog_str,
@@ -33,8 +33,12 @@ def main():
help='PDF input file')
parser.add_argument('--zipfile', dest='zipfile',
help='ZIP input file')
+ parser.add_argument('--acrobat-compatibility',
+ dest='acrobat_compatibility',
+ help='Add a byte at start for Acrobat Reader compatibility with szippdf format',
+ action='store_true')
parser.add_argument('--verbose', dest='verbose',
- help='Verbosity level (default: debug)',
+ help='Verbosity level (default: info)',
default="info",
choices=["none", "error", "info", "debug"])
parser.add_argument('output_file', nargs='+',
@@ -43,6 +47,8 @@ def main():
args = parser.parse_args()
formats = ["pdfzip", "zippdf", "szippdf"]
+ if args.acrobat_compatibility and args.format[0] != "szippdf":
+ parser.error('--acrobat-compatibility is for szippdf only')
if args.format[0] in formats:
if args.pdffile is None:
parser.error('pdffile is required')
@@ -65,7 +71,7 @@ def main():
if args.format[0] == "zippdf":
a = PolyglotZipPdf(p, z)
if args.format[0] == "szippdf":
- a = PolyglotSZipPdf(p, z)
+ a = PolyglotSZipPdf(p, z, args.acrobat_compatibility)
a.generate()
a.write(args.output_file[0])