Batch Covert Links to PDF?

Is there any way to easily modify the “Batch convert links to web archives” to convert to PDFs instead? I am not much of a scripter but I looked in the DT script dictionary but didn’t se a command to replace the “download to archive.”

I would greatly appreciate any suggestions since I think the PDF format is greatly superior to web archives and would save me alot of work in the future.

You might want to check out this excellent script. It’s not perfect, but batch-converting URLs to PDFs is a bit difficult, I assume, because HTML is generally so reliant upon the width of the application window, etc.

Here’s a script for v2 to convert all selected documents to paginated PDFs:


-- Convert documents to paginated PDFs
-- Created by Christian Grunenberg on Mon Dec 01 2008.
-- Copyright (c) 2008. All rights reserved.

tell application id "com.devon-technologies.thinkpro2"
	try
		set theSelection to the selection
		if theSelection is not {} then
			set frontMostWindow to think window 1
			repeat with theRecord in theSelection
				set theName to (name of theRecord) as string
				set theurl to (URL of theRecord) as string
				set theWindow to open window for record theRecord
				repeat while loading of theWindow
					delay 1
				end repeat
				set theData to paginated PDF of theWindow
				set thePDF to create record with {name:theName, URL:theurl, type:PDF document}
				set data of thePDF to theData
				if theWindow is not the frontMostWindow then close theWindow
			end repeat
		end if
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

Tip: Use…

set theData to PDF of theWindow

…instead of…

set theData to paginated PDF of theWindow

…to create single-page PDF documents.

Thanks so much for this script…it works really well on both links and webarchives. I tried it out also on RFTD files but the links weren’t preserved but I figured out you can convert RFTD to HTML first and then to PDF which keeps the links intact.

There a couple of issues:

  1. The conversion scripts, menu items, and content menu items for converting files are all over the place. Its hard to remember what is possible with checking all these places. Any way of bringing some order to this?

  2. Ideal for me, and perhaps others, would be a way to annotate PDF files that were created from web pages with the URL. We already have a script to to this for RFTD. When PDF annotation goes live for DT, will this be possible??

Hmmm…just realized that going from RTFD to HTML and then to PDF means I lose the original images. Any way to convert directly from RFTD to PDF without losing the links???

I must be doing something wrong. I copied the text of the script in the script editor and then saved it as a script. This archive I saved in the script folder. I select an webarchive, then the script and nothing happened. Then I tried with a link. I’ve done everythin many times with the same results.

What I’m I missing?

thanks,

roberto