Merging documents

When I select two searchable PDFs and combine them, I get a new document with just the text of both PDFs.

Can DT merge pdfs into a multiple page PDF? I know preview can, and PDFPen pro can (even has an applescript I read) but one more app in the process :slight_smile:

This script might be what you are looking for. It requires at least 10.4 OS.

Of course with dtpro 2.0 you can drag the thumbnails between documents. Try opening a separate window for the “source” document, selecting the thumbnails, and dragging them into the thumbnail area of the target document. It’s a bit buggy still, but it works!

I use the script when I’ve got heavier duty merges to do…


--merge selected pdfs with leopard's python merge utility
--by eric oberle v1.1

property temp_directory : "/tmp/devonthink/combine-pdfs"
property export_path_posix : temp_directory & "ocr/"
property export_path_nonposix : (POSIX file export_path_posix)

tell application "DEVONthink Pro"
	set cupos to selection of window 1
	set reimport_location to current group
		if reimport_location is {} then set reimport_location to {}
	on error
		set reimport_location to {}
	end try
end tell

---main loop

	do shell script ("mkdir " & temp_directory & ";rm -r  " & temp_directory & "/*")
end try
tell application "DEVONthink Pro"
	set this_record to first item in cupos
	set the_name to (the name of this_record)
	if the_name does not end with ".pdf" then
		set the_name to the_name & "-complete.pdf"
	end if
	set the_comment to comment of this_record
	set the_kind to kind of this_record
	set the_url to URL of this_record
	repeat with this_item in cupos
		if the name of this_item does not end with ".pdf" then
			set the name of this_item to ((the name of this_item) & ".pdf")
			set the_comment to the_comment & return & comment of this_item
		end if
		my export_pdf(this_item, temp_directory)
	end repeat
	set merge_pdf_command to "python '/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/'  -o '" & temp_directory & "/joined.pdf'  " & temp_directory & "/*.pdf"
	do shell script (merge_pdf_command)
	set merged_pdf to import (temp_directory & "/joined.pdf") to reimport_location
	set comment of merged_pdf to the_comment
	set URL of merged_pdf to the_url
end tell

on export_pdf(the_record, temp_directory)
	---returns finder-path of exported file
	tell application "DEVONthink Pro"
		if the parent of the_record is not {} then
			set reimport_location to the first item of the parent of the_record
			set reimport_location to root of current database
		end if
		set exported_file_with_path to export record the_record to temp_directory
		log "exported_fwp " & exported_file_with_path
	end tell
	return {exported_file:exported_file_with_path, reimport_loc:reimport_location}
end export_pdf