AppleScript in Acrobat 9: 10.5 vs 10.6
Using Acrobat Pro 9, this AppleScript used to work on OS 10.5. However, when I run this same script on a Mac that's running OS 10.6, it gives an error message. Here's the script:
tell application "Adobe Acrobat Pro"
save document "Test1.pdf" to file "Macintosh HD:Folder A:Test2.pdf" without linearize
--- save the current document Test1.pdf to the Macintosh HD to the folder "Folder A" and save it with the filename Test2.pdf
close document 1
end tell
What adjustments do I have to make for it to run on 10.6?
Thanks in advance.
Error message is:
Adobe Acrobat Pro got an error: document "Test1.pdf" doesn’t understand the save message.
Similar Messages
-
Replace cover page of PDF with applescript in Acrobat
I tried replacing a cover page in a PDF document with the following code but got a "doesn’t understand the replace pages message." What am I not getting here? I'd like to fill a folder with new covers and have them wind up replacing the covers of PDF files, or page 1 with covers that have the same file name. This is my starting point.
tell application "Adobe Acrobat Pro"
set docPgToBe_replaced to "Macintosh HD:Users:don_feldman:Desktop:Switch_Chapter_ Covers:chapter PDF:9780071714921.pdf"
set SourceOfNewPage to "Macintosh HD:Users:don_feldman:Desktop:Switch_Chapter_ Covers:cover PDF:9780071714921.pdf"
replace pages docPgToBe_replaced over 1 from SourceOfNewPage starting with 1 number of pages 1
save docPgToBe_replaced
end tellThe initial view setting is the responsibility of the document author - if they have defined one you cannot override it.
There's an option to set a default pagination and zoom for when the PDF itself has no preference, but it makes no sense for that to allow for cover pages as Acrobat has no idea if one exists or not. -
How can I add javascript text fields to Acrobat pages from Applescript please?
I have a real need to add text fields to Acrobat document pages from Applescript. I can't access the Headers and Footers from Applescript in Acrobat XI. I can set watermarks using the following script, but cannot for the life of me work out how to add text fields. Any advice please?
Regards
set TempAttachmentName to "(20140717121212Z)"
set PreserveFileName to "This is a test"
set bypass to false
tell application "Adobe Acrobat Pro"
activate
set CountOfPages to count of pages
repeat with PageCounter from 1 to CountOfPages
tell application "System Events" to tell process "AdobeAcrobat"
try
click menu item "Page..." of menu 1 of menu item "Go To" of menu 1 of menu bar item "View" of menu bar 1
tell current application to delay 0.1
keystroke PageCounter as text
tell current application to delay 0.1
keystroke return
if not bypass then
my ADDHeaderFooter(TempAttachmentName, PreserveFileName & " " & CountOfPages, PageCounter)
end if
end try
end tell
end repeat
end tell
on ADDHeaderFooter(The_String1, The_String2, currentPage)
tell application "Adobe Acrobat Pro"
activate
set myDocument to document 1
tell myDocument
tell page currentPage
set cbox to crop box
set item 2 of cbox to (item 2 of cbox) + 44
set item 4 of cbox to (item 4 of cbox) - 44
set media box to cbox
set crop box to cbox
set theResult1 to my Add_WaterMarkText(The_String1, "IDAutomationHC39M", 12, 1, 1, 1, 0, 3, 10, 3, 0)
do script theResult1
set theResult2 to my Add_WaterMarkText(The_String2, "Times", 16, 1, 1, 1, 0, 4, 10, -6, 0)
do script theResult2
end tell
end tell
end tell
end ADDHeaderFooter
on Add_WaterMarkText(cText, cFont, nFontSize, nS, nE, nTA, nHA, nVA, nHV, nVV, nR)
set Params to "cText: '" & cText & "'," & return
set Params to Params & "cFont: '" & cFont & "'," & return
set Params to Params & "nFontSize: '" & nFontSize & "'," & return
if class of nS is integer then set Params to Params & "nStart: " & (nS - 1) & "," & return
if class of nE is integer then set Params to Params & "nEnd: " & (nE - 1) & "," & return
-- 0 = left, 1 = centre, 2 = right
if class of nHA is integer then set Params to Params & "nHorizAlign: " & nHA & "," & return
-- 3 = top, 4 = bottom
if class of nVA is integer then set Params to Params & "nVertAlign: " & nVA & "," & return
-- offset in points
if class of nHV is integer then set Params to Params & "nHorizValue: " & nHV & "," & return
-- offset in points
if class of nVV is integer then set Params to Params & "nVertValue: " & nVV & "," & return
if class of nR is integer then set Params to Params & "nRotation: " & nR & "," & return
set javascript to "this.addWatermarkFromText({" & Params & "});"
return javascript
end Add_WaterMarkTextG'day
Unfortunately I don't have the API. My Adobe Reader installation updating to version XI failed, and subsequent attempts to fall back on the X version are blocked by the partial install of XI. Damn Adobe stuff.
Could someone please post the relevant part of the API to give me some pointers, please.
I ha mucked about with some information I found on the Web, and come up with the following, which fails because I can't work out how to address the current document with the variable myDoc.
Regards, Brian
set Params to Params & "var myDoc = this;" & return
set TempAttachmentName to "(20140717121212Z)"
set PreserveFileName to "This is a test"
set bypass to false
tell application "Adobe Acrobat Pro"
activate
set CountOfPages to count of pages
repeat with PageCounter from 1 to 1 # CountOfPages
tell application "System Events" to tell process "AdobeAcrobat"
try
click menu item "Page..." of menu 1 of menu item "Go To" of menu 1 of menu bar item "View" of menu bar 1
tell current application to delay 0.1
keystroke PageCounter as text
tell current application to delay 0.1
keystroke return
if not bypass then
my ADDHeaderFooter(TempAttachmentName, PreserveFileName & " " & CountOfPages, PageCounter)
end if
end try
end tell
end repeat
end tell
on ADDHeaderFooter(The_String1, The_String2, currentPage)
tell application "Adobe Acrobat Pro"
activate
set myDoc to document 1
tell myDoc
tell page currentPage
set cbox to crop box
set item 2 of cbox to (item 2 of cbox) + 44
set item 4 of cbox to (item 4 of cbox) - 44
set media box to cbox
set crop box to cbox
set theResult1 to my Add_WaterMarkText(The_String1, "IDAutomationHC39M", 12, 1, 1, 1, 0, 3, 10, 3, 0, myDoc)
do script theResult1
set theResult2 to my Add_WaterMarkText(The_String2, "Times", 16, 1, 1, 1, 0, 4, 10, -6, 0, myDoc)
do script theResult2
end tell
end tell
end tell
end ADDHeaderFooter
on Add_WaterMarkText(cText, cFont, nFontSize, nS, nE, nTA, nHA, nVA, nHV, nVV, nR, myDoc2)
#set Params to "var myDoc = app.newDoc();" & return
set Params to ""
set Params to Params & "var myDoc = this;" & return
set Params to Params & "var inch = 72;" & return
set Params to Params & "var Bbox = this.getPageBox(" & "\"Crop\"" & ");" & return
set Params to Params & "var f = myDoc.addField(" & "\"Text1\"" & ", " & "\"" & cText & "\"" & ", 0, [72, Bbox[1]-inch, Bbox[2]-2*inch, Bbox[1]-2*inch ] );" & return
set Params to Params & "f.strokecolor = color.black;" & return
set Params to Params & "f.richText = true;" & return
set javascript to Params
return javascript
end Add_WaterMarkText -
Is there a way to trigger batch process via Applescript or Javascript?
Based on what I've found so far on the internet, the answer is no. The Applescripts I've found so far that attempt to run a batch process don't work for me in either Acrobat Pro 8 or Pro 9.
I've been using Applescript to automate a process that starts in InDesign (create PDFs), then goes to Acrobat to set open options (I've got a batch process for that but can't find a way to trigger it). If I can get that to work, I'll attempt to automate the task of using a Photoshop droplet to create JPEGs of a specific size from these PDFs.
I've settled on InDesign CS3 for creating single-page PDFs from a multiple-page document, partly because I could not find a scriptable way to do this in Acrobat. I know just enough about Applescript to be dangerous. I know much less about Javascript.
Any help would be appreciated.
Thanks,
Kevin StaufferKevin some thing like this for Photoshop should aid you
set Todays_Date to do shell script "date \"+%d-%m-%y\""
-- Create new folder to save to
tell application "Finder"
set Raster_Images to make new folder at desktop with properties ¬
{name:"Rasterized PDF's " & Todays_Date}
end tell
-- Set Photoshop settings
tell application "Adobe Photoshop CS2"
activate
set display dialogs to never
set User_Rulers to ruler units of settings
set ruler units of settings to pixel units
-- set background color to {class:CMYK color, cyan:0, magenta:0, yellow:0, black:0}
-- set foreground color to {class:CMYK color, cyan:0, magenta:0, yellow:0, black:100}
end tell
-- Get list of PDF's
set The_Question to "Do you want to include all the subfolders" & return & "within your folder selection?"
set The_Dialog to display dialog The_Question buttons {"No", "Yes"} default button 1 with icon note
if button returned of The_Dialog is "Yes" then
set Input_Folder to choose folder with prompt "Where is the top level folder of PFD's?" without invisibles
tell application "Finder"
set File_List to (files of entire contents of Input_Folder whose name extension is "pdf")
end tell
else
tell application "Finder"
set Input_Folder to choose folder with prompt "Where is the folder of PFD's?" without invisibles
set File_List to (files of Input_Folder whose name extension is "pdf")
end tell
end if
set File_Count to count of File_List
if File_Count = 0 then
display dialog "This folder contains no PDF files to rasterize!" giving up after 2
end if
-- Loop through the files in list
repeat with This_File in File_List
tell application "Finder"
set The_File to This_File as alias
end tell
-- Tiger (OSX.4) shell call to count the pages
set Page_Count to my PDF_Pages(POSIX path of The_File)
if the result is not false then
-- Loop Photoshop through the page count
repeat with i from 1 to Page_Count
tell application "Adobe Photoshop CS2"
activate
open The_File as PDF with options ¬
{class:PDF open options, bits per channel:eight, constrain proportions:true, crop page:trim box, mode:CMYK, page:i, resolution:300, suppress warnings:true, use antialias:true, use page number:true}
set Doc_Ref to the current document
tell Doc_Ref
flatten
-- Enter your name strings into two enties below
-- Case sensitive stings
-- do action "My Action" from "My Action Set"
-- New file naming options
set Doc_Name to name
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set Doc_Name to text items of Doc_Name
set AppleScript's text item delimiters to "_"
set Doc_Name to Doc_Name as string
set AppleScript's text item delimiters to "-"
set Doc_Name to text item 1 of Doc_Name
set AppleScript's text item delimiters to ASTID
if Page_Count = 1 then
set New_File_Name to (Raster_Images as string) & Doc_Name & ".tif"
else
set File_Number to ""
repeat until (length of (File_Number as text)) = (length of (Page_Count as text))
if File_Number = "" then
set File_Number to i
else
set File_Number to "0" & File_Number
end if
end repeat
set New_File_Name to (Raster_Images as string) & Doc_Name & "_" & File_Number & ".tif"
end if
end tell
save Doc_Ref in file New_File_Name as TIFF with options {byte order:Mac OS, embed color profile:false, image compression:LZW, save alpha channels:false, save layers:false}
close current document without saving
end tell
end repeat
end if
end repeat
-- Set ruler units back to user prefs
tell application "Adobe Photoshop CS2"
set ruler units of settings to User_Rulers
end tell
beep 3
-- OSX Tiger shell handler
on PDF_Pages(This_PDF)
try
do shell script "/usr/bin/mdls -name kMDItemNumberOfPages" & space & quoted form of This_PDF & " | /usr/bin/grep -o '[0-9]\\+$'"
on error Error_Message number Error_Number
if Error_Number is 1 then
display alert "Page Count Unavailable" message "The page count for " & This_PDF & " is unavailable." giving up after 3
return false
else
display alert "Error " & Error_Number message Error_Message giving up after 3
return false
end if
end try
end PDF_Pages
and something like this to perform JavaScript from within AppleScript for Acrobat
You would be better talking to the JavaScript Experts on how to use addScript() to get your doc level scripts in.
property Default_Path : (path to desktop folder as Unicode text) as alias
property JavaScript : "var re = /.*\\/|\\.pdf$/ig; var filename = this.path.replace(re,''); try { for (var i = 0; i < this.numPages; i++) this.extractPages( { nStart: i, cPath: filename+'_' + (i+1) +'.pdf' }); } catch (e) { console.println('Aborted: '+e) }" as text
set The_PDF to choose file default location Default_Path ¬
with prompt "Where is the multi-page PDF?" without invisibles
tell application "Adobe Acrobat 7.0 Professional"
activate
open The_PDF
tell active doc
do script JavaScript
close saving yes
end tell
end tell -
How can I use applescript for OCR of a bunch of files - with Acrobat XI?
Hi there,
Iwant to write a script (eg applescript) that can be used as a droplet or has a menu to open a folder of scanned pdf-files to conduct OCR. And - I want to use Acrobat XI (as this is my version), German verison.
As Acrobat XI is not recordable with the applescript-editor and I do not find a manual of objects and methods I googled a script that worked with Acrobat 9 but not with Acrobat XI. Here you define a "Action Assistant"-Script e.g. called "OCR this" and "click" the item. But as in Acrobat XI this Item is noch in the main-sbubmenu anymore it seems not to work.
Here is a Screenshot:
And this is theapplescrpt, tha opens the "Aktionsassistent":
click the menu item "Aktionsassistent" of menu "Werkzeuge" of menu item "Werkzeuge" of menu "Anzeige" of menu bar item "Anzeige" of menu bar 1
Butr then I cannot reach "OCR this".
If any body has a hint - either for clicking "OCR this" or to sript an OCR on an opened pdf.file with applescript this would be great.
Thanks,
MaritnAppleScript is documented in the Acrobat SDK. But there is no method for this.
-
Hi, I'm writing applescript to automate Adobe Acrobat XI, I'm missing only one line of code - opening dialog window of "Convert Colors..." tool. It was easy in Acrobat 9 but some reason it's complicated in Acrobat XI.
Is there an option to add "Convert Colors..." as menu item into menu bar?Thanks Gilad D. I created JS file with simple code
app.addMenuItem({cName:"Convert Colors", cParent:"View", cExec:'app.execMenuItem("ColorConversionMenuItem");'});
and I added it into acrobat (USER/Library/Application Support/Adobe/Acrobat/11.0/JavaScripts/).
I enabled menu items JavaScript execution privileges in Acrobat Preferences.
Now I can open "Convert Colors" from main menu bar, and create applescript which do the same. -
AppleScript to batch change 'Initial View' of PDF Documents Acrobat 9 Pro
Hi
I'm struggling to write a script that takes a bunch of PDF documents and opens
those in Acrobat 9 Pro. Changes the Inital View settings (ie. Page layout = Single Page and Magnification = Fit Page)
and saves the changes.
Is this possible with Acrobat and AppleScript?
Is there an AppleScript Reference for Acrobat?
Appreciate your help.
Cheers,
AlexWell, it says Acropbat Scripting ... didn't appear to me as Windows only.
Will move it to the Mac Forum.
Thanks. -
How do you "save as" in Acrobat 9 via Applescript?
Greetings all,
I'm using the Applescript Script Editor and trying to do a "save as." The Applescript dictionary for Acrobat 9 has a reference to "save" in the Core Suite, but no matter what I try, I get an AS error that typically contains the text "document 1 does not understand the save message."
I can do a "save as" via Applescripting that GUI but that seems problematic as well (I've set the Properties > Initial View options for document 1 after inserting a page--all via Applescript--but doing a "save as" via the GUI apparently does not save those properties. I would hate to have to script the process of having Acrobat open the file again and reset the initial view; I should be able to do that before saving the new file.
Thanks,
KevinHold down the OPTION key. The Save As option should appear in the File menu.
-
Using AppleScript "execute" command in Acrobat
Acrobat's scripting dictionary has a cryptic description of an "execute" command that is supposed to execute a menu item "as if a user clicked it".
No information is given as to how to identify the desired menu command except "reference". Huh? Is there documentation or a tutorial on this anywhere?
Related question, how can AppleScript identify auxiliary windows such as the Document Properties window and its various button bar items and other fields?
Here's one simple thing I'm trying to accomplish: I'm using System Events to script some items like keywords in the Document Properties window. Sometimes it takes several seconds for a document to open. Without putting in huge wait loops, I'd like to execute the menu item "File: Properties..." and then wait for the window to open using a loop like this:
repeat until exists <some way to identify the Document Properties window>
end repeat
Any hope of doing stuff like this? I already tore out enough hair trying to get AppleScript's "do script" command to work (only lately having discovered that the script file apparently must be plain text, no Unicode).The Macintosh keyboard does not have a true "Enter" key any more - not on the MacBook Pro or the iBooks. Modifier keys do not seem to work either. I've turned on the System Prefs > Keyboard & made it appear in the top Menu Bar. From this menu choose "Show Keyboard Viewer" to see how keys + Return are displayed. Only the Function key changes the Return key. Function + Delete is a forward delete. But Function + Return is just another Return. So any highlighted text is deleted! Command + Return stays on the same line and selected text remains. I will try KeyRemap4MacBook utility then consider buying a USB numeric keypad. Urggh.
-
Acrobat X, using applescript, how do I open the 'Header & Footer' panel
G'day from Oz.
We badly want to update to the CS6 suite, but using the trial version of Acrobat X, I can't find a way of opening the 'Add Header & Footer' dialog panel with applescript. We must add a barcode to pdf's, which was relatively simple using Acrobat 9.
Anyone know a way to do this please?I have been bumping up against this issue in the last few days. I have redone my output as PDF and that works OK - i.e. There are no Safari footer details on the AirPrint printed page.
But now I find that PDF documents frequently print with white space bands across the page (chopping off some of the text). I can even replicate this when pinch zooming on my iPad with a PDF document. So I suspect a bug in the PDF processing functionality within IOS. I am running IOS 4.3 so I had better update to see if the issue goes away. -
When I try to run a simple javascript on the Mac using AppleScript I receive the following error:
Adobe Acrobat Professional got an error: "app.openDoc(\"/temp/Form_A.pdf\");" doesnt understand the do script message.
My AppleScript:
tell application "Adobe Acrobat Professional"
set javascript to "app.openDoc(\"/temp/Form_A.pdf\");"
try
do script javascript
on error e
beep
return e
end try
end tell
If I run the same JavaScript in a button in Acrobat it works fine:
app.openDoc("/temp/Form_A.pdf");
Has Adobe added some new security features in Acrobat 8.1.2?
Cheers, AdrianYes - certain parts were changed with Acrobat 8 .. try the scripting
forum ...
Jon -
I know this is the InDesign scripting forum, but I've had great experience with the users here answering questions quickly!
Can I write scripts for Acrobat 8 using AppleScript?
What I've read isn't particularly encouraging--you have to use the "do script" command calling to a javascript, which sounds like I would need to be able to write the javascripts that I want to "do". Am I understanding this correctly?
I don't know any JavaScript at all. I know AppleScript at a decent beginner level.
The scripts I'd be interested in writing have to do with comments in Acrobat PDFs--showing/hiding comments based on type and generating printouts or PDFs from the "Summarize Comments..." command.
Thanks for any help or guidance you can give.Acrobat only offers a limited set of classes to AppleScript. Im only V7 so I can't confirm… Your best bet is to check out the app's dictionary for yourself and search the terms… I would guess from the previous versions that you are going to be disappointed though…
-
Acrobat AppleScript stamp (Stempel)
Mein AppleScript fügt mehrere PDFs zusammen. Das geht wunderbar auch bei mehrseitigen Anhang-PDFs (weil ich die Seiten zählen lasse).
Nun möchte ich jedem Anhang einen Stempel auf die erste Seite geben: [Anhang 01], [Anhang 02], …
Ich finde aber in der AppleScript-Bibliothek die passenden Befehle leider nicht.
Und ich frage mich, ob transparente PDFs (einseitig) auf eine PDF-Seite eingefügt werden können (mit insert page) mit dem Ergebnis, daß es wie gestempelt aussieht.tell application "Finder"
set myPDF to choose file with prompt "Bitte wählen Sie Ihr PDF"
end tell
tell application "Adobe Acrobat Professional"
open myPDF -- with invisible
make Text Annotation with properties {bounds:{544, 820, 550, 812}, name:"Anmerkung Numero 05", contents:"Hier schreibe ich per Script einen Kommentar, aber wo bleibt er ab?"}
end tell
Mit diesem Script bekomme ich oben rechts ein Icon mit Mouseover "Anmerkung Numero 05". Immerhin.
Contents erzeugt keine Spuren.
Mein Ziel ist aber ein Stempel, bei dem ohne Mouseover mein Text (name) zu lesen ist.
Hat jemand eine Idee?
Mir fällt auf, daß für diesen Acrobat-Teil (Stempel, AppleScript) nichts im Internet zu finden ist, was mir helfen konnte. Keine Beispieldateien zu finden. Und ich suchte ausdauernd, denn ich möchte meine Aufgabe lösen. Von FileMaker aus soll ein PDF aus mehreren PDF zusammengefügt werden. Die Anhangdateien sollen auf der ersten Seite einen Stempel bekommen. -
Running AppleScript with Adobe Acrobat to rotate and crop file.
I constantly receive PDF files from a third party service provider that I always have to ROTATE and CROP in order to fit perfectly into labels that are perforated.
The Label sheets are 8-up (2 x 4). If I print it as is, they DON'T fall where they supposed to. I can't get the trird party service provider to alter the way they supply the PDF files (they just not helpful). I thought it is still easier for me to do the neccesary adjustments.
What I want to do is:
(1) rotate the document (multi-page PDF) 180 deg
(2) crop leading edge 3mm.
(3) if possible, I want it to be able to watch a folder and do this automatically as PDFs are dropped into a defined folder (can be set permananetly) and save OVER the old file.
I know AppleScript can do this (I think), but I don't have the expertise on AppleScript to write the commands.
Can anyone help?
I am using Mountain Lion & Acrobat 8.Thanks for the reply. I can still open the file in excel and I understand that I can redirect the file to open in another program. But it doesn't solve my problem that when I email the file to someone else it tries to open the file as a pdf (which it basically isn't) and gives the error message that its an unsupported file type. What I am really looking for is a way to stop it from saving an excel file as an adobe file even when I choose the file format as an excel workbook when I save it.
-
AppleScript do script file completely broken in Acrobat 9 Pro?
After not being able to use Acrobat 8 at all because of this issue
http://www.adobeforums.com/webx/.59b4b95a
I plunked down another $170 hoping the issue would be fixed in Acrobat 9.
But with Acrobat 9 Pro (9.0.0, OS X 10.5.5), calling do script file does not seem to work at all. I've created a simple one line script:
console.println("test 123");
and called it like this:
tell application "Adobe Acrobat Pro"
do script file "Path:to:file:test.js" as alias
end tell
I get this error:
92:181: execution error: Adobe Acrobat Pro got an error: Can't continue do script. (-1708)
The console in Acrobat Pro shows:
illegal character
0:
Thanks for any help or suggestions.It depends. Generally-speaking the content of PDF files created in Acrobat X will use PDF/1.7 as the base level so will open in Acrobat and Reader 9, but there are exceptions, including:
PDF Portfolios won't display properly
PDFs using the 'Acrobat X or later' security hash won't open at all
Some edge case scenarios with certification won't validate
Files which exploit bugs in one version or which hit a bug in a previous version
All PDFs created in Acrobat (Standard or Pro) will open in the same version of Reader, Standard or Pro - it's only the creation/editing features which vary between flavors.
Maybe you are looking for
-
I have an iPad 3 model A1416 16GB. It is about 1 1/2 years old. When I opened it today the screen for my password came up and then before I could enter it the screen went blank. I can not get it to do anything now. It had about 24% of charge left.
-
Regarding file content conversion and jdbc adapters
hi can any one send me the details about the sender jdbc adapter and the receiver jdbc adapter. i need the output of sender jdbc adapter(structure)also fro the receiver jdbc adapter. for file content conversion - can any one send abt the sender and r
-
IPad mini iTunes sync without Bluetooth??
I have a wifi-only iPad Mini on order for my wife. Her computer is an older iMac5,2 without Bluetooth. Will she be able to transfer/sync her contact data, photos and music using the iMac's USB connection? Would any additional adaptor/'camera kit' be
-
I am new to Dreamweaver AND site-building, so please keep that in mind when answering:) Can I insert an image as a background for my web page and then insert other images on top of it??
-
Prevent double click / double submit
Hi, I have a JSP with some input fields and some command buttons within a form. When the user clicks twice on one of the buttons two requests (including the form data) are sent. In the server side this results in unpredictable behvior of my business