Skip to content

Commit

Permalink
DEP: Remove merger.OutlinesObject (#847)
Browse files Browse the repository at this point in the history
Closes #829
  • Loading branch information
MartinThoma authored May 1, 2022
1 parent b5e0ee2 commit 3713c8f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Deprecations (DEP):
- PyPDF2 2.0 requires Python 3.6+. Python 2.7 and 3.5 support were dropped.
- PdfFileReader and PdfFileMerger no longer have the `overwriteWarnings`
parameter. The new behavior is `overwriteWarnings=False`.
- merger: OutlinesObject was removed.
- utils:
* `formatWarning` was removed
* `isInt(obj)`: Use `instance(obj, int)` instead
Expand Down
43 changes: 0 additions & 43 deletions PyPDF2/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,46 +600,3 @@ def addNamedDestination(self, title, pagenum):
NumberObject(826),
)
self.named_dests.append(dest)


class OutlinesObject(list):
def __init__(self, pdf, tree, parent=None):
list.__init__(self)
self.tree = tree
self.pdf = pdf
self.parent = parent

def remove(self, index):
obj = self[index]
del self[index]
self.tree.removeChild(obj)

def add(self, title, pagenum):
page_ref = self.pdf.getObject(self.pdf._pages)[PA.KIDS][pagenum]
action = DictionaryObject()
action.update(
{
NameObject("/D"): ArrayObject(
[page_ref, NameObject("/FitH"), NumberObject(826)]
),
NameObject("/S"): NameObject("/GoTo"),
}
)
action_ref = self.pdf._addObject(action)
bookmark = TreeObject()

bookmark.update(
{
NameObject("/A"): action_ref,
NameObject("/Title"): createStringObject(title),
}
)

self.pdf._addObject(bookmark)

self.tree.addChild(bookmark)

def removeAll(self):
for child in self.tree.children():
self.tree.removeChild(child)
self.pop()

0 comments on commit 3713c8f

Please sign in to comment.