diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7f7c39aca..d9e30952d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -54,6 +54,7 @@ history and [GitHubs 'Contributors' feature](https://github.com/py-pdf/pypdf/gra * [WevertonGomes](https://github.com/WevertonGomesCosta) * [Wilson, Huon](https://github.com/huonw) * ztravis +* [Stober, Marc](https://github.com/marcstober) ## Adding a new contributor diff --git a/pypdf/_writer.py b/pypdf/_writer.py index 25a6444d3..e3fe5bb07 100644 --- a/pypdf/_writer.py +++ b/pypdf/_writer.py @@ -384,7 +384,7 @@ def viewer_preferences(self) -> Optional[ViewerPreferences]: self._root_object[NameObject(CD.VIEWER_PREFERENCES)] = o return o - def create_viewer_preference(self) -> ViewerPreferences: + def create_viewer_preferences(self) -> ViewerPreferences: o = ViewerPreferences() self._root_object[NameObject(CD.VIEWER_PREFERENCES)] = self._add_object(o) return o diff --git a/tests/test_writer.py b/tests/test_writer.py index c9766f979..d0c58dc4e 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -1725,10 +1725,7 @@ def test_damaged_pdf_length_returning_none(): @pytest.mark.enable_socket() def test_viewerpreferences(): - """ - Add Tests for ViewerPreferences - https://github.com/py-pdf/pypdf/issues/140#issuecomment-1685380549 - """ + """Add Tests for ViewerPreferences""" url = "https://github.com/py-pdf/pypdf/files/9175966/2015._pb_decode_pg0.pdf" name = "2015._pb_decode_pg0.pdf" reader = PdfReader(BytesIO(get_data_from_url(url, name=name))) @@ -1779,8 +1776,10 @@ def test_viewerpreferences(): v.print_pagerange = ArrayObject() assert len(v.print_pagerange) == 0 - writer.create_viewer_preference() + writer.create_viewer_preferences() assert len(writer._root_object["/ViewerPreferences"]) == 0 + writer.viewer_preferences.direction = "/R2L" + assert len(writer._root_object["/ViewerPreferences"]) == 1 del reader.trailer["/Root"]["/ViewerPreferences"] assert reader.viewer_preferences is None