Print PDF to Devonthink Pro.scpt

If I want to print a .pdf into DT, I go into the document’s print menu, select PDF and then “Print PDF to DevonThink Pro.scpt”. And each time I get a message saying it failed.

My workaround is to print the .pdf to the desktop and then drag it into the DT database, but I know there must be a way to print it directly into DT.

What am I doing wrong here?

Are you using DEVONthink Personal or DEVONthink Pro? If the latter, which version?

Sorry. Pro 1.1.1.

I’m getting a different sort of failure. When I try to use the “Save to DEVONthink Pro.scpt” item in Firefox, everything works as expected. No problem.

Sometimes, when I try to use it in Safari (which I use 95% of the time), I get the print confirmation dialog, I get to select a folder in DTP, and then the process hangs. The dialog box says “Processing: page 1” and the blue thermometer reaches one or two pixels short of 100%, and then it’s stuck… I have to force-quit Safari to regain control.

This is repeatable on certain pages… I can’t identify the common thread, but I suspect they all use Java or AJAX. It’s avoidable by using Firefox, but I tend to prefer Safari, and occasionally I forget and try the print-to-PDF trick. Big mistake. :frowning:

Running 10.4.7 with Safari 2.0.4 (419.3). Any ideas what’s going wrong?

In ;your Home directory, check /Library/PDF Services/. In the PDF Services folder you should find this script: “Save to DEVONthink Pro.scpt”.

If the script isn’t there, in DT Pro select the menu item Help > Install Add-Ons. Make sure all the items are checked, and press Install.

To eliminate a possible cache problem, restart the computer. Then open an application with a printable document, such as a browser’s display of a Web page, and press Command-P to “print” it. When the Print panel appears, click on the PDF button, then choose the option “Save to DEVONthink Pro.scpt”. You will have the option of the location to which the PDF will be saved.

I’ve never run into that problem when using the script to “print” a page to DT Pro. But perhaps I’ve never visited the pages you encounter.

Could you post the URL of a page that presents a problem under Safari?

This gets more interesting. I just discovered the script DOES work with Safari (v. 2.0.4) … and hadn’t been working with Firefox (v. 1.5.0.4).

So then I tried printing this page from both browsers. With Safari, the script printed the entire page (it came to four .pdf pages inside DT.)

With Firefox, it printed only the FIRST .pdf page of this page.

So I’m scratching my head here.

Any ideas how I can get it to work well with Firefox?

I don’t know why Firefox couldn’t print to PDF.

Firefox is a good browser in many ways, but it’s a 98-pound weakling when it comes to working with OS X Services, and has extremely limited scripting capabilities. I don’t use it.

Well, there are two variations of the failure. Sometimes, the thermometer appears to get “stuck” on the last page printed to PDF. In those cases, I just move the Print dialog box out of the way and do something else… Safari is nonresponsive, but it will eventually free up. This just happened right now on this page, as a test (“this page” meaning Devon Technologies User Forum).

The other failure mechanism is when the thermometer gets stuck on the first page printed to PDF. When this happens, no amount of time will suffice to get it un-stuck… I left it alone for twenty minutes this morning, and eventually had to force-quit. This was repeatable across multiple pages at the New York Times website.

It’s behind a password, but if you’re willing to sign up for their 14-day free trial, you can test it at http://select.nytimes.com/gst/abstract.html?res=F20B17FE355B0C708CDDAC0894DE404482. Very consistent failure.

My workaround is to use the similar script to print to Yojimbo, then drag the PDF from Yojimbo to DTPro. That is silly…

Just for what it’s worth… this failure just happened to me again on the Office Depot site with the DTPro 1.2 update.

If you want to experiment, try http://www.officedepot.com/textSearch.do?uniqueSearchFlag=true&Ntt=420-920-090&x=33&y=15.

I could reproduce this and the symptoms look similar to what we experience when the PDFKit chokes on a file. Most of the time it will help if we try it again. I was under the impression that the application did this already but since it doesn’t, I’m posting the temporary workaround that you could try.

Replace the contents of “Save to DEVONthink Pro.scpt” with this:



on open these_items
	set this_app to (path to «constant afdregfp» as string)
	if this_app does not contain "DEVONthink Pro" then
		try
			set this_file to item 1 of these_items
			
			tell application this_app
				try
					set this_name to the name of window 1
				on error
					set this_name to ""
				end try
				
				repeat while this_name is ""
					display dialog "Saving to DEVONthink Pro. Please enter a file name:" default answer this_name
					set this_name to the text returned of the result
				end repeat
			end tell
			
			tell application "DEVONthink Pro"
				activate
				if not (exists current database) then error "Please open a database before using this script!"
				set theDestination to display group selector "Destination" buttons {"Cancel", "OK"}
				set theRecord to import this_file to theDestination
				if theRecord is missing value then
					set theRecord to import this_file to theDestination
				end if
				try
					set the name of theRecord to this_name
				on error
					error "Import failed of PDF at: " & this_file
				end try
			end tell
			
			try
				if this_app contains "Safari.app" then
					tell application "Safari" to set this_url to the URL of document 1
					tell application "DEVONthink Pro" to set the URL of theRecord to this_url
				else if this_app contains "Mail.app" then
					tell application "Mail"
						set theSelection to the selection
						set this_sender to the sender of item 1 of theSelection
					end tell
					tell application "DEVONthink Pro" to set the URL of theRecord to this_sender
				else
					tell application this_app
						set curr_doc_path to path of document 1
						if (curr_doc_path is not missing value) and (length of curr_doc_path > 1) then
							set doc_url to "file://" & (POSIX path of curr_doc_path)
							tell application "DEVONthink Pro" to set the URL of theRecord to doc_url
						end if
					end tell
				end if
			end try
			
		on error error_message number error_number
			if the error_number is not -128 then
				try
					display alert "DEVONthink Pro" message error_message as warning
				on error number error_number
					if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
				end try
			end if
		end try
		tell application this_app to activate
	end if
end open


Stephen, I can’t replicate your problem when “printing” from either Safari or DEVONagent, using the “Save to DT Pro.scpt” script.

The Home Depot page printed immediately. So did several New York Times pages. No hangups.

Note: I greatly prefer capturing in RTFD (selected text and images) from sources such as the New York Times, as there are often useful clickable links. In addition, by either selecting only the text and images that I want, or by selecting the printer friendly version that’s available, I don’t have lots of adds and other irrelevant material in the capture.

Thanks for the code. I tried it, and the script got hung on again. I had to Force-Quit Safari just so I could log back in and type this reply.

Like the old one, the revised script calls DTPro, I get to pick which group to file the PDF in, the PDF actually gets created and filed correctly, but I have a print dialog stuck on “Printing Page 1” forever… which makes Safari nonresponsive.

Thanks for looking at this!

I’m getting exactly the same problem. I use DEVONthink Pro Office 1.3.3. I can print to PDF if I drag an alias of DEVONthink to the PDF Services folder and print to that but if I use the DEVONthink script I have the problem and solution described above. I’ve mostly tried to print from the NY Times site but have also crashed from the LA Times and The Atlantic sites.

I use Saft with Safari and I’ve got years of useless junk on my Mac that also could be interfering.

There are a great many hacks of the operating system out there, including Unsanity haxies, input manager plugins such as Saft and 1PassWord and so on.

Some of those hacks do things that users like very much.

But I prefer keeping my computers with a pretty stock operating system. There are three reasons:
Third party developers rarely have resources for quality assurance testing comparable to Apple;
Hacks are subject to ‘breaking’ (and causing problems) every time Apple puts out updates; and
I want my computers and applications to “just work” without stability problems and without data corruption or loss.

There was a time long ago when I eagerly installed every new software “gadget” including appearance themes. My experience was that I spent more time trying to clean up my computers than getting work done.

Experience in software support reinforces my “stock OS” philosophy. :slight_smile:

Tell me that you can’t import PDF files into DT Pro and my first (and probably correct) guess is that you installed a certain haxie. Tell me that DEVONagent crashes all the time, and I can tell you (probably correctly) which input manager you installed, and that it needs immediate updating.

But the possibilities of OS errors caused by multiple error-producing OS hacks can be bewilderingly complex and hard to diagnose.

The bottom line is that I can’t reproduce the problems reported in this thread. The print to PDF script works in every application I use, as well as Firefox. It has never hung up.

I haven’t had to resort to a backup DT Pro or DT Pro Office database for going on three years. (But I do backups frequently, as a hard drive could fail at any time.)

Perhaps I’m losing out by not taking advantage of OS hacks that could improve my workflow or make my work more convenient. On the other hand, I don’t have stability problems, everything works predictably and reliably and I don’t lose data – so I don’t have to spend time and effort diagnosing and trying to correct or recover from problems. On balance, I think I’m well ahead of the game.

I have this same problem too. The PDF does get created but Safari hangs. I’d like this addressed.

A previous participant in this thread chiming in…

I love Safari, but can’t function without Saft (which remembers open tabs and windows when I mistakenly/forgetfully quit Safari, or when Microsoft Entourage wedges my machine so badly that I have to reboot).

Sadly, Saft is a proven culprit for this problem with DEVONthink, and I suspect it in some other instances.

I’ve actually given up and shifted to Firefox. Ugly and irritating, but it seems more stable, and I certainly can print to PDF for DEVONthink from it. And it can be set to remember windows/tabs!

PS – I haven’t experimented with Safari 3 yet. Don’t know if it fixes this or not.

DEVONagent remembers and reopens the tabs that were open on quit.

Tabs are great for keeping a small number of pages immediately available. I’ve got six tabs that I use all the time.

But I’ve got over a hundred sites that I routinely check, some more often than others. It would be an inefficient use of computer resources, as well as poor ergonomics, to try to use tabs to hold all of those pages. So I handle my collection of favorite sites as bookmarks in my DT Pro database, organized by subgroups in my Bookmarks group. Works for me, with fast access (my Bookmarks group and my Scientific Journals subgroup of bookmarks are always open views in my database) and good working environment providing quick and easy choice of data capture options.

I would be willing to bet that with that setup I can easily win a speed contest to select and capture a set, say, of 50 specified new articles (some as rich text, some as HTML, some as WebArchive, some as PDF) from among my set of favorite sites – against someone using Firefox or Safari with tabs. But that’s not really the point.

The point is to have a working environment that makes it simple and easy to find and capture information into a database. Then one can forget about the process and concentrate on the information. For it’s all about the information, in the long run.

I’m not arguing that everyone should use my procedures and tools. On the contrary, different people will prefer different procedures and tools. What’s important for every user is to discover a working environment that’s comfortable enough and efficient enough to “disappear” and let the user concentrate on the information that’s sought.

Stephen

sorry for a quick reply only: Do a google search for “SafariStand”. It does remember open tabs and a lot more. I have used it because I really missed Opera’s functionality when switching from Windows (Opera for the Mac was very unstable on my machine).
So you can basically continue using Safari which is well integrated with DevonThink according to my experience and oh, did I mention it is free?
Hope it helps
Prion

I would like to recommend OmniWeb - especially for those who make extensive use of tabs. It has the ability to define workspaces of tabs that can be named, organized, made into snapshots … but it is not free (very affordable though).

It is based on the Webkit and uses therefore the same engine as Safari and DT / DA.

/Sven