Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import fitz
- import tkinter
- import os
- from tkinter import filedialog as fd
- filename = fd.askopenfilename()
- pdf_document = fitz.open(filename)
- terms='СМЕТА'
- with open("outdata.txt", "w") as outputFile:
- for current_page in range(len(pdf_document)):
- page = pdf_document.loadPage(current_page)
- if page.searchFor (terms):
- #вывод в консоль
- print("%s found on page %i" % (terms, current_page))
- #вывод в txt
- print("%s found on page %i" % (terms, current_page), file=outputFile)
- outputFile.close()
- os.system('outdata.txt')
Advertisement
Add Comment
Please, Sign In to add comment