From 1ea01110cc5ad132e721ab74e1c7b873e3f9a3bb Mon Sep 17 00:00:00 2001 From: alister Date: Mon, 21 Mar 2022 08:51:14 +0000 Subject: [PATCH 1/2] --viewer-page-layout support for twopageright and twopageleft --- src/img2pdf.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index 81d5ef6..859b5b9 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -91,7 +91,7 @@ ImageFormat = Enum("ImageFormat", "JPEG JPEG2000 CCITTGroup4 PNG GIF TIFF MPO ot PageMode = Enum("PageMode", "none outlines thumbs") -PageLayout = Enum("PageLayout", "single onecolumn twocolumnright twocolumnleft") +PageLayout = Enum("PageLayout", "single onecolumn twocolumnright twocolumnleft twopageright twopageleft") Magnification = Enum("Magnification", "fit fith fitbh") @@ -1140,6 +1140,10 @@ class pdfdoc(object): catalog[PdfName.PageLayout] = PdfName.TwoColumnRight elif self.page_layout == PageLayout.twocolumnleft: catalog[PdfName.PageLayout] = PdfName.TwoColumnLeft + elif self.page_layout == PageLayout.twopageright: + catalog[PdfName.PageLayout] = PdfName.TwoPageRight + elif self.page_layout == PageLayout.twopageleft: + catalog[PdfName.PageLayout] = PdfName.TwoPageLeft elif self.page_layout is None: pass else: @@ -3898,7 +3902,9 @@ and left/right, respectively. It is not possible to specify asymmetric borders. 'Valid values are "single" (display single pages), "onecolumn" ' '(one continuous column), "twocolumnright" (two continuous ' 'columns with odd number pages on the right) and "twocolumnleft" ' - "(two continuous columns with odd numbered pages on the left)", + "(two continuous columns with odd numbered pages on the left), " + '"twopageright" (two pages with odd numbered page on the right) ' + 'and "twopageleft" (two pages with odd numbered page on the left)', ) viewerargs.add_argument( "--viewer-fit-window", -- 2.39.5 From 8cf8c68d7e7c361f06e241f2baec283b7ce58d3a Mon Sep 17 00:00:00 2001 From: alister Date: Fri, 25 Mar 2022 12:23:16 +0000 Subject: [PATCH 2/2] set pdf version to 1.5 with PdfName.TwoPageLeft and PdfName.TwoPageRight --- src/img2pdf.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/img2pdf.py b/src/img2pdf.py index 859b5b9..13bb5b6 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -1142,8 +1142,12 @@ class pdfdoc(object): catalog[PdfName.PageLayout] = PdfName.TwoColumnLeft elif self.page_layout == PageLayout.twopageright: catalog[PdfName.PageLayout] = PdfName.TwoPageRight + if self.output_version < "1.5": + self.output_version = "1.5" elif self.page_layout == PageLayout.twopageleft: catalog[PdfName.PageLayout] = PdfName.TwoPageLeft + if self.output_version < "1.5": + self.output_version = "1.5" elif self.page_layout is None: pass else: -- 2.39.5