Export PDF Use Page's Text as File Name

I’ve bought the books and read the web pages and I still don’t get it! Here’s my delimma . . . .

InDesign CS2
Acrobat 7
Mac OSX - Tiger

I have a 800 page document or 400 english/spanish words, flash cards.
Odd pages are the front of the card; even pages represent the back.

From this “Master” document I will generate many smaller sets, some cards being used in multiple sets and others only once.

Trying to simplify this process, I think it best to move these cards out of the page layout program and work with them as whole units instead of creating multiple instances of the same card in different documents as was done in the past.

  • I want to export all pages to a PDF in increments of 2, ultimately creating 400, 2-page PDF files (a card front and it’s back).

  • Extract text from frame of odd pages to be used as the PDF file name (up to 15 characters).

-(I need to be able to quickly identify the PDF files or “cards” in a file list. It would make sense to have the file name match the flash card “word”)

From that point I can create the different sets by combining the necessary PDF files in Acrobat
Or I could import the PDF’s back in to IND for each NEW set of cards.
So, when revisions are made in the “Master” set and then re-PDF’d every occurrene of that card would be updated.

Hi cajarrell
edit::confused: Sorry reading your post again i’m assuming there spreads and not single pages…

This Snippet should get you the pdf’s you need of the spreads:

tell application "Adobe InDesign CS2"
	tell document 1
		repeat with i from 1 to count of spreads
			set i to i + 1
			tell application "Adobe InDesign CS2"
				tell PDF export preferences
					set acrobat compatibility to acrobat 7
					set page range to (i as string)
					set export reader spreads to true
					set view JDF to false
				end tell
				export document 1 format PDF type to (((path to desktop) as string) & "Name of pdf" & i) without showing options
			end tell
		end repeat
	end tell
end tell

Created a test document with 4 pages (2 spreads) and it worked fine…
This will (if it works!) place 400 pdf’s on your desktop please bare that in mind before you run it, test it on a smaller
paged document first!!

i’ll try and look into the other bit you asked for but really busy at the minute…

Hi cajarrell

This should get your pdf’s if there single pages:

tell application "Adobe InDesign CS2"
	tell document 1
		repeat with i from 1 to count of pages by 2
			tell application "Adobe InDesign CS2"
				tell PDF export preferences
					set acrobat compatibility to acrobat 7
					set page range to (i & "," & 1 + i as string)
					--set export reader spreads to true
					set view JDF to false
				end tell
				export document 1 format PDF type to (((path to desktop) as string) & "Name of pdf" & i) without showing options
			end tell
		end repeat
	end tell
end tell

WOW!
I absolutely must learn to do this.
The only “successful” script I’ve written was a basic step and repeat and it took me a week.

I ABSOLUTELY must learn this . . .

Thank you so much…

Now, point me in the right direction on how to extract text from a page and use that string as the file name…maybe I can figure that out!

Hi Cajarrell

WOW! Glad it worked for you!!
I’m just learning this stuff myself, my advice for what its worth is just stick with it. it falls into place
very slowly but it does come!
This forum has been a huge help to me as i’m sure it has for others, a lot of helpfull people on here.
Anyhow give this ago for the rest of your problem.

tell application "Finder"
	if not (exists the folder "Flash Card pdf's" of desktop) then
		set NEWfolder to make new folder at desktop with properties {name:"Flash Card pdf's"}
		set NEWfolder to NEWfolder as alias
	end if
end tell
tell application "Adobe InDesign CS2"
	tell document 1
		repeat with i from 1 to count of pages by 2
			tell page i
				tell text frame 1 -- assumes text frame 1 has the info in you want! can be any text frame pick a number?
					set future_file_name to characters 1 thru 15
					tell application "Adobe InDesign CS2"
						tell PDF export preferences
							set acrobat compatibility to acrobat 7
							set page range to (i & "," & 1 + i as string)
							--set export reader spreads to true
							set view JDF to false
						end tell
						export document 1 format PDF type to (NEWfolder & future_file_name & i as string) without showing options
					end tell
				end tell
			end tell
		end repeat
	end tell
end tell

Made things a little neater by throwing the pdf’s into a folder on desktop . i only tested this with a 4 page document with one text frame on each page, if you have a lot of
text boxes on each page you will need to specify which one to use.

Again, WOW!
Did you take a class on AppleScript, or just dive in? How do you guys/gals do it?

It appears to work . . . until it launches Acrobat and the newly created file will not open. It errors out. It creates the folder on the desktop and places the files but they don’t have file extensions.

The PDF files created yesterday opened so, I ran the original script that produced PDF’s 12 hours ago…and…it errors now too. I have not changed/installed/updated anything. Any suggestions?

The error message says: Acrobat could not open “filename1” because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn’t correctly decoded.)
To create a PDF doc go to the source app and print the document to Adobe PDF.

I hid all layers except the one with the target frame. Ran the script and it error’d on a frame with less that 15 characters…oops! I think I can fix that - from 1 to end - I’ll look it up.

My text frames are linked - All odd pages have one text frame linked from the previous and then to the next odd page. I use the Keep options to make each paragraph (or word) start on the next odd page. As the script is now, it wont work with linked frames, right?
If not, I can add one of the many “break frame links” script to front of this code…

Hi Cajarrell

Sorry to hear your having trouble with this!
Can’t understand why it would launch Acrobat, theres nothing in there to do that?
I’ve had an issue where i’ve saved pdf’s to the desktop and there fine but when they go in the folder they won’t open…?
Not sure about the error message! I’d maybe revert back to the original script.
I’m not gonna be on a mac that has indesign until after the weekend.
in the meantime you might be able to re-jig these scripts together to get somewhere near what you want.
I’d leave the bit that creates the folder out for now though i’m sure thats a problem…

Hi caj

Try this:

tell application "Adobe InDesign CS2"
	tell document 1
		repeat with i from 1 to count of pages by 2
			tell page i
				tell text frame 1 -- assumes text frame 1 has the info in you want! can be any text frame pick a number?
					set future_file_name to characters 1 thru 15
					tell application "Adobe InDesign CS2"
						tell PDF export preferences
							set acrobat compatibility to acrobat 7
							set page range to (i & "," & 1 + i as string)
							--set export reader spreads to true
							set view JDF to false
						end tell
						export document 1 format PDF type to (path to desktop) & future_file_name & i as string without showing options
					end tell
				end tell
			end tell
		end repeat
	end tell
end tell

no longer puts them in a folder just names them and leaves them on the desktop
has for the naming of the pdf’s this should just pick up the characters from the first text frame you may have to tweak this for your needs…

Sorry it’s been so long. I’ve been out on vaccation!
Well, you got it this time! Marvelous!

I changed it to single pages instead of spreads and it turned out to be the 2nd text frame.
Also took out the character restrictions, so it names the file using the entire vocabulary word…which is G-R-E-A-T!
I do miss the “neatness” of the folder…but hey, that’s small stuff!

Turns out, while I was gone a different artists spent a week on this project…and didn’t get it done. She’ll still be plugging away today…wait til she sees this! (of course I’ll give you FULL credit!) :wink:

Thank again for all your help…
Have a Happy New Year!

tell application “Adobe InDesign CS2”
tell document 1
repeat with i from 1 to count of pages by 2
tell page i
tell text frame 2
set future_file_name to characters
–1 thru 3
tell application “Adobe InDesign CS2”
tell PDF export preferences
set acrobat compatibility to acrobat 7
set page range to (i & “,” & 1 + i as string)
–set export reader spreads to false
set view JDF to false
end tell
export document 1 format PDF type to (path to desktop) & future_file_name & i as string without showing options
end tell
end tell
end tell
end repeat
end tell
end tell