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 50 repeat with yNum from 30 to ((height of aSize) – 30) by 50 set squAnn to (current application’s PDFAnnotationSquare’s alloc()’s initWithBounds:{origin:{x:xNum, y:yNum}, |size|:{width:40, height:40}}) (squAnn’s setValue:(current application’s NSColor’s blueColor()) forAnnotationKey:(current application’s kPDFAnnotationKey_Color)) (squAnn’s setValue:(current application’s NSColor’s clearColor()) forAnnotationKey:(current application’s kPDFAnnotationKey_InteriorColor)) (firstPage’s addAnnotation:squAnn) 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 33 times, 1 visits today)