Devonthink PDF issue in Safari Reader Mode

I often save PDFs I am viewing in Safari’s Reader mode directly to Devonthink as a PDF.

Up until the most recent update (3.7.2) these always ended up in my global inbox as a pdf document titled “Name of Webpage”.

Now, they are saved as “unnamed document” which is a problem as I save many pdfs. They now all end up with the same name.

As far as I can tell:

  1. This only happens in Safari’s Reader mode. Regular Safari pages save as properly named pdfs (But have all the ads and other web junk - not an option).

  2. If I just save as a PDF (to a finder folder) the PDFs in either mode save with their proper name.

  3. This bug is reproducible on all 3 of my Devonthink seats - so I don’t think it is a setting error. Two are running Big Sur, one is still on Catalina.

This used to work correctly. Not sure when it started as I have been away for 3 weeks.

This has been reported to Development. Thanks for your patience and understanding.

I can confirm the same thing happens here.

Here is a workaround, using a smart rule and script:

URL is not is left intentionally blank. You’ll want to change the trigger to on import (Edit: no you won’t, currently this rule will only work when triggered manually, see my post below.)

The script is as follows:

-- includes sections from C. Grunenberg: Set name to title of web page
-- those sections Copyright C. Grunenberg

on performSmartRule(theRecords)
	tell application id "DNtp"
		try
			repeat with theRecord in theRecords
				set theURL to URL of theRecord
				set this_source to download markup from theURL
				if this_source is not missing value then
					set this_title to get title of this_source
					if this_title is not missing value and this_title is not "" then set the name of theRecord to this_title
				end if
			end repeat
		on error error_message number error_number
			if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		end try
	end tell
end performSmartRule

There is something else going on here too; @cgrunenberg: the smart rule above will not trigger automatically, even when set to on import (or on creation); the reason is that as the item arrives in the inbox, it has no URL; that is added moments after it arrives. That also means that the script fails even if the URL is not condition is removed. When I added a line display dialog theURL it will display a blank dialog - the URL is empty. Immediately after arriving - or if the rule is active, then immediately after the rule has failed with AppleEvent timed out the URL is added to the document.

@bluefrog @cgrunenberg You can perform this simple test:

Use a rule which triggers on importing name matches unnamed document. Set the action to Move the item to the inbox of another database. Print as PDF to DT from the reader view in Safari. The item will be moved to the inbox of the other database and will never receive a URL. (This is not to detract from the possibly unrelated bug the OP has reported; although I’m not convinced that is a DT problem - if I print the PDF to Acrobat, the same thing happens.)

From my testing, it’s not happening in Catalina, just Big Sur.

One of my seats is a 2012 iMac running Catalina 10.15.7.

The “bug” definitely happens on that computer. Every time.

I’m not sure whether Jim was referring to my report or yours; I fear your report is not caused by DEVONthink - if I print a PDF to Adobe Acrobat from the Safari reader view, the document is also called “unnamed document”. Saving (as per your point 2 in the original post) is different to printing to PDF (and that may be another workaround - save to a folder in Finder, index that folder in DT and set a smart rule to automatically move the file to the database).

@Blanc Thanks.

I can now report that your hunch that this might not be a Devonthink issue might be correct. I get the same problem when saving a PDF to Evernote on both Big Sur and Catalina.

If that is correct, the ability to save Safari Reader web pages as named PDFs is important (at least to me) so we’ll see what the solution is.

When is said “Saving as a PDF” I actually meant “Printing as a PDF.” None of the web pages in any of my examples were orginally PDFs.

Thanks for the feedback. My solution above (smart rule/script) will work manually, and apparently possibly automatically on Catalina. As far as Big Sur is concerned, I’m working on a workaround :wink:

And here you go:

In addition to my smart rule/script above, you need a second smart rule (which has to be above the first one in the list):

The script is

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			perform smart rule trigger import event record theRecord
		end repeat
	end tell
end performSmartRule

In combination this will automatically rename PDFs printer from Safari’s reader view. Tested, and it works here (Big Sur).

The next release will both work around the Safari issue on 11.4 and fix the smart rule issue.

4 Likes

I am having this problem (which was fixed) again.

Now running Devonthink 3.9.3 on OSX Sonoma 14.0.

When I print a page as a PDF from Safari to Devonthink I get an “unnamed document” When I print a PDF to the desktop it is named properly. When I print a page as a PDF to Devinthink NOT in Reader mode it works with the correct name. I tested this on articles from both the Wall St Journal and my local newspaper.

Seems that Sonoma needs a different workaround as this pretty useless name is set by Safari (or the printtool), not by DEVONthink. We’ll check this.

And the next maintenance release will fix this, the issue is actually identical to the issue that the URL is not grabbed from Safari on Sonoma.

I am still having this problem. ONLY when safari is in Reader Mode.

Running Devonthink 3.9.4 on OSX Sonoma 14.2. Not sure if 3.9.4 is the update you referenced above.

it is working in Sonoma 14.2 with an internal build. Thanks for your patience and understanding.