Skip to content

Commit

Permalink
update PdfDocumentManager.get_image_num
Browse files Browse the repository at this point in the history
  • Loading branch information
HadronCollider committed May 2, 2024
1 parent 8d63e38 commit 36896ce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/main/checks/report_checks/image_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def check(self):
return answer(False, "Не найдено ни одного заголовка.<br><br>Проверьте корректность использования стилей.")
number_of_images, all_numbers = self.count_images_vkr()
count_file_image_object = self.file.pdf_file.get_image_num(page_without_pril=self.file.page_count)
if not count_file_image_object and not number_of_images:
if count_file_image_object and not number_of_images:
return answer(False, f'В отчёте найдено {count_file_image_object} рисунков (), но не найдено ни одной подписи рисунка.<br><br> Если в вашей работе присутствуют рисунки, убедитесь, что для их подписи был '
f'использован стиль {self.image_style}, и формат: '
f'"Рисунок <Номер рисунка> — <Название рисунка>".')
Expand Down
6 changes: 2 additions & 4 deletions app/main/reports/pdf_document/pdf_document_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ def get_text_on_page(self):
# def get_text_on_page(self):
# return {page + 1: self.pages[page].extract_text() for page in range(self.page_count_all)}

def get_image_num(self, page_without_pril=None):
if not page_without_pril:
page_without_pril = self.pdf_file.page_count
return sum(map(lambda page: len(self.pdf_file.get_page_images(page)), self.pages[:page_without_pril]))
def get_image_num(self):
return len(self.pdf_file.get_page_images(0))

def page_images(self, page_without_pril):
total_height = 0
Expand Down

0 comments on commit 36896ce

Please sign in to comment.