AppleScript名:指定PDFの最初のページからアノテーションを取得する |
— Created 2017-06-08 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "Quartz" set aHFSPath to (choose file of type {"com.adobe.pdf"} with prompt "Choose a PDF with Annotation") set aPOSIX to POSIX path of aHFSPath set aURL to (current application’s |NSURL|’s fileURLWithPath:aPOSIX) set aPDFdoc to current application’s PDFDocument’s alloc()’s initWithURL:aURL set pCount to aPDFdoc’s pageCount() set firstPage to (aPDFdoc’s pageAtIndex:0) –> (PDFPage) PDFPage, label 1 set anoList to (firstPage’s annotations()) as list if anoList = {missing value} then return –指定PDF中にAnotationが存在しなかった log anoList (* {(PDFAnnotationMarkup) Type: ’Highlight’, Bounds: (81, 624) [434, 53] , (PDFAnnotationSquare) Type: ’Square’, Bounds: (50, 419) [212, 162] , (PDFAnnotationSquare) Type: ’Square’, Bounds: (301, 107) [244, 484] } *) repeat with i in anoList set aBounds to i’s |bounds|() log aBounds (* {origin:{x:80.79, y:624.4106}, size:{width:433.6944, height:52.8918}} *) (* {origin:{x:50.05553, y:419.1671}, size:{width:212.27807, height:162.3308}} *) (* {origin:{x:300.6213, y:106.8405}, size:{width:244.0961, height:484.4566}} *) end repeat |
More from my site
(Visited 52 times, 1 visits today)