Skip to content

Commit

Permalink
updated dep
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgOhneH committed Sep 18, 2023
1 parent 19805c6 commit b9a2041
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions core/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ async def _add_pdf_highlights(download_settings,
out_path):
if download_settings.highlight_page_limit != 0:
with fitz.Document(old_absolute_path, filetype="pdf") as doc:
if doc.pageCount > download_settings.highlight_page_limit:
logger.debug(f"Skipping highlights. File: {absolute_path}. Page Count: {doc.pageCount} is to large")
if doc.page_count > download_settings.highlight_page_limit:
logger.debug(f"Skipping highlights. File: {absolute_path}. Page Count: {doc.page_count} is to large")
return

logger.debug(f"Adding highlights to {absolute_path}")
Expand Down
20 changes: 10 additions & 10 deletions core/pdf_highlighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,23 @@ def add_differ_highlight(new_path, old_path, out_path):
with open(EMPTY_TWO_COLUMN_LEFT_PDF_PATH, "rb") as f:
doc_preset = fitz.Document(stream=f.read(), filetype="pdf")

for i in range(max(doc_new.pageCount, doc_old.pageCount)):
for i in range(max(doc_new.page_count, doc_old.page_count)):

if i >= doc_old.pageCount:
if i >= doc_old.page_count:
bound = doc_new[i].bound()
doc_preset.newPage(width=bound.x1, height=bound.y1)
doc_preset.new_page(width=bound.x1, height=bound.y1)

else:
doc_preset.insertPDF(doc_old,
doc_preset.insert_pdf(doc_old,
from_page=i,
to_page=i,
annots=True)

if i >= doc_new.pageCount:
if i >= doc_new.page_count:
bound = doc_old[i].bound()
doc_preset.newPage(width=bound.x1, height=bound.y1)
doc_preset.new_page(width=bound.x1, height=bound.y1)
else:
doc_preset.insertPDF(doc_new,
doc_preset.insert_pdf(doc_new,
from_page=i,
to_page=i,
annots=True)
Expand All @@ -110,7 +110,7 @@ def add_differ_highlight(new_path, old_path, out_path):
def get_all_boxes(doc):
boxes = []
for i, page in enumerate(doc):
text_page = page.getTextPage()
text_page = page.get_textpage()
blocks = text_page.extractRAWDICT()["blocks"]
for block in blocks:
if block["type"] == 1:
Expand Down Expand Up @@ -168,8 +168,8 @@ def make_annotations(doc, boxes, similar_boxes):
continue
page = doc[box.page_index]
try:
annot = page.addHighlightAnnot(box.get())
annot.setColors(stroke=box.colour)
annot = page.add_highlight_annot(box.get())
annot.set_colors(stroke=box.colour)
annot.update()
except ValueError as e: # Bad quads error
print(f"Error: {e}. Box: {box.get()}")
Expand Down
6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ colorama
pyyaml
certifi
PyMuPDF
PyQt5==5.15.2
pyinstaller==5.13
PyQt5==5.15.9
pyinstaller==5.13.2
tenacity
babel
git+https://github.com/Digital-Sapphire/PyUpdater
PyUpdater-S3-plugin
pywin32; sys_platform == 'win32'

0 comments on commit b9a2041

Please sign in to comment.