Today I encountered a very strange phenomenon when exporting PDF-files from within Indesign using Applescript.
A few months ago, I created a small workflow to automate pdf-file creation. All this time it worked great, but for some unknown reason, a file I was working on today, would not export using Applescript, or a large part of the artwork was missing in the pdf-file. I tried eliminating the problem by removing many parts of the artwork until only a few text frames remained. And still, the bug remained.
When exporting the file manually, everything worked fine, but when using Applescript to do the same thing, the error "Failed to Export PDF" was shown, or the pdf-file produced, was incomplete.
The code I was using ...
export format PDF type to "HD:Result:test.pdf using "myPresetName" without showing options
After many hours of searching the web and doing many tests, I found a temporary "solution" to my problem.
First I added this line...
set page range of PDF export preferences to "1-" & (count pages in active document) as string
For some strange reason, Indesign uses the page rage of the previous export to create the pdf-file. Make sure to define your own page range with every export you do.
And finally, I disabled the "background exporting tasks" by using the Tomaxxi script (Tomaxxi.com)...
The lessons i learned today are...
- Creating a pdf-file using a preset by hand successfully, does not mean you can do the same thing using Applescript.
- A preset doesn't contain all properties you need for building a perfect PDF. There are hidden properties which are not included in the preset and may influence the result.
I hope Adobe will do something about the generic error message "Failed to Export PDF". A few more pointers would help fixing the problem a lot sooner (is the source of the problem a font, image, clipping path, effect, ...)
I hope this information is helpfull for those people who encounter the same problem.