This script could be used in case of rich text documents, therefore Word files have to be converted via Data > Convert > To Rich Text first.
-- Convert documents to (paginated) PDFs
-- Created by Christian Grunenberg on Mon Dec 01 2008.
-- Copyright (c) 2008-2011. All rights reserved.
tell application id "com.devon-technologies.thinkpro2"
try
set theSelection to the selection
if theSelection is not {} then
show progress indicator "Converting..." steps (count of theSelection)
set theWindow to missing value
repeat with theRecord in theSelection
set theName to (name of theRecord) as string
step progress indicator theName
if cancelled progress then exit repeat
set theType to type of theRecord
if theType is not group and theType is not feed and theType is not smart group then
if theWindow is missing value then
set theWindow to think window of (open tab for record theRecord)
else
set record of theWindow to theRecord
end if
repeat while loading of theWindow
delay 0.5
end repeat
set theData to paginated PDF of theWindow
-- set theData to PDF of theWindow
try
set theParents to parents of theRecord
set thePDF to create record with {name:theName, URL:(URL of theRecord) as string, type:PDF document} in (item 1 of theParents)
repeat with i from 2 to (count of theParents)
replicate record thePDF to (item i of theParents)
end repeat
set data of thePDF to theData
set creation date of thePDF to creation date of theRecord
set modification date of thePDF to modification date of theRecord
set comment of thePDF to comment of theRecord
set label of thePDF to label of theRecord
end try
end if
end repeat
if theWindow is not missing value then close theWindow saving no
hide progress indicator
end if
on error error_message number error_number
hide progress indicator
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell