Skip to content

Commit

Permalink
Minor bug fix for Issue #12 to convert PDF with forms
Browse files Browse the repository at this point in the history
navchandar committed Sep 23, 2023
1 parent de0aec2 commit 5a8e0ec
Showing 3 changed files with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scanner/scanner.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
import argparse
from pathlib import Path
from importlib import metadata
from PIL import Image, ImageEnhance
from pprint import pprint as pretty_print
from PIL import Image, ImageEnhance
import pypdfium2 as pdfium
from colorama import Fore, Style, init

@@ -228,6 +228,11 @@ def _convert_pdf_pages_to_jpg_list(
"""
images_list = []
doc = pdfium.PdfDocument(pdf_path)

# If pdf contains forms, initiate form fields to render on output
if doc.get_formtype():
doc.init_forms()

for page in doc:
# increase render resolution for better scanned image quality
bitmap = page.render(scale=2)
Binary file added tests/Test_pdf_FillForm.pdf
Binary file not shown.
Binary file added tests/Test_pdf_Form.pdf
Binary file not shown.

0 comments on commit 5a8e0ec

Please sign in to comment.