Guest User

Untitled

a guest
Oct 23rd, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import sys
  2. import fitz
  3. import tkinter
  4. import os
  5.  
  6. from tkinter import filedialog as fd
  7.  
  8.  
  9. filename = fd.askopenfilename()
  10. pdf_document = fitz.open(filename)
  11.  
  12. terms='СМЕТА'
  13.  
  14.  
  15.  
  16. with open("outdata.txt", "w") as outputFile:
  17.     for current_page in range(len(pdf_document)):
  18.      page = pdf_document.loadPage(current_page)
  19.      if page.searchFor (terms):
  20.         #вывод в консоль
  21.         print("%s found on page %i" % (terms, current_page))
  22.         #вывод в txt
  23.         print("%s found on page %i" % (terms, current_page), file=outputFile)
  24.     outputFile.close()
  25.     os.system('outdata.txt')
Advertisement
Add Comment
Please, Sign In to add comment