PDF FreeText annotations

There seems to be a bug with PDF FreeText annotations. Saving and reopening the record doesn’t make a difference. Similar things happened with different PDFs.

  1. Add a FreeText annotation

  1. Text is not shown in Details

  1. Add Details

4 - Summarize Highlights

5 - Open PDF in external app

I’ve also seen the opposite case where

  • after creating a FreeText annotation the text entered isn’t shown in Details
  • adding Details (assuming they could be used separately) overwrites the FreeText text.
1 Like

I am not seeing an issue with the text not appearing in the Document > Annotations inspector.

  • adding Details (assuming they could be used separately) overwrites the FreeText text.

@cgrunenberg: I am seeing this in the internal build as well.

It’s probably intended as the text of FreeText annotations is / should be stored in the PDFKit annotation’s contents property (which is what we see in “Details”, I think).

The PDFAnnotation class’s contents and setContents: methods let you get and set the textual content for a PDFAnnotationFreeText object.

One problem is that the FreeText isn’t always displayed in “Details”, the other is that the FreeText isn’t always updated when “Details” are edited.

Actually DEVONthink’s handling shouldn’t cause this issue as it tries to add details, not to overwrite the contents. However, the PDFkit internally seems to overwrite the contents in this case too. The next release will therefore show entered text in the details immediately to avoid this inconsistency.

1 Like

[Offtopic] Hi, two questions:

  • How does DEVONthink populate the PDF annotation inspector’s “Inhalt” column if an annotation wasn’t created via DEVONthink? I think I’ve read that it “tries” do so but couldn’t figure out when it succeeds. What I’ve found is that the column gets populated on a second script run but is there an annotation key that could be used to do it directly?

  • Do you know whether PDFKit automatically sets a offset if one creates two (highlight) annotations at the same bounds/quadPoints? Seems after the first one was created all following annotations have the same bounds, but all different to the first.

Actually this depends on the type of the annotation, e.g. in case of highlight annotations DEVONthink tries to retrieve the highlighted text if the annotation does not have any contents/details on its own.

Not that I’m aware of. How did you actually create this?

Seems PDFSelections created via PDFKit’s findString: are too small for DEVONthink. It seems to work if they are a bit resized. Not sure whether that’s a good idea, though. Thoughts?

set thisSelectionLine_BoundsForPage to {{477.58887080565, 53.3468387916}, {63.14715452304, 25.8436799418}}

set thisSelectionLine_BoundsForPage to my resizeRect(thisSelectionLine_BoundsForPage, 2)

on resizeRect(theBounds, theDiff)
		set theAmount to theDiff / 2
		set theBounds to {{((theBounds's item 1's item 1) - theAmount), ((theBounds's item 1's item 2) - theAmount)}, {(theBounds's item 2's item 1) + (2 * theAmount), (theBounds's item 2's item 2) + (2 * theAmount)}}
	on error error_message number error_number
		if the error_number is not -128 then display alert "Error: Handler \"resizeRect\"" message error_message as warning
		error number -128
	end try
end resizeRect

Retrieving the text of highlighted text is actually quite tricky due to issues of the PDFkit framework, DEVONthink already tries to adapt (increase) the bounds if necessary. In the end it depends a lot on the PDF document, its layout & used fonts.

1 Like