Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging for pdf2txt #325

Merged
merged 1 commit into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pdfminer/high_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
bundled scripts and for using pdfminer as a module for routine tasks.
"""

import logging
import six
import sys

Expand Down Expand Up @@ -50,6 +51,9 @@ def extract_text_to_fp(inf, outfp,
'upgrade to Python 3. For more information see '
'https://github.com/pdfminer/pdfminer .six/issues/194')

if debug:
logging.getLogger().setLevel(logging.DEBUG)

if six.PY2 and sys.stdin.encoding:
password = password.decode(sys.stdin.encoding)

Expand Down
2 changes: 2 additions & 0 deletions tools/dumppdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from pdfminer.psparser import PSKeyword, PSLiteral, LIT
from pdfminer.utils import isnumber

logging.basicConfig()

ESC_PAT = re.compile(r'[\000-\037&<>()"\042\047\134\177-\377]')


Expand Down
3 changes: 3 additions & 0 deletions tools/pdf2txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import logging
import six
import sys

import pdfminer.settings
pdfminer.settings.STRICT = False
import pdfminer.high_level
import pdfminer.layout
from pdfminer.image import ImageWriter

logging.basicConfig()


def extract_text(files=[], outfile='-',
no_laparams=False, all_texts=None, detect_vertical=None, # LAParams
Expand Down
6 changes: 5 additions & 1 deletion tools/pdfdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import pdfminer.high_level
import pdfminer.layout

logging.basicConfig()


def compare(file1, file2, **kwargs):
if '_py2_no_more_posargs' in kwargs is not None:
Expand Down Expand Up @@ -89,10 +91,12 @@ def main(args=None):
P.add_argument("-O", "--output-dir", default=None, help="Output directory for images")
P.add_argument("-C", "--disable-caching", default=False, action="store_true", help="Disable caching")
P.add_argument("-S", "--strip-control", default=False, action="store_true", help="Strip control in XML mode")


A = P.parse_args(args=args)

if A.debug:
logging.getLogger().setLevel(logging.DEBUG)

if A.page_numbers:
A.page_numbers = set([x-1 for x in A.page_numbers])
if A.pagenos:
Expand Down