Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe you can replace your code by indentify a class like this #2

Open
sigurn2 opened this issue May 6, 2024 · 0 comments
Open

Maybe you can replace your code by indentify a class like this #2

sigurn2 opened this issue May 6, 2024 · 0 comments

Comments

@sigurn2
Copy link

sigurn2 commented May 6, 2024

import PyPDF2
class pdfFile:
    def __init__(self, file) -> None:
        self.file_path = open(file, 'rb')
        self.pdfReader = PyPDF2.PdfReader(self.file_path)

    def getPageCount(self):
        return len(self.pdfReader.pages)

    def extractData(self, page):
        return self.pdfReader.pages[page - 1].extract_text()
    
    def close(self):
        self.pdfFile.close()

    def pages(self):
        return self.pdfReader.pages()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant