diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 13d2d2b..cfe7eca 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -11,6 +11,11 @@ assignees: '' *A clear and concise description of what the bug is.* +## Have you tried [repairing](../../docs/repairing.md) the PDF? + +*Please try running your code with `pdfplumber.open(..., repair=True)` before submitting a bug report.* + + ## Code to reproduce the problem *Paste it here, or attach a Python file.* diff --git a/docs/repairing.md b/docs/repairing.md new file mode 100644 index 0000000..6efd8e7 --- /dev/null +++ b/docs/repairing.md @@ -0,0 +1,11 @@ +# Repairing Malformed PDFs + +Many parsing issues can be traced back to malformed PDFs. + +Malformed PDFs can often be [fixed via Ghostscript](https://superuser.com/questions/278562/how-can-i-fix-repair-a-corrupted-pdf-file). + +`pdfplumber` lets you automatically run those repairs, in several ways: + +- `pdfplumber.open(..., repair=True)` will repair your PDF on the fly (but not save the repaired version to disk). +- `pdfplumber.repair(path_to_pdf)` will return a `BytesIO` object holding the bytes of a repaired version of the original file. +- `pdfplumber.repair(path_to_pdf, outfile="path/to/repaired.pdf")` will write a repaired version of the original file to the indicated `outfile` path.