Search for word does not run #1618
-
I'm trying just a simple example where a couple of words are being replaced, but I can't replace a speficic word because the program doesn't work (the words commented are the ones that broke the code) (I'm trying to find Viviana but I can't). But if I write any other word it does work, that code does run, but if I change text it does not.
test.pdf Update 2: |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments 6 replies
-
If tried more and more, and the thing is, if the word I'm searching (text var) is in the pdf, the code does not work. |
Beta Was this translation helpful? Give feedback.
-
As I wrote: a reproducing file is required! |
Beta Was this translation helpful? Give feedback.
-
Ah, ok - I see the file now. |
Beta Was this translation helpful? Give feedback.
-
Doing this: >>> doc=fitz.open("test.pdf")
>>> page=doc[0]
>>> for r in page.search_for("en"):
a=page.add_highlight_annot(r)
a.update()
>>> doc.save("y.pdf")
>>> Looks as it should, doesn't it? |
Beta Was this translation helpful? Give feedback.
-
Yes, that's what I'm looking for, but you are using "search_for" which seems deprecated for me ( 'Page' object has no attribute 'search_for') is waiting for "searchFor". |
Beta Was this translation helpful? Give feedback.
-
No, I must ask you: which version do you use? |
Beta Was this translation helpful? Give feedback.
-
I put it at the end of the last update ( fitz 0.0.1.dev2). The one that was installed after using pip install |
Beta Was this translation helpful? Give feedback.
-
Package "fitz" has nothing to do with PyMuPDF! |
Beta Was this translation helpful? Give feedback.
-
That package cannot coexist with PyMuPDF in the same environment. |
Beta Was this translation helpful? Give feedback.
-
Okay, so I delete everything of fitz and install PyMuPDF, thought that they were the same, that fitz was PyMuPDF. |
Beta Was this translation helpful? Give feedback.
-
All that could have been found earlier, if you had used a complete bug report. |
Beta Was this translation helpful? Give feedback.
-
Then I need to install Mupdf, and then pymupdf right? This is not just a python module. All this came because in everything I've found on the internet seems that fitz is the package of Pymupdf |
Beta Was this translation helpful? Give feedback.
-
You also kept your operating system secret. python -m pip install -U pip
python -m pip install pymupdf No separate MuPDF installation required. |
Beta Was this translation helpful? Give feedback.
-
I'm windows sorry |
Beta Was this translation helpful? Give feedback.
-
Unistalled fitz, installed pymu ( PyMuPDF 1.16.7) and upgrade pip and I keep getting the same error: |
Beta Was this translation helpful? Give feedback.
-
PyMuPDF is not in Anaconda. Use native pip as I wrote. |
Beta Was this translation helpful? Give feedback.
-
Yes, I used pip to install it on anaconda, that version is shown in the anaconda prompt. |
Beta Was this translation helpful? Give feedback.
You also kept your operating system secret.
If it is Mac, Linux or Windows, then there exist wheels.
If true, you only need to do this:
No separate MuPDF installation required.