AppleScript名:指定PDFの最初のページに大量のサークルアノテーションを添付する |
— Created 2017-06-16 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "Quartz" use framework "AppKit" set aHFSPath to (choose file of type {"com.adobe.pdf"} with prompt "Select PDF") 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 aPage to aPDFdoc’s pageAtIndex:0 set firstPage to (aPDFdoc’s pageAtIndex:0) –Remove Annotation my removeAnnotationFromPage:firstPage –Call by Reference –Get PDF size by Point set aBounds to aPage’s boundsForBox:(current application’s kPDFDisplayBoxMediaBox) set aSize to |size| of aBounds –Add Annotation repeat with xNum from 30 to ((width of aSize) – 30) by 25 repeat with yNum from 30 to ((height of aSize) – 30) by 25 set cAnn to (current application’s PDFAnnotationCircle’s alloc()’s initWithBounds:{origin:{x:xNum, y:yNum}, |size|:{width:20, height:20}}) (cAnn’s setValue:(current application’s NSColor’s redColor()) forAnnotationKey:(current application’s kPDFAnnotationKey_Color)) (firstPage’s addAnnotation:cAnn) end repeat end repeat –Save It aPDFdoc’s writeToFile:aPOSIX –Remove All Annotation from a Page. Call by Reference on removeAnnotationFromPage:aPage set anoList to (aPage’s annotations()) as list repeat with i in anoList (aPage’s removeAnnotation:i) end repeat end removeAnnotationFromPage: |
More from my site
(Visited 23 times, 1 visits today)