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

Access to plain text of a page? #12

Closed
JorjMcKie opened this issue May 28, 2015 · 6 comments
Closed

Access to plain text of a page? #12

JorjMcKie opened this issue May 28, 2015 · 6 comments
Labels

Comments

@JorjMcKie
Copy link
Collaborator

Is there a way to access the text contained in a page and e.g. analyze it inside Python?

@rk700
Copy link
Contributor

rk700 commented May 29, 2015

@JorjMcKie, yes there should be. I'll add the API for extracting image/text from a page.

@JorjMcKie
Copy link
Collaborator Author

Hi @rk700,
it is good to see you could find some time in the middle of your big change of life! I hope everything is turning out well for you.
In the meantime I have been trying to continue some of the work.

  • some stuff indocumentation
  • a solution for a table of contents
  • added a close function for PDFs, so that the running process can delete / rename the input PDF. I have been guessing here: is it sufficient to just do a pdf_close_document? What about other file types?

I am afraid, I might have destroyed your change concerning text extraction? I will try it out ...

@rk700
Copy link
Contributor

rk700 commented Jun 4, 2015

@JorjMcKie, thank you for your work on the project! Especially when I could not devote too much time on it.

For closing doc, I think we can open a new issue. Currently ,fz_drop_document, in which doc is closed, happens in the destructor of the Document object. That is, the document will not be closed before there are still python references to it. But usually, the destructor is not called as soon as there're no references. So we should add an explicit closing function and maybe then remove the Document destructor. BTW, fz_drop_document can deal with all the supported doc types.

And don't worry about the text extraction code, it can be recovered easily from the commit history:)

@JorjMcKie
Copy link
Collaborator Author

@rk700, I have done a "repair" to the extractText, so it again works.
For the close() issue: I did add a call to pdf_close_document in fitz.i. And it worked (see this large example for editing table of contents)! Of course I do not know all consequences.

@rk700
Copy link
Contributor

rk700 commented Jun 4, 2015

@JorjMcKie, the global context would live as long as the module, so it is freed when the program exits. And we can use the general function fz_drop_document for other types of files, since it will call different closing function for different types.

@JorjMcKie
Copy link
Collaborator Author

Text extraction tested - closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants