Skip to content

Commit

Permalink
Merge pull request #1235 from brandonrobertz/add-text-output-mode
Browse files Browse the repository at this point in the history
Add a --format text option
  • Loading branch information
jsvine authored Dec 16, 2024
2 parents 28d4f50 + f3f2b57 commit e0ee254
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pdfplumber/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def parse_args(args_raw: List[str]) -> argparse.Namespace:
action="store_true",
)

parser.add_argument("--format", choices=["csv", "json"], default="csv")
parser.add_argument("--format", choices=["csv", "json", "text"], default="csv")

parser.add_argument("--types", nargs="+")

Expand Down Expand Up @@ -109,6 +109,9 @@ def main(args_raw: List[str] = sys.argv[1:]) -> None:
include_attrs=args.include_attrs,
exclude_attrs=args.exclude_attrs,
)
elif args.format == "text":
for page in pdf.pages:
print(page.extract_text(layout=True))
else:
pdf.to_json(
sys.stdout,
Expand Down

0 comments on commit e0ee254

Please sign in to comment.