Closed dzklaim closed 6 years ago
On tablet I have tried many readers and only ezPDF seem to recognize annotations.
On desktop linux Okular has no problems recognizing annotations.
But none of the following can read the annotations wrote to pdf
in pdf-tools
:
I think the problem was that I set the Rect entry of the annotation to the empty rectangle, but the specification says to ignore all markup outside this rectangle. With commit 30be1f75cc47a719ba88e4a2c2af2df4f05ba934 I changed it to the smallest rectangle containing all markup. I verified that it works in Acrobat and Evince, please check it out.
Oh, wow, that would be wonderful! Is this backward compatible, i.e. I could still open PDFs with markups from previous pdf-tools, and can then save those as PDFs with markups supported by other platforms?
No, those would be in need of fixing. The following function should accomplish this, be careful.
(defun pdf-annot-fix-broken-edges (&optional file-or-buffer verbosep)
(interactive (list (current-buffer) t))
(let ((nfixed 0))
(dolist (a (pdf-info-getannots nil file-or-buffer))
(let-alist a
(when (and (memq .type '(squiggly underline strike-out highlight))
(equal .edges '(0.0 0.0 0.0 0.0)))
(pdf-info-mvannot
.id
(apply #'pdf-util-edges-union
(apply #'append
(mapcar
(lambda (e)
(pdf-info-getselection .page e nil file-or-buffer))
.markup-edges)))
file-or-buffer)
(cl-incf nfixed))))
(when verbosep
(message "Fixed %d annotations" nfixed))
nfixed))
Just compiled https://github.com/politza/pdf-tools/commit/30be1f75cc47a719ba88e4a2c2af2df4f05ba934, uninstalled pdf-tools
from list-packages
then installed the compiled .tar
archive. pdf-tools
seems to be working, but neither the old highlighted annotations with text nor a newly created one got picked up by other readers.
Just saw the function you mentioned above. Running it inside M-:
while the pdf was open in pdf-tools
with a highlighted annotation did not help (highlight still haven't got picked up by other readers).
I just pushed another update.
You would also have to reload the library or restart Emacs.
Use M-x in the Pdf's buffer.
Great, that fixed it! I had to run the above function on the old pdf (some comments were lost when I used https://github.com/politza/pdf-tools/commit/30be1f75cc47a719ba88e4a2c2af2df4f05ba934 but I guess I'll have to live with that since I had no backups) before it shows up in other viewers. This is a major usability upgrade 👏 👏
What do you mean by "lost contents", how ?
I had multiple annotation content/text corresponding to highlights in a few PDFs. Only very old ones, or ones that are at the beginning (roughly 10%) of the document are still there after loading the PDFs with the newly compiled pdf-tools, while newer annotations (at around 60-100% of the PDFs) were completely lost. In other terms, it was as if my annotations made last night was not there while the ones I made during last week was there.
It may or may not be a pdf-tools
issue, as I did killall emacs
yesterday night, which might produce the same result, if the annotations weren't written to PDFs upon C-c C-c
.
The new code affects new annotations only, so I guess it was due to killing Emacs without saving.
Dear Politza I get exactly the same issue with latest version of pdf-tools under OSX: annotations do not appear when I open the file with Aperçu or Acrobat. Do you know how I could fix that (if there is a way)? I find your package awesome, and this is the only feature that prevent me to use it instead classical pdf viewers.
Please install the latest version of this package, force a rebuild by removing the epdfinfo executable and then see if the issue persists.
I just tried that, and get the same result: in acrobat (or Apercu), i only can see an empty white box instead of the comment. But i don't want to take too much of your time. best.
Can you upload an example PDF somewhere ?
duque2016.pdf There is an annotation p2, top of second paragraph.
That does not look like the annotation on page 2 was created with pdf-tools. I've added an annotation are you able to see that one in the other viewers. duque2016-2.pdf
Well... yes It was, actually... Do you want me to do it again?
The problem maybe come from the fact that i tried to open the annotation from another pdf reader. Here is a new document, with an annotation made in pdf-tools, not opened in any other reader Angelini2015.PDF (p.1).
It still doesn't work when I try to read annotated documents on preview (mac os). I tried with some documents I annotated and with duque2016-2.pdf
I obtain white square with no annotation:
It works on acrobat
it is not possible to view an annotation in evince for example created using the highlight text + annotation functionality. I can see the the highlighted text, the indication that there is an annotation on the sidepane but it seems that evince fails to recognize that there is some text associated with the highlighted text.