- working intrepreter v2
This commit is contained in:
1 parent
1d11cd1c7f
commit
487f9b6c08
33 files changed
+1216
-1366
No files matched your search
@@ -1,19 +0,0 @@
|
||||
import os
|
||||
|
||||
from pdfmajor.extractor import v2_extract_items_from_pdf
|
||||
from pdfmajor.interpreter_v2 import PDFText
|
||||
|
||||
CUR_PATH = os.path.dirname(os.path.dirname(__file__))
|
||||
CUR_PATH = os.path.dirname(os.getcwd())
|
||||
|
||||
FILE_NAME = os.path.join(
|
||||
CUR_PATH,
|
||||
"samples/pdf/fonts.pdf"
|
||||
)
|
||||
|
||||
for page in v2_extract_items_from_pdf(FILE_NAME):
|
||||
for item in page:
|
||||
if isinstance(item, PDFText):
|
||||
print(item.chars)
|
||||
else:
|
||||
print(item)
|
||||
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
|
||||
# from pdfmajor.extractor import extract_items_from_pdf
|
||||
from pdfmajor.interpreter_v2 import LTCharBlock, PDFInterpreter, logging
|
||||
from pdfmajor.interpreter_v2 import PageInterpreter
|
||||
from pdfmajor.interpreter_v2.commands import LTItem
|
||||
from pdfmajor.interpreter_v2.commands import LTCharBlock, LTChar
|
||||
|
||||
CUR_PATH = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
FILE_NAME = os.path.join(
|
||||
CUR_PATH,
|
||||
"samples/pdf/tables.pdf"
|
||||
)
|
||||
|
||||
for page in PDFInterpreter(FILE_NAME, debug_level=logging.INFO):
|
||||
assert isinstance(page, PageInterpreter)
|
||||
for item in page:
|
||||
assert isinstance(item, LTItem)
|
||||
if isinstance(item, LTCharBlock):
|
||||
for char in item:
|
||||
assert(char, LTChar)
|
||||
Reference in new issue
Block a user