I think the problem lies in defining the folder for the source PDF and the Output JPEGs. In my Final script, the source PDF lies in a sub-folder (HighF) of the parent folder (sourcePath).
And…
the output JPGs are to be saved in the sub-folder (JpgFolder) of HighF folder of sourcePath folder.
SteFan, there is a little progress, but with a new error:
The error came at
save docRef in file BackC as JPEG with options jpgOptions with copying
Finally, what exactly I need is to save the JPEGS in the “JpgFolder” which is a child folder of “HighF” whose parent folder is “sourcePath”
i.e.: sourcePath:HighF:JpgFolder
If you look at the Reply,you will also notice it is combining the folders’ to make one big file name “Hi-Res JPEG_Native Cover_123456Native Cover_123456_Back Cover”
whereas “Hi-Res JPEG_Native Cover_123456” is the name of the folder JpgFolder; and
“Native Cover_123456_Back Cover” will be the name of the Back Cover JPG file.
Can you please update my script to work properly. All the things are going fine except the last part of creating JPEGs
Here is my revised script:
tell application "Adobe InDesign CS5"
set myDocument to active document
set docName to name of myDocument
set sourceName to text 1 thru -6 of docName
set sourcePath to the file path of myDocument as string
set zeroPoint to zero point of active document
set zero point of active document to {0, 0}
tell application "Finder"
set fldr to alias sourcePath
set baseFold to (fldr's parent) as alias
set pageWidth to text returned of (display dialog "Enter the page width (in inches)" default answer 6)
set pageWidth to pageWidth as real
if not (exists folder "1 Native Cover") then set PackageF to make new folder at baseFold with properties {name:"1 Native Cover"}
if not (exists folder "2 Hi-Res JPEG") then set HighF to make new folder at baseFold with properties {name:"2 Hi-Res JPEG"}
set JpgFolder to "Hi-Res JPEG_" & sourceName
make new folder at HighF with properties {name:JpgFolder}
if not (exists folder "3 Cover Proof") then set LowF to make new folder at baseFold with properties {name:"3 Cover Proof"}
if not (exists folder "4 Prepress Cover") then set CanvasF to make new folder at baseFold with properties {name:"4 Prepress Cover"}
if not (exists folder "5 Previous Cover") then make new folder at baseFold with properties {name:"5 Previous Cover"}
--if not (exists folder "Working Folder") then set WorkF to make new folder at sourcePath with properties {name:"Working Folder"}
set packFolder to make new folder at PackageF with properties {name:sourceName}
end tell
tell active document
save myDocument
package to alias (packFolder as string) copying fonts yes copying linked graphics yes including hidden layers yes copying profiles no updating graphics no ignore preflight errors yes creating report no
set idmlFile to (packFolder as string) & sourceName & ".idml"
export myDocument format InDesign markup to file idmlFile
--Creating a zip file of the package folder and deleting the folder
tell application "Finder"
set theItem to packFolder as alias
set itemPath to quoted form of POSIX path of theItem
--set fileName to name of theItem
set theFolder to POSIX path of (container of theItem as alias)
set zipFile to quoted form of (theFolder & sourceName & ".zip")
do shell script "cd " & itemPath & ";zip -r " & zipFile & " *"
if (exists folder theItem) then delete folder theItem
end tell
set HighPDF to (HighF as string) & sourceName & ".pdf" as string
export format PDF type to HighPDF using "CSP_EXPORT_3.20.14" without showing options
set LowPDF to (LowF as string) & sourceName & "_Low-Res.pdf" as string
export format PDF type to LowPDF using "CSP_EXPORT_3.20.14_150DPI" without showing options
--save myDocument
--Creating a Canvas File
delete every guide of myDocument
tell document preferences of myDocument
set page height to "12i"
set page width to "18i"
set page orientation to landscape
end tell
set mySel to page items of myDocument
--ungroup mySel
set MyNewSel to make group with properties {group items:mySel}
set {w, x, y, z} to geometric bounds of result
move MyNewSel by {(18 / 2 - (x + z) / 2), (12 - y)}
set canvasFile to (CanvasF as string) & sourceName & "_with Canvas.indd"
save myDocument to canvasFile
set CanvasPDF to (CanvasF as string) & sourceName & "_with Canvas.pdf" as string
export format PDF type to CanvasPDF using "CSP_EXPORT_3.20.14" without showing options
close myDocument
end tell
end tell
tell application "Finder"
try
set afile to (1st file of HighF whose name extension is "pdf")
set thefile to afile as string
end try
tell application "Adobe Photoshop CS5"
set display dialogs to never
set myOptions to {class:PDF open options, mode:RGB, resolution:300, use antialias:true, page:1, constrain proportions:true, crop page:bounding box}
open file thefile as PDF with options myOptions
set mystate to current history state of current document
set docRef to current document
set docName to name of docRef
set BackC to (JpgFolder as string) & docName & "_Back Cover"
set FrontC to (JpgFolder as string) & docName & "_Front Cover"
--set BackC to docName & "_Back Cover"
--set FrontC to docName & "_Front Cover"
resize canvas document 1 width pageWidth as inches anchor position middle left
set jpgOptions to {class:JPEG save options, embed color profile:true, format options:standard, quality:12}
save docRef in file BackC as JPEG with options jpgOptions with copying
set current history state of current document to mystate
resize canvas document 1 width pageWidth as inches anchor position middle right
set jpgOptions to {class:JPEG save options, embed color profile:true, format options:standard, quality:12}
save docRef in file FrontC as JPEG with options jpgOptions with copying
close docRef without saving
end tell
end tell