'How to extract Bold text from pdf using python?
The list below provides examples of items and services that should not be billed separately. Please note that the list is not all inclusive.
1. Surgical rooms and services – To include surgical suites, major and minor, treatment rooms, endoscopy labs, cardiac cath labs, X-ray.
2. Facility Basic Charges - pulmonary and cardiology procedural rooms. The hospital’s charge for surgical suites and services shall include the entire above listed nursing personnel services, supplies, and equipment
I want output like:
- Surgical rooms and services
- Facility Basic Charges
there is first sentence also bold but we need to omit that sentence, we need to extract only those text which are represented with numbers
Solution 1:[1]
You can do it using this code:
import pdfplumber
with pdfplumber.open('test.pdf') as pdf:
text = pdf.pages[0]
clean_text = text.filter(lambda obj: obj["object_type"] == "char" and "Bold" in obj["fontname"])
print(clean_text.extract_text())
It use pdfplumber library, so for more info you can check they documentation
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nestor Silva |
