Well here goes Im posting in the hope that some one here is multi-lingual. I’ve made a attempt to have applescript create the text content for my do script. Im having a real struggle with javascript at the moment. Can someone shed some light on the validity of the java that is performed? Im less than convinced that im even on the right track here. So here is where im at and stuck.
-- Flag integer values
property applyOverPrint : 131072
property applySoftProofSettings : 2097152
property applyWorkingColorSpaces : 262144
property emitCJKTTasT2 : 134217728
property emitFlatness : 67108864
property emitFormsAsPSForms : 4194304
property emitHalftones : 1
property emitPostScriptXObjects : 524288
property maxJP2KRes : 8388608
property setPageSize : 1024
property suppressBG : 16
property suppressCJKFontSubst : 64
property suppressCenter : 256
property suppressCropClip : 4
property suppressRotate : 128
property suppressTransfer : 8
property suppressUCR : 32
property usePrintersMarks : 33554432
property useTrapAnnots : 16777216
-- Raster flag integer values
property textToOutline : 1
property strokesToOutlines : 2
property allowComplexClip : 4
property preserveOverprint : 8
-- binaryOK: (boolean)
-- bitmapDPI: (integer)
-- colorOverride: {Auto = 0, Grey = 1, mono = 2} (integer)
-- colorProfile: (integer)
-- downloadFarEastFonts: (boolean)
-- flags: bit field (integer) Needs to be created from the above propertys.?
-- fontPolicy: {everyPage = 2, jobStart = 0, pageRange 1} (integer)
-- gradientDPI: (integer)
-- pageHandling: {fit = 2, nUp = 6, none = 1, shrink = 3, tileAll = 5, tileLarge = 4} (integer)
-- pageSubset: {all = -3, even = -5, odd = -4} (integer)
-- printAsImage: (boolean) PS Level 1
-- printContent: {doc = 0, docAndComments = 1, formFieldsOnly = 2} (integer)
-- psLevel: {2, 3} (integer)
-- rasterFlagValues: bit field (integer) Needs to be created from the above propertys.?
-- reversePages: (boolean)
-- transparencyLevel: (integer)
-- useT1Conversion: (boolean)
-- Record the current printer and set printer choice
tell application "Printer Setup Utility"
set DefaultPrinter to the current printer
set current printer to printer "DC_3535_DC3535_Print"
end tell
-- Set last used print preset to default
do shell script "defaults write com.apple.print.custompresets com.apple.print.lastPresetPref Standard"
-- Get list of PDF's
set Q1 to "Do you want to include all the subfolders" & return & "within your folder selection?"
set theDialog to display dialog Q1 buttons {"No", "Yes"} default button 1 with icon note
if button returned of theDialog is "Yes" then
set inputFolder to choose folder with prompt "Where is the top level folder of PFD's?" without invisibles
tell application "Finder"
try
set filesList to (files of entire contents of inputFolder whose name extension is "pdf") as alias list
on error -- only one file
set filesList to (files of entire contents of inputFolder whose name extension is "pdf") as alias as list
end try
end tell
else
tell application "Finder"
set inputFolder to choose folder with prompt "Where is the folder of PFD's?" without invisibles
try
set filesList to (files of inputFolder whose name extension is "pdf") as alias list
on error -- only one file
set filesList to (files of inputFolder whose name extension is "pdf") as alias as list
end try
end tell
end if
set countA to count of filesList
if countA = 0 then
display dialog "This folder contains no PDF files to print!" giving up after 2
end if
-- Loop through the list of files
repeat with aFile in filesList
set fileIndex to 0
tell application "Finder"
set theFile to aFile as alias
end tell
tell application "Adobe Acrobat 7.0 Pr#2CB915"
activate
open theFile
tell active doc
-- Set the window size and document view
set bounds to {146, 42, 1198, 1200}
set view mode to just pages
set zoom type of PDF Window 1 to fit page
delay 1
set MB_Size to media box of page 1 as list
-- Points to millimeters Conversion
set MB_Height to ((item 2 of MB_Size) / 2.834645) as integer
set MB_Width to ((item 3 of MB_Size) / 2.834645) as integer
-- Determine long & short edges
if MB_Height ≥ MB_Width then
set LE to MB_Height
set SE to MB_Width
else
set LE to MB_Width
set SE to MB_Height
end if
-- JavaScript indexing is zero based so minus 1
set PageCount to (count of pages) - 1
-- Set flag values
set fv to applyOverPrint + applySoftProofSettings + applyWorkingColorSpaces + usePrintersMarks + suppressUCR + emitHalftones + suppressTransfer
-- Set raster flag values
set rfv to allowComplexClip + preserveOverprint + strokesToOutlines
-- Set the print peramiters
set PP1 to "{binaryOK: true, bitmapDPI: 300, colorProfile: 2, colorOverride: 0, downloadFarEastFonts: true, firstPage: 0, flags: " & fv & ", fontPolicy: 0, gradientDPI: 150, interactive: 2, lastPage: " & PageCount & ", pageHandling: 3, pageSubset: -3, printAsImage: false, printContent: 0, psLevel: 3, rasterFlagValues: " & rfv & ", reversePages: false, transparencyLevel: 75, useT1Conversion: true}"
-- Determine ecconomic paper size
set thisFit to false
-- Fits on A5 paper (less printer margins)
if LE < 200 and SE < 138.5 then
set thisFit to true
do shell script "defaults write com.apple.print.PrintingPrefs DefaultPaperID iso-a5"
delay 1
-- Print document via JavaScript using PP1 inc fv & rfv
do script "this.print({bUI: false, printParams: " & PP1 & "});"
display dialog "This PDF Fits on A5" giving up after 2
end if
-- Fits on A4 paper (less printer margins)
if LE < 287 and SE ≤ 200 and thisFit is false then
set thisFit to true
do shell script "defaults write com.apple.print.PrintingPrefs DefaultPaperID iso-a4"
delay 1
do script "this.print({bUI: false, printParams: " & PP1 & "});"
display dialog "This PDF Fits on A4" giving up after 2
end if
-- Fits on A3 paper (less printer margins)
if LE < 410 and SE ≤ 287 and thisFit is false then
do shell script "defaults write com.apple.print.PrintingPrefs DefaultPaperID iso-a3"
delay 1
do script "this.print({bUI: false, printParams: " & PP1 & "});"
display dialog "This PDF Fits on A3" giving up after 2
end if
-- Scale output to fit on A3 paper (less printer margins)
if LE ≥ 410 or SE > 287 then
do shell script "defaults write com.apple.print.PrintingPrefs DefaultPaperID iso-a3"
delay 1
set PP2 to "{binaryOK: true, bitmapDPI: 300, colorProfile: 2, colorOverride: 0, downloadFarEastFonts: true, firstPage: 0, flags: " & fv & ", fontPolicy: 0, gradientDPI: 150, interactive: 2, lastPage: " & PageCount & ", pageSubset: -3, printAsImage: false, printContent: 0, psLevel: 3, rasterFlagValues: " & rfv & ", reversePages: false, transparencyLevel: 75, useT1Conversion: true}"
-- Print document via JavaScript using PP2 inc fv & rfv
do script "this.print({bUI: false, bShrinkToFit: true, printParams: " & PP2 & "});"
display dialog "This PDF is larger than A3 & requires scaling" giving up after 2
end if
end tell
close active doc saving no
end tell
end repeat
-- Set the printer choice back
tell application "Printer Setup Utility"
set current printer to DefaultPrinter
end tell