Comments (2)
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
import urllib.request
from io import BytesIO
def extract_pdf_metadata(pdf_file:str) -> dict:
"""Returns the metadata of a PDF
Parameters:
pdf_path (str) : the path of the PDF file of which metadata should be extracted
Returns:
dict: metadata of the PDF, presented as a JSON structured as follows :
{
metadata:{
"Author": "AURORE",
"CreationDate": "D:20200325185329+01'00'",
"Creator": "Microsoft Office Word 2007",
"ModDate": "D:20210311153835+01'00'",
"Producer": "Microsoft Office Word 2007",
"Title": "DOSSIER COUP DE POUCE 2020"
}
content:"Lorem ipsum dolor sit amet, ..."
}
"""
pdf_parser = PDFParser(pdf_file)
doc = PDFDocument(pdf_parser)
metadata = doc.info[0]
for (key, value) in doc.info[0].items():
# Need to decode each value from bytestrings toward strings
metadata[key] = value.decode("utf-8", errors='ignore')
return metadata
if __name__ == '__main__':
response = urllib.request.urlopen('http://arxiv.org/pdf/cs/9308101v1')
pdf_txt = response.read()
fileObj = BytesIO()
fileObj.write(pdf_txt)
metadata = extract_pdf_metadata(fileObj)
print(metadata)
from pytdelivery.
Closed with commit #cebc9a24d06933fd9b969901ba1fd8b38ad51861
from pytdelivery.
Related Issues (15)
- Use a DB to store PDF IF + content + metadata
- Create an endpoint to upload PDF from URL
- Test Flask API with Flask client
- Upload files asynchronously using a queue (Redis Celery)
- Create an API to get informations about document processing state (pending, success, failure), metadata and links to contents
- Create a test conf file HOT 1
- Use an ORM?
- Convert current unittests toward pytests (compatible with Flask test utils)
- Use MongoAlchemy
- Containerize the application
- Deploy the application in production
- Setup a CI/CD pipeline
- Solve integration issue : project not functionnal when cloned in master branch
- Configure the Flask project with a dedicated file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytdelivery.