diff --git a/docs/index.rst b/docs/index.rst index 62f2ab2c5..abf294935 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -42,6 +42,7 @@ You can contribute to `pypdf on GitHub `_. user/file-size user/pdf-version-support user/pdfa-compliance + outlines .. toctree:: diff --git a/docs/outlines.rst b/docs/outlines.rst new file mode 100644 index 000000000..e499a26c1 --- /dev/null +++ b/docs/outlines.rst @@ -0,0 +1,27 @@ +========================= +Working with Outlines +========================= + +Outlines (also known as bookmarks) are used to create a clickable table of contents in a PDF. + +Reading outlines +----------------- +.. code-block:: python + + from pypdf import PdfReader + + reader = PdfReader("example.pdf") + outlines = reader.outline + for item in outlines: + print(item) + +Adding outlines +---------------- +.. code-block:: python + + from pypdf import PdfWriter + + writer = PdfWriter() + writer.add_blank_page(width=200, height=200) + writer.add_outline_item("My First Page", 0) + writer.write("output.pdf")