mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-30 00:50:24 +08:00
b44f2dc3bc
@ Added - Access to `curve` points. (E.g., `page.curves[0]["points"]`.) - Ability for `.draw_line` to draw `curve` points. @ Changed - Disaggregated "min_words_vertical" (default: 3) and "min_words_horizontal" (default: 1), removing "text_word_threshold". - Internally, made `utils.decimalize` a bit more robust; now throws errors on non-decimalizable items. - Now explicitly ignoring some (obscure) `pdfminer` object attributes. - Raw input for `.draw_line` from a bounding box to `((x, y), (x, y))`, for consistency with `curve["points"]` and with `Pillow`'s underlying method. @ Fixed - Fixed typo bug when `.rect_edges` is called before `.edges`
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
import unittest
|
|
import pandas as pd
|
|
import pdfplumber
|
|
import sys, os
|
|
|
|
import logging
|
|
logging.disable(logging.ERROR)
|
|
|
|
HERE = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
path = os.path.join(HERE, "pdfs/nics-background-checks-2015-11.pdf")
|
|
self.pdf = pdfplumber.open(path)
|
|
self.im = self.pdf.pages[0].to_image()
|
|
|
|
def test_basic_conversion(self):
|
|
self.im.reset()
|
|
self.im.draw_rect(self.im.page.rects[0])
|
|
self.im.draw_circle(self.im.page.chars[0])
|
|
self.im.draw_line(self.im.page.edges[0])
|
|
|
|
def test_debug_tablefinder(self):
|
|
self.im.reset()
|
|
settings = {
|
|
"horizontal_strategy": "text",
|
|
"intersection_tolerance": 5
|
|
}
|
|
self.im.debug_tablefinder(settings)
|
|
|
|
def test_curves(self):
|
|
path = os.path.join(
|
|
HERE,
|
|
"../examples/pdfs/ag-energy-round-up-2017-02-24.pdf"
|
|
)
|
|
page = pdfplumber.open(path).pages[0]
|
|
im = page.to_image()
|
|
im.draw_lines(page.curves)
|