Single Page PDF Indesign

I’ve been working on this script to create single page PDF’s out of Indesign CS3.
It makes the PDF’s fine but it won’t separate them into single pages.
I end up with several PDF’s with all the pages in them. Can’t figure it out.
Here is what I got so far…
Thanks


tell application "Adobe InDesign CS3"
	activate
	tell (active document) to set {file_name, doc_pages, page_numbers} to {name, pages, name of pages}
	set pdf_style to name of PDF export presets
	set export_style to (choose from list pdf_style with prompt "Select PDF Export Preset") as string
	if export_style is "false" then return
	set folder_path to (choose folder with prompt "Select folder to Save PDF files") as string
	
	set oldPref to page numbering of general preferences
	set page numbering of general preferences to absolute
	
	set pagesToPrint to (choose from list page_numbers with prompt "Choose Pages to PDF" with multiple selections allowed)
	if pagesToPrint is false then return
	
	repeat with anItem in pagesToPrint
		if length of anItem is 4 then
			set new_number to contents of anItem
		else
			set new_number to text -3 thru -1 of ("00" & anItem)
		end if
		set PDF_name to folder_path & file_name & "_" & new_number & ".pdf"
		set page range of PDF export preferences to (anItem as string)
		tell active document to export format PDF type to PDF_name using export_style without showing options
	end repeat
	set page numbering of general preferences to oldPref
	beep
	display dialog "Your PDFs are Done" buttons {"Done"} default button 1
end tell

Uh, I just ran it a few times and it is working just fine. I selected both “1” and “2” and ended up with two PDFs, one with “_001” and one with “_002” in the file name. Each PDF had a single page with the right info on it.

Is your export preset overriding the page range maybe? Try changing

tell active document to export format PDF type to PDF_name using export_style without showing options
to
tell active document to export format PDF type to PDF_name using export_style with showing options

so you can see what the page range is set to when you run it.

Thanks MattBoy…
After tinkering around…
I know when it happens, but not sure why it happens.
As soon as you section the document, the script no longer works as it is supposed to.

Fishheadtw