Dont delete toc pages if they empty PDF file

This commit is contained in:
Kovid Goyal 2019-11-28 10:52:42 +05:30
parent fdc0c7cf7e
commit c091461b99
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -528,6 +528,7 @@ def get_anchor_locations(pdf_doc, first_page_num, toc_uuid):
ans = {}
anchors = pdf_doc.extract_anchors()
toc_pagenum = anchors.pop(toc_uuid)[0]
if toc_pagenum > 1:
pdf_doc.delete_pages(toc_pagenum, pdf_doc.page_count() - toc_pagenum + 1)
for anchor, loc in iteritems(anchors):
loc = list(loc)