Last active
September 20, 2019 04:43
-
-
Save HiCraigChen/0faade4bc4c338e2ced29d71122e9676 to your computer and use it in GitHub Desktop.
pdftotext python code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from chalice import Chalice | |
import os | |
app = Chalice(app_name='pdftotext') | |
@app.route('/') | |
def index(): | |
# Get a sample pdf file | |
os.system("curl https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf -o /tmp/file.pdf") | |
# Execute pdftotext | |
os.system("lib/poppler-utils-0.26/usr/bin/pdftotext /tmp/file.pdf /tmp/out.txt") | |
# Read .txt file and return | |
f = open("/tmp/out.txt","r") | |
data = f.readlines() | |
f.close() | |
return {'text': data} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment