Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Export book file (documents) to individual pdfs - retaining unique, assigned pdf export 'Save as' name

Explorer ,
Dec 18, 2018 Dec 18, 2018

I posted a question related to this issue a while ago, but have not seen any further discussion.

Does anyone know of a script that can export Indesign files (ideally a group of book files) to pdf using the Export - 'Save as' name assigned/saved to the file?

Better still a script that can export individual files contained in multiple book files using the above file naming method?

MTIA

Steve

TOPICS
Scripting
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 20, 2018 Dec 20, 2018

Hi,

The following AppleScript can get you started. You will want to add details for how the PDF is to be saved.

--assuming a book is open and the files for the book are in the same folder as the book

tell application "Adobe InDesign CC 2018"

  set bookList to books

  set bookRef to item 1 of bookList

  set filePath to file path of bookRef as string

  set fileList to name of book contents of bookRef --gets names of the book's files

  repeat with i from 1 to length of fileList

  set thisFilePath to filePath & item i of fileList --add book's path to name of file

  set oset to offset of "." in thisFilePath

  set pdfFilePath to (text 1 thru oset of thisFilePath as string) & "pdf"

  set docRef to open file thisFilePath --open the file and export PDF

  tell docRef

  export format PDF type to pdfFilePath without showing options

  end tell

  close docRef saving no

  end repeat

end tell

Hope this helps.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 21, 2018 Dec 21, 2018

HI 'S'

Thank you, I'm sure that will answer part of my goal. Sadly I'm not a scripter (I have 'fiddled' successfully amending bits of Java, but not applescript). I'll think about it over the xmas break and see how it works when I'm back in the office in January.

The filenaming process I use/need to employ doesn't seem to be widely used. In fact there was some talk of the facility being removed from InDesign 2019. I create/maintain a couple of hundred InDesign specification sheets (exported to pdf as finished item) which are incrementally numbered when updated. When I create a document it has the standard file name format from InDesign just using the Product name as the InDesign file name.

When I export that file to pdf the first time I append the file name with 'v01.01'. When I update that file (InDesign file overwritten and saved) and export the file again the Acrobat 'saved' file name is v01.01 which I then amend to v01.02.

Steve

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2018 Dec 21, 2018

Hi Steve,

one idea would be to store a counter.

You would do that in the book file you want to export.

Or you could write a log file that traces your exports with that specific book file.

In case you want to store the counter in your book file:

It will be a "label" on the book file itself that you can only set and readout by scripting. In that case you would need method book.insertLabel("key string", "value string") for creating the label and book.extractLabel("key string") to read it out.

The script for export will update the label information.

Adobe InDesign CS6 (8.0) Object Model JS: Book

Adobe InDesign CS6 (8.0) Object Model JS: Book

Regards,
Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 21, 2018 Dec 21, 2018

Hi Uwe

thanks for that. I've never used the label function - I should look into that.

As I was walking the dogs this morning it occurred to me that what I want may not be possible.

I have single page Spec sheets as individual/chapter book files (great for synchronising table cell styles). But the individual sheets are updated independently - some may be version v01.01, some v01.02, v01.03. This involves manually editing the file.

It would be nice if this number could be tagged somehow and then included in the export to pdf file name.

Regards, Steve

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2018 Dec 21, 2018

Hi Steve,

both methods are also availbale for object Document.

In fact you'll find that insertLabel() and extractLabel() are there for nearly all kind of objects with InDesign.

Regards,
Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 21, 2018 Dec 21, 2018

Thanks Uwe,

It's about time I learnt about using Apple Script!

Regards, Steve

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 21, 2018 Dec 21, 2018

Hi,

As a beginner, I think you will appreciate AppleScript's syntax. The code below demonstrates how you can set a label for a document and update it.  The onTextToList(theText, theDelim) portion is what is called a Handler. This allows procedures that are used often to be saved as individual "snippets" to be used in any number of scripts. This one will take your document label (v01.01) and change it to a list of 2 items {"v01", "01"}. That way you can increment (add 1 to) the second part and then concatenate (add strings) the two parts to get "v01.02". See if you can figure out the rest of the code.

(*Demonstrates setting and getting label in a document and incrementing*)

tell application "Adobe InDesign CC 2018"

  set docRef to document 1

  set docLabel to label of docRef

  if docLabel = "" then

  set label of docRef to "v01.01"

  else

--call to handler to create list from string using a delimiter

  set labelParts to my textToList(docLabel, ".")

  set firstPart to item 1 of labelParts

  set secondPart to item 2 of labelParts

  --increment secondPart

  set vNum to secondPart as number

  set verNum to vNum + 1

  set verText to firstPart & "." & (text -2 thru -1 of ("0" & verNum)) as string

  set label of docRef to verText

  end if

end tell

(*The handler - creates a list from string passed using the character defined by theDelim*)

on textToList(theText, theDelim)

  set AppleScript's text item delimiters to "."

  set strList to text items of theText

  set AppleScript's text item delimiters to ""

  return strList

end textToList

Hope this helps.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 22, 2018 Dec 22, 2018

Hi S

thank you for the start.

I have an O'Reilly book, AppleScript the Definitive Guide (2004), is it still relevant or should I find something more contemporary?

Steve

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 22, 2018 Dec 22, 2018

HI,

That book will give you a good overview of AppleScript in general and is still relevant. (Nasty plug). I am updating my book on AppleScripting InDesign, It was written for CS5.5 and most of it is still relevant--just doesn't cover some of the new stuff. You will find a lot of information on my blog: yourscriptdoctor.com/blogs. Of course, Adobe's guides for scripting InDesign are a must-have.

Glad to help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 23, 2018 Dec 23, 2018
LATEST

Many thanks, and happy holidays!

Regards, Steve

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines