Hi Ame,
After a hard labour, I have now created my full script (merging smaller ones in one), which do all my work. I also tried to merge the PDF2Jpg script to my full script, but I’m getting an error:
At this error the script stops and no JPEGs are produced.
I added the PDF2JPG at the end of my final script as this is the second last process of my routine.
Here is the PDF2JPG script which is working fine if run alone:
tell application "Finder"
	--set theLocation to (target of front window) as string
	set pageWidth to text returned of (display dialog "Enter the page width (in inches)" default answer 6)
	set pageWidth to pageWidth as real
	
	try
		set afile to (1st file of folder 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:CMYK, 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 & docName & "_Back Cover"
		set FrontC to JpgFolder & 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
My Final script containing the PDF2JPG at the end:
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"
		if not (exists folder "1 Native Cover") then set PackageF to make new folder at sourcePath with properties {name:"1 Native Cover"}
		
		if not (exists folder "2 Hi-Res JPEG") then set HighF to make new folder at sourcePath 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 sourcePath with properties {name:"3 Cover Proof"}
		if not (exists folder "4 Prepress Cover") then set CanvasF to make new folder at sourcePath with properties {name:"4 Prepress Cover"}
		if not (exists folder "5 Previous Cover") then make new folder at sourcePath 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"
	--set theLocation to (target of front window) as string
	set pageWidth to text returned of (display dialog "Enter the page width (in inches)" default answer 6)
	set pageWidth to pageWidth as real
	
	try
		set afile to (1st file of folder 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:CMYK, 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 & docName & "_Back Cover"
		set FrontC to JpgFolder & 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
Could you please suggest me how to rectify the error.