PDFContext

[CGPDFContext]kCGPDFX(断念)

オプション指定するだけじゃダメなの?
現時点ではPDFXで書き出せない-->方法わかる人教えてほしい



#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use framework "PDFkit"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL
property refNSArray : a reference to refMe's NSArray
property refNSMutableDictionary : a reference to refMe's NSMutableDictionary
property refNSSortDescriptor : a reference to refMe's NSSortDescriptor

property refPDFDocument : a reference to refMe's PDFDocument

set objFileManager to refMe's NSFileManager's defaultManager()

#####ここはご自分で設定してね
####ユーザーパスワードは利用者に伝える用
set strUserPassword to "1234"
###管理者パスワード
set strOwnerPassword to "4321"


####ダイアログで使うデフォルトロケーション
tell application "Finder"
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell

####UTIリスト PDFのみ
set listUTI to {"com.adobe.pdf"}

####ダイアログを出す
set aliasFilePath to (choose file with prompt "PDFファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

set strFilePath to POSIX path of aliasFilePath
####ドキュメントのパスをNSString
set ocidFilePath to refNSString's stringWithString:strFilePath
####ドキュメントのパスをNSURLに
set ocidNSUrlPath to refNSURL's fileURLWithPath:ocidFilePath


####ドキュメントの初期化
set ocidActiveDoc to refPDFDocument's alloc()'s init()
set ocidActiveDoc to refPDFDocument's alloc()'s initWithURL:ocidNSUrlPath

####現在の設定
set boolPrinting to ocidActiveDoc's allowsPrinting() as boolean

set ocidPdfOptionDict to refNSMutableDictionary's alloc()'s initWithCapacity:0

#####
###
ocidPdfOptionDict's setObject:("JC201103" as text) forKey:"kCGPDFXOutputConditionIdentifier"
ocidPdfOptionDict's setObject:("GTS_PDFA1" as text) forKey:"kCGPDFXOutputIntentSubtype"
ocidPdfOptionDict's setObject:("Japan Color 2011 Coated" as text) forKey:"kCGPDFXInfo"
ocidPdfOptionDict's setObject:("http://www.color.org" as text) forKey:"kCGPDFXRegistryName"
ocidPdfOptionDict's setObject:("Japan Color 2011" as text) forKey:"kCGPDFXOutputCondition"
ocidPdfOptionDict's setObject:("Japan Color 2011 Coated" as text) forKey:"kCGPDFXDestinationOutputProfile"


##ICCProfile
ocidPdfOptionDict's setObject:("GTS_PDFX" as text) forKey:"kCGPDFContextOutputIntent"
ocidPdfOptionDict's setObject:("PDF/X-1a:2003" as text) forKey:"kCGPDFContextOutputIntents"
ocidPdfOptionDict's setObject:("PDF/X-1a:2003" as text) forKey:"kCGPDFContextCreateLinearizedPDF"
ocidPdfOptionDict's setObject:("PDF/X-1a:2003" as text) forKey:"kCGPDFContextCreatePDFA"

(*
GTS_PDFX
ISO 15930 (all parts)
GTS_PDFA1
ISO 19005-1:2005 (PDF/A)
ISO_PDFE1
(*
PDF/X-1:2001
PDF/X-3:2002
PDF/X-1a:2003
PDF/X-2:2003
PDF/X-3:2003
PDF/X-4
PDF/X-4p
PDF/X-5g
PDF/X-5n
PDF/X-5pg
PDF/X-1:2001
PDF/X-1a:2001
*)

*)


set boolSaveJob to ocidActiveDoc's writeToURL:ocidNSUrlPath withOptions:ocidPdfOptionDict

|

[CGPDFContext]メタデータの書き込み(保存時)

Keywordsのリスト系 はAcrobatの表示と互換が無いので設定するなら…『1つ』がいいかも



#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use framework "PDFkit"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL
property refNSArray : a reference to refMe's NSArray
property refNSMutableDictionary : a reference to refMe's NSMutableDictionary
property refNSSortDescriptor : a reference to refMe's NSSortDescriptor

property refPDFDocument : a reference to refMe's PDFDocument

set objFileManager to refMe's NSFileManager's defaultManager()



####ダイアログで使うデフォルトロケーション
tell application "Finder"
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell

####UTIリスト PDFのみ
set listUTI to {"com.adobe.pdf"}

####ダイアログを出す
set aliasFilePath to (choose file with prompt "PDFファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

set strFilePath to POSIX path of aliasFilePath
####ドキュメントのパスをNSString
set ocidFilePath to refNSString's stringWithString:strFilePath
####ドキュメントのパスをNSURLに
set ocidNSUrlPath to refNSURL's fileURLWithPath:ocidFilePath


####ドキュメントの初期化
set ocidActiveDoc to refPDFDocument's alloc()'s init()
set ocidActiveDoc to refPDFDocument's alloc()'s initWithURL:ocidNSUrlPath

####現在の設定
log (ocidActiveDoc's documentAttributes()) as record


log ((ocidActiveDoc's documentAttributes())'s valueForKey:"Title") as text
log ((ocidActiveDoc's documentAttributes())'s valueForKey:"Author") as text
log ((ocidActiveDoc's documentAttributes())'s valueForKey:"Subject") as text
log ((ocidActiveDoc's documentAttributes())'s valueForKey:"Keywords") as list
log ((ocidActiveDoc's documentAttributes())'s valueForKey:"OutputIntent") as text
log ((ocidActiveDoc's documentAttributes())'s valueForKey:"OutputIntent") as text

###保存オプションの初期化
set ocidPdfOptionDict to refNSMutableDictionary's alloc()'s initWithCapacity:0

#####メタデータ指定
ocidPdfOptionDict's setObject:("作成者は" as text) forKey:"kCGPDFContextAuthor"
ocidPdfOptionDict's setObject:("内容の作成:何で作った" as text) forKey:"kCGPDFContextCreator"
ocidPdfOptionDict's setObject:("タイトル部:書類の名前" as text) forKey:"kCGPDFContextTitle"
ocidPdfOptionDict's setObject:("主題:サブジェクト" as text) forKey:"kCGPDFContextSubject"
ocidPdfOptionDict's setObject:({"キーワード1", "キーワード2"} as list) forKey:"kCGPDFContextKeywords"

###保存
set boolSaveJob to ocidActiveDoc's writeToURL:ocidNSUrlPath withOptions:ocidPdfOptionDict


ocidActiveDoc's release()

|

[CGPDFContext]ユーザーパスワード設定(保存時)

1:開くのにパスワードが必要
2:印刷するのにパスワードが必要



#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use framework "PDFkit"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL
property refNSArray : a reference to refMe's NSArray
property refNSMutableDictionary : a reference to refMe's NSMutableDictionary
property refNSSortDescriptor : a reference to refMe's NSSortDescriptor

property refPDFDocument : a reference to refMe's PDFDocument

set objFileManager to refMe's NSFileManager's defaultManager()

#####ここはご自分で設定してね
####ユーザーパスワードは利用者に伝える用
set strUserPassword to "1234"
###管理者パスワード
set strOwnerPassword to "4321"


####ダイアログで使うデフォルトロケーション
tell application "Finder"
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell

####UTIリスト PDFのみ
set listUTI to {"com.adobe.pdf"}

####ダイアログを出す
set aliasFilePath to (choose file with prompt "PDFファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

set strFilePath to POSIX path of aliasFilePath
####ドキュメントのパスをNSString
set ocidFilePath to refNSString's stringWithString:strFilePath
####ドキュメントのパスをNSURLに
set ocidNSUrlPath to refNSURL's fileURLWithPath:ocidFilePath


####ドキュメントの初期化
set ocidActiveDoc to refPDFDocument's alloc()'s init()
set ocidActiveDoc to refPDFDocument's alloc()'s initWithURL:ocidNSUrlPath

####現在の設定
log ocidActiveDoc's allowsCopying() as boolean
log ocidActiveDoc's allowsPrinting() as boolean
log ocidActiveDoc's allowsCommenting() as boolean
log ocidActiveDoc's allowsContentAccessibility() as boolean
log ocidActiveDoc's allowsDocumentAssembly() as boolean
log ocidActiveDoc's allowsDocumentChanges() as boolean
log ocidActiveDoc's allowsFormFieldEntry() as boolean

set boolPrinting to ocidActiveDoc's allowsPrinting() as boolean

set ocidPdfOptionDict to refNSMutableDictionary's alloc()'s initWithCapacity:0

#####
if boolPrinting is true then
ocidPdfOptionDict's setObject:(false as boolean) forKey:"kCGPDFContextAllowsPrinting"
ocidPdfOptionDict's setObject:(strUserPassword as text) forKey:"kCGPDFContextUserPassword"
ocidPdfOptionDict's setObject:(strOwnerPassword as text) forKey:"kCGPDFContextOwnerPassword"
else
log "すでに設定されています"
end if

set boolSaveJob to ocidActiveDoc's writeToURL:ocidNSUrlPath withOptions:ocidPdfOptionDict

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom