As to “creating a PDF from DT’s data
property”:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "PDFKit"
use scripting additions
tell application id "DNtp"
set rec to get record with uuid "x-devonthink-item://E2D5F820-37B7-402C-A642-869BAD579F5E"
set pdfdata to data of rec
set nsData2 to my NSDataFromASData(pdfdata)
set pdfDoc to (current application's PDFDocument's alloc()'s initWithData:nsData2)
log pdfDoc's pageCount()
end tell
on NSDataFromASData(asData)
return (current application's NSArray's arrayWithObject:asData)'s firstObject()'s |data|()
end NSDataFromASData
That worked, at least for the single PDF document I tried it with.
I didn’t invent that, I just scrapped it from the net. Seems to indeed do what was asked for. If I understood what was asked for correctly.