From c95b694068d00184dfc8a9b7dceabf7446839ccd Mon Sep 17 00:00:00 2001 From: Marc Stober Date: Mon, 21 Aug 2023 09:51:34 -0400 Subject: [PATCH] r2l proof-of-concept --- pypdf/_writer.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pypdf/_writer.py b/pypdf/_writer.py index 29125b2cc3..9cefd6fb24 100644 --- a/pypdf/_writer.py +++ b/pypdf/_writer.py @@ -3472,6 +3472,18 @@ def _set_page_label( page_labels[NameObject("/Nums")] = nums self._root_object[NameObject(CatalogDictionary.PAGE_LABELS)] = page_labels + def set_viewer_preferences_direction_r2l(self) -> None: + """ + Set the viewer preferences to right to left. + """ + #HACK - TODO - this is a quick fix to set the viewer preferences to right to left. + # A better solution to this is to add a property to set the viewer preferences. + # See: https://github.com/py-pdf/pypdf/issues/2105 + if NameObject(CatalogDictionary.VIEWER_PREFERENCES) not in self._root_object: + viewer_preferences = TreeObject() + viewer_preferences[NameObject("/Direction")] = NameObject("/R2L") + self._root_object[NameObject(CatalogDictionary.VIEWER_PREFERENCES)] = viewer_preferences + def _pdf_objectify(obj: Union[Dict[str, Any], str, int, List[Any]]) -> PdfObject: if isinstance(obj, PdfObject):