help with script to convert pages of pdf to jpgs

Here is my stab at it

seems to work ok except that it only does the first page the number of pages times in stead of processing each page into a pdf

any help would be great
tia

set thepath to “Mac HD:Users:admin:Desktop: test folder:”

set chosen_file to choose file
set current_name to characters 1 thru -4 of displayed name of (get info for chosen_file) – Get the name of the PDF file
set pgCount to my [color=green]CountPDF/color
tell application “Adobe Photoshop CS”
set display dialogs to never
repeat with i from 1 to pgCount
open chosen_file as PDF with options {width:3, page:i, resolution:150, mode:RGB, constrain proportions:true} – opens the PDF as a 3" wide 150 dpi image
set docName to name of current document
set current_name to characters 1 thru -5 of docName
tell current document

           [color=blue]flatten[/color]
           [color=blue]save[/color] [color=blue]in[/color] (([color=green]thepath[/color] & [color=green]current_name[/color]) [color=blue]as[/color] [color=blue]file specification[/color]) [color=blue]as[/color] [color=blue]JPEG[/color] [color=blue]with options[/color] {[color=blue]quality[/color]:5} [color=blue]appending[/color] [color=blue]lowercase extension[/color] --[color=olive]saves the jpg to the temp location[/color]
           (*[color=olive]resize image resolution "72" width (0.833) with constrain proportions

[/color] set gif_file to save in ((tempfiles & current_name) as file specification) as CompuServe GIF with options {colors in palette:256} appending lowercase extension --saves the gif to the temp location
*)
close saving no
end tell
end repeat
end tell

on [color=green]CountPDF/color
set x to (read chosen_file for 200)
set PDFVersion to x’s paragraph 1
if PDFVersion = “%PDF-1.3” or PDFVersion = “%PDF-1.5” or PDFVersion = “%PDF-1.4” then
set pagesFlag to "/N "
else if PDFVersion = “%PDF-1.2” then
set pagesFlag to "/Pages "
end if
set numPages to word 1 of (text ((offset of pagesFlag in x) + (pagesFlag’s length)) thru -1 of x) as integer
return numPages
end CountPDF

this script was automatically tagged for
color coded syntax by Script to Markup Code
written by Jonathan Nathan

Joe:

I do not have the CS version of Photoshop, so I cannot test your script. Have you tried eliminating your [display dialogs never] command, and halting the repeat right after this line:

open chosen_file as PDF with options {width:3, page:i, resolution:150, mode:RGB, constrain proportions:true}

to make sure the correct page is open? If the repeat is indeed going through the correct number of times for total pages in the PDF, the error must be in this portion somewhere, otherwise nothing would be saved as it cascades down from here.

Joe,

I found this in the PSCS scripting guide:

tell application "Adobe Photoshop CS"
	set myFilePath to alias choose file
	open myFilePath as PDF with options {class:PDF open options, mode:RGB, resolution:150, use antialias:true, page:7, constrain proportions:true}
	
end tell

I used this just to open a single pdf and a page I knew existed. It works here so you should be able to replace the 7 with i and have it work.

PreTech

Thanks that worked perfectly Pretech