File size: 781 Bytes
f2500ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import streamlit as st 
import subprocess
from subprocess import STDOUT, check_call
import os


@st.cache
def gh():
    proc = subprocess.Popen('apt-get install -y ghostscript', shell=True, stdin=None, stdout=open(os.devnull,"wb"), stderr=STDOUT, executable="/bin/bash")
    proc.wait()

gh()



import camelot as cam

input_pdf = st.file_uploader(label = "upload your pdf here", type = 'pdf')


import base64
if input_pdf is not None:
    with open("input.pdf", "wb") as f:
        base64_pdf = base64.b64encode(input_pdf.read()).decode('utf-8')
        f.write(base64.b64decode(base64_pdf))
    f.close()

    #source: https://www.southalabama.edu/mathstat/personal_pages/mulekar/st550/Krishnakumar.pdf
    table = cam.read_pdf("input.pdf", flavor = 'stream')
    st.write(table)