PyPDFium2Loader
This notebook provides a quick overview for getting started with PyPDFium2 document loader. For detailed documentation of all __ModuleName__Loader features and configurations head to the API reference.
Overviewโ
Integration detailsโ
Class | Package | Local | Serializable | JS support |
---|---|---|---|---|
PyPDFium2Loader | langchain_community | โ | โ | โ |
Loader featuresโ
Source | Document Lazy Loading | Native Async Support |
---|---|---|
PyPDFium2Loader | โ | โ |
Setupโ
To access PyPDFium2 document loader you'll need to install the langchain-community
integration package.
Credentialsโ
No credentials are needed.
If you want to get automated best in-class tracing of your model calls you can also set your LangSmith API key by uncommenting below:
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
# os.environ["LANGSMITH_TRACING"] = "true"
Installationโ
Install langchain_community.
%pip install -qU langchain_community
Initializationโ
Now we can instantiate our model object and load documents:
from langchain_community.document_loaders import PyPDFium2TocLoader
file_path = "./example_data/sample_book.pdf"
loader = PyPDFium2TocLoader(file_path)
API Reference:PyPDFium2TocLoader
Loadโ
docs = loader.load()
docs[6]
Document(metadata={'source': './example_data/sample_book.pdf', 'toc_entry': {'toc_index': 6, 'level': 1, 'n_kids': 0, 'page_indexes': [4, 5, 6], 'title': 'Example Schedule'}}, page_content='Example Schedule\r\nA sample schedule utilizing these resources in a 15 week semester is shown below:\r\nWeek Chapters Assignments Learning\r\nOutcomes\r\n1 Introduction Lab: Think Like a Hacker\r\nIntroduction Review Questions\r\n1.1, 1.2, 1.6, 2.7\r\n2 Cryptography Lab: Hash it Out\r\nCryptography Review Questions\r\n1.2, 1.3, 1.6, 2.1,\r\n2.4, 2.5, 2.8, 3.9\r\n3 Malware Lab: Malware Analysis\r\nMalware Review Questions\r\n1.2, 1.3, 1.4, 2.5,\r\n4.1, 4.3, 4.5\r\n4 Protocols Lab: Scanning with nmap\r\nProtocols Review Questions\r\n1.3, 1.6, 1.7, 3.1,\r\n3.2, 4.1\r\n5 Attacks Quiz 1\r\nAttacks Review Questions\r\n1.2, 1.3, 1.4, 1.8,\r\n3.3, 3.4, 4.1, 4.2\r\nWeek Chapters Assignments Learning\r\nOutcomes\r\n6 Introduction\r\nCryptography\r\nMalware\r\nProtocols\r\nAttacks\r\nMidterm Review\r\nLab: MitM with Scapy\r\n1.1, 1.2, 1.3, 1.4,\r\n1.5, 1.6, 1.7, 1.8,\r\n2.1, 2.4, 2.5, 2.7,\r\n2.8, 3.1, 3.2, 3.3,\r\n3.4, 3.8, 3.9, 4.1,\r\n4.2, 4.3, 4.5\r\n7 Introduction\r\nCryptography\r\nMalware\r\nProtocols\r\nAttacks\r\nMidterm 1.1, 1.2, 1.3, 1.4,\r\n1.5, 1.6, 1.7, 1.8,\r\n2.1, 2.4, 2.5, 2.7,\r\n2.8, 3.1, 3.2, 3.3,\r\n3.4, 3.8, 3.9, 4.1,\r\n4.2, 4.3, 4.5\r\n8 Security Solutions Lab: Exploiting log4j\r\nSecurity Solutions Review Questions\r\n3.1, 3.2, 3.3, 3.6,\r\n4.1, 4.2\r\n9 Access Controls Lab: Linux File Permissions\r\nAccess Controls Review Questions\r\n2.1, 2.2, 2.4, 2.7,\r\n3.3, 3.4, 3.8, 5.1\r\n10 Vulnerability\r\nManagement and\r\nCompliance\r\nLab: Scanning with Nessus\r\nVulnerability Management and\r\nCompliance Review Questions\r\n5.1, 5.2, 5.3, 5.4, 5.5\r\n11 Incident Response\r\nand Continuity\r\nLab: Reporting on the 2014 Sony\r\nPictures Hack\r\nIncident Response and Recovery\r\nReview Questions\r\n1.2, 1.3, 1.4, 1.7,\r\n1.8, 2.3, 2.5, 3.1,\r\n3.2, 3.3, 3.4, 4.1,\r\n4.2, 4.3, 4.4, 4.5,\r\n5.3, 5.4, 5.5\r\n12 Virtualization Lab: Malicious Containers\r\nVirtualization Review Questions\r\n2.3, 3.6, 3.6\r\n13 Mobile Solutions Quiz 2 3.5\r\n14 Security Solutions\r\nAccess Controls\r\nVulnerability\r\nManagement and\r\nCompliance\r\nIncident Response\r\nand Continuity\r\nVirtualization\r\nMobile Solutions\r\nFinal Review 1.2, 1.3, 1.4, 1.7,\r\n1.8, 2.1, 2.2, 2.3,\r\n2.4, 2.5, 2.7, 3.1,\r\n3.2, 3.3, 3.4, 3.5,\r\n3.6, 3.7, 3.8, 4.1,\r\n4.2, 4.3, 4.4, 4.5,\r\n5.1, 5.2, 5.3, 5.4, 5.5\r\nWeek Chapters Assignments Learning\r\nOutcomes\r\n15 Security Solutions\r\nAccess Controls\r\nVulnerability\r\nManagement and\r\nCompliance\r\nIncident Response\r\nand Continuity\r\nVirtualization\r\nMobile Solutions\r\nFinal Exam 1.2, 1.3, 1.4, 1.7,\r\n1.8, 2.1, 2.2, 2.3,\r\n2.4, 2.5, 2.7, 3.1,\r\n3.2, 3.3, 3.4, 3.5,\r\n3.6, 3.7, 3.8, 4.1,\r\n4.2, 4.3, 4.4, 4.5,\r\n5.1, 5.2, 5.3, 5.4, 5.5\n')
print(docs[6].metadata)
{'source': './example_data/sample_book.pdf', 'toc_entry': {'toc_index': 6, 'level': 1, 'n_kids': 0, 'page_indexes': [4, 5, 6], 'title': 'Example Schedule'}}
print(docs[6].page_content)
Example Schedule
A sample schedule utilizing these resources in a 15 week semester is shown below:
Week Chapters Assignments Learning
Outcomes
1 Introduction Lab: Think Like a Hacker
Introduction Review Questions
1.1, 1.2, 1.6, 2.7
2 Cryptography Lab: Hash it Out
Cryptography Review Questions
1.2, 1.3, 1.6, 2.1,
2.4, 2.5, 2.8, 3.9
3 Malware Lab: Malware Analysis
Malware Review Questions
1.2, 1.3, 1.4, 2.5,
4.1, 4.3, 4.5
4 Protocols Lab: Scanning with nmap
Protocols Review Questions
1.3, 1.6, 1.7, 3.1,
3.2, 4.1
5 Attacks Quiz 1
Attacks Review Questions
1.2, 1.3, 1.4, 1.8,
3.3, 3.4, 4.1, 4.2
Week Chapters Assignments Learning
Outcomes
6 Introduction
Cryptography
Malware
Protocols
Attacks
Midterm Review
Lab: MitM with Scapy
1.1, 1.2, 1.3, 1.4,
1.5, 1.6, 1.7, 1.8,
2.1, 2.4, 2.5, 2.7,
2.8, 3.1, 3.2, 3.3,
3.4, 3.8, 3.9, 4.1,
4.2, 4.3, 4.5
7 Introduction
Cryptography
Malware
Protocols
Attacks
Midterm 1.1, 1.2, 1.3, 1.4,
1.5, 1.6, 1.7, 1.8,
2.1, 2.4, 2.5, 2.7,
2.8, 3.1, 3.2, 3.3,
3.4, 3.8, 3.9, 4.1,
4.2, 4.3, 4.5
8 Security Solutions Lab: Exploiting log4j
Security Solutions Review Questions
3.1, 3.2, 3.3, 3.6,
4.1, 4.2
9 Access Controls Lab: Linux File Permissions
Access Controls Review Questions
2.1, 2.2, 2.4, 2.7,
3.3, 3.4, 3.8, 5.1
10 Vulnerability
Management and
Compliance
Lab: Scanning with Nessus
Vulnerability Management and
Compliance Review Questions
5.1, 5.2, 5.3, 5.4, 5.5
11 Incident Response
and Continuity
Lab: Reporting on the 2014 Sony
Pictures Hack
Incident Response and Recovery
Review Questions
1.2, 1.3, 1.4, 1.7,
1.8, 2.3, 2.5, 3.1,
3.2, 3.3, 3.4, 4.1,
4.2, 4.3, 4.4, 4.5,
5.3, 5.4, 5.5
12 Virtualization Lab: Malicious Containers
Virtualization Review Questions
2.3, 3.6, 3.6
13 Mobile Solutions Quiz 2 3.5
14 Security Solutions
Access Controls
Vulnerability
Management and
Compliance
Incident Response
and Continuity
Virtualization
Mobile Solutions
Final Review 1.2, 1.3, 1.4, 1.7,
1.8, 2.1, 2.2, 2.3,
2.4, 2.5, 2.7, 3.1,
3.2, 3.3, 3.4, 3.5,
3.6, 3.7, 3.8, 4.1,
4.2, 4.3, 4.4, 4.5,
5.1, 5.2, 5.3, 5.4, 5.5
Week Chapters Assignments Learning
Outcomes
15 Security Solutions
Access Controls
Vulnerability
Management and
Compliance
Incident Response
and Continuity
Virtualization
Mobile Solutions
Final Exam 1.2, 1.3, 1.4, 1.7,
1.8, 2.1, 2.2, 2.3,
2.4, 2.5, 2.7, 3.1,
3.2, 3.3, 3.4, 3.5,
3.6, 3.7, 3.8, 4.1,
4.2, 4.3, 4.4, 4.5,
5.1, 5.2, 5.3, 5.4, 5.5
Lazy Loadโ
Relatedโ
- Document loader conceptual guide
- Document loader how-to guides