text: from logging import NullHandler
  from pdf2docx import Converter
  import  streamlit as st
  from pdf2docx import parse
  import base64
  import time
  import tempfile
  from pathlib import Path
  from functions import *
  timestr = time.strftime("%Y%m%d-%H%M%S")
  class FileDownloader(object):
  	
  	def __init__(self, data,filename='myfile',file_ext='pdf'):
  		super(FileDownloader, self).__init__()
  		self.data = data
  		self.filename = filename
  		self.file_ext = file_ext
  
  	def download(self):
  		b64 = base64.b64encode(self.data.encode()).decode()
  		new_filename = "{}_{}_.{}".format(self.filename,timestr,self.file_ext)
  		st.markdown("#### Download File ###")
  		href = f'<a href="data:file/{self.file_ext};base64,{b64}" download="{new_filename}">Click Here!!</a>'
  		st.markdown(href,unsafe_allow_html=True)
  f = FileDownloader
  
  #from extractPic import pdf2pic
  uploaded_file = st.file_uploader(label="请上传PDF文件",type="pdf")
  docx_file = "./sample.docx"
  #parse(uploaded_file, docx_file)
  if uploaded_file is not None:
      with st.expander("查看PDF文件"):
           
          base64_pdf = base64.b64encode(uploaded_file.read()).decode('utf-8')
          pdf_display = f'<embed src="data:application/pdf;base64,{base64_pdf}" width="100%" height="600" type="application/pdf">' 
          st.markdown(pdf_display, unsafe_allow_html=True)
          file_details = {"filename":uploaded_file.name, "filetype":uploaded_file.type,
                                  "filesize":uploaded_file.size}
          st.write(file_details)
          st.write(uploaded_file.name)
          #save_uploadedfile(uploaded_file)
          f.download(base64_pdf)
      # cv = Converter("uploaded_file.name")
  
  
  
  
      # docx_file = cv.convert(docx_file)
      # b64 = base64.b64encode(docx_file.encode()).decode()
      # st.download_button(label="转换完成，请下载docx文件",data=docx_file,file_name="sample.docx")
  