Javascript in batch sequence

I've done some Acrobat scripting but mostly through VB and I'm able to write what I need but I want to have it as part of my operator's Acrobat instead of the of separate program. That said, I want to write a Java script that I can include in batch sequence.
I need to add a page to the start of a document and I want to have that page be nubered "a" without disturbing the numbering else where in the file. By simply adding the page at the start with the batch sequence it adopts the numbering of the first page. So if the first page is numbered as "i" then the new inserted page gets numbered "i" and the rest of the numbering changes, what was i becomes ii, what was ii becomes iii, and so on. I'm able to script this in VB by adding the page at the end, renumber them using the SetPageLabels from a Javascript object, then moving the page to the beginning.
Is there any documentation on using Javascript within a batch sequence?
Thanks,
Ken

Well, hacking along here working in the console pasting my code in.
The script adds a single page from another Acrobat file to the start of the open PDF. I need the page that goes in at the front to be numbered "a" and NOT effect numbering in the rest of the pages. Some files work fine, other files not so much, like the Javascript API reference PDF as well as other PDFs we've created here form InDesign.
The script inserts a page at the end of the PDF and numbers that page "a" then moves it to the start of the document. The problem occurs when the page is moved to the start, it changes the number of all the other pages to follow page "a" which is a bit of a silly thing to have to send my clients. I decided to compromise and if the first page (before I insert the anything) was numeric I would simply try changing things to start page 1 after my inserted page "a".
My code looks like this:
var NumPages = this.numPages
var PgLabel = this.getPageLabel(0)
this.insertPages(NumPages-1, "/F/TNTSTUFF/Disclaimers/HUP_ProofNotice.pdf")
this.setPageLabels(NumPages,["a", "", 1]);
this.movePage(NumPages, -1)
if (PgLabel.match("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")) {  
        this.setPageLabels(1, ["1", "", 1]);  
However, the setPageLabels command is causing this error:
RaiseError: The base pages object is missing or invalid.
Doc.setPageLabels:7:Console undefined:Exec
===> The base pages object is missing or invalid.
I'm not sure it is relavent, but on the files that work the numbering in Acrobat looks like this with the parentheical numbers:
Files that DON'T work look like this, with NO parenthetical:
Even if I manually renumber the pages starting with 2 to make the numbering in the 2nd file look more like the numbering in the first file, I still get the error.
Is there a way I can overcome this with Java code and what the heck is it?
Thanks again to anyone who can help.
Best,
Ken

Similar Messages

  • Javascript in batch sequence stopped working

    The following javascript used in a batch sequence is causing Acrobat to stop working. It was working fine, this problem has happened sometime in the last 2 weeks. This has affected all of our PCs regardless of Acrobat update version. We are running Acrobat 8 (8.15, 8.17, 8.21, 8.25). The only update common to all PCs is Windows Update.
    /* Extract single pages to c:/Adobe */
    // Regular expression used to acquire the base name of file
    var re = /\.pdf$/i;
    // filename is the base name of the file Acrobat is working on
    var filename = this.documentFileName.replace(re,"");
    try {for (var i = 0; i < this.numPages; i++)
    this.extractPages({
    nStart: i,
    cPath: "C:\\Adobe\\"+filename+"_" + i +".pdf"
    } catch (e) { console.println("Aborted: " + e) }
    Any Clues?

    Thanks for the speedy response. I tried this and the problem is still there.
    I did some further testing and the original script, and the new one modified to include your correction, both work if the PDF only has one page.
    With more than one page Acrobat 'has stopped working'

  • Batch Sequence with JavaScript

    Hi Guys,
    I have a batch sequence that won't save the original files. I'm getting a message "The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder."
    However, another batch sequence that runs on the same file saves it fine so I know that noone else has it open and that and I know I have rights to that folder.
    The sequence that won't save the file sets the open optons and has JavaScript in it that collapses the many bookmarks.
    Is there something about having JavaScript in the batch sequence that's not allowing this to save?
    Many thanks,
    Ken

    You rock!! That made it all go.
    I was mistaken befeore thought, its the JavaScript Editor that's coming up on the screen when I run the sequence. I have to close it with the OK button before the sequence finishes. It comes up for each file I process. Trouble is I can't imagine what I've changed that would cause that to start happening.
    The code looks like this:
    //Collapses all bookmarks and shows the bookmarks panel
    function BookmarksCollapse(bkm, nLevel)
    var s = "";
    for (var i = 0; i < nLevel; i++);
    bkm.open=0;
    if (bkm.children != null)
        for (var i = 0; i < bkm.children.length; i++)
            BookmarksCollapse(bkm.children[i], nLevel + 1);
    BookmarksCollapse(this.bookmarkRoot, 0);
    //app.execMenuItem("ShowHideNavigationPane");
    //app.execMenuItem("ShowHideBookmarks");
    this.saveAs(this.path);

  • Batch sequence to remove document JavaScript

    Does anyone know of a batch sequence that can remove the document JavaScript from a group of Acrobat 9 Pro PDFs?

    If the doc-level Javascript names are not known in advance, then the only way I found to remove all of the Javascripts is with doc.extractPages(), which will create a new doc object, and then newDoc.saveAs() followed by newDoc.closeDoc().
    I don't do this in a batch sequence but in a .Net app, so I'm not entirely sure how you would write this in a batch sequence.  Here's a code snippet that shows the basic logic:
                    object AcroJS = AcroPDDoc.GetJSObject();
                    string PdfFullPath = "C:\\filename.pdf";
                    Type T = AcroJS.GetType();
                    object newDoc = T.InvokeMember("extractPages", InvokeMethodFlags, null, AcroJS, null);
                    AcroJS = null;
                    AcroPDDoc.Close();
                    object[] saveAsDataParam = { PdfFullPath };
                    T.InvokeMember("saveAs", InvokeMethodFlags, null, newDoc, saveAsDataParam);
                    T.InvokeMember("closeDoc", InvokeMethodFlags, null, newDoc, null);
                    newDoc = null;
                    AcroPDDoc.Open(PdfFullPath);
                    AcroJS = AcroPDDoc.GetJSObject();
    This can also be used to create a new doc GUID.
    Bill

  • Using Batch sequences in Acro Xi Mac

    Hello Everyone:
       I have a couple of scripts heavily in use that required they be built as part of a batch sequence, as they deal with multiple PDFs.. 
       These scripts are fairly large (one about 1000 lines, one in excess of 3000 lines) with the potential to get even larger. 
       Additionally, several requests for scripts are rolling down the line that look to be of similar or greater size. 
       The Adobe Acrobat editor is just not a good fit for building such large scripts.  I have switched the editor to UltraEdit, which is a much more capable editor.
       However, the problem comes when a new version is finished and I need to install it in other computers.  It seems that the only way to do this is to copy the script into a text file, take that text file to the next computer in line, open it up in a text editor, copy the script to the pasteboard, open up the batch sequence, open up the execute Javascript command, open up the script and copy the new code on top of the old code.  If this needs to be done on multiple machines, it becomes, ahem, tedious.
       Is there any way to save the script to a XXX.js file and just copy the new js file over the old XXX.js file?  I've looked at addscript but was not reassured by its examples in the Batch Sequence PDF that it could do the job I need it to do..

    Gilad:
       Thank you.  Though I would have preferred something a bit simpler, the import/export method you suggest is indeed simpler than the process I was using.  It still has its warts and wrinkles, but with practice I am sure I can find ways to minimize those minor irritants.
    R,
    John

  • Batch Sequence Problem

    I am using Acrobat 9.4. I have a JavaScript that runs a batch sequence to create pop-up tool tips for certain words and phrases. The sequence works properly on most PDF files. I have a problem that on one basic PDF file the batch sequence properly creates the pop-ups but in the process converts the file to a PDF Form. The JavaScript author believes the problem must be that Acrobat adds Form Fields to the basic PDF file during the sequence operation and then thinks the file is a PDF Form. Is there any way to stop this from happening?

    Technically, a document with just a single button is a form. If you mean that the Forms document message bar appears, then that's a known problem. There is a user preference that controls whether the message bar is shown, but it's up to the user to set it.
    Without seeing the code, it seems apparent that it does add some type of form fields to the document to implement the tooltips and that is indeed the reason you're seeing the mesage bar.

  • Batch Sequence Page Scaling

    I have a few hundred PDFs that I need to change the page scaling on, hopefully using a batch sequence or another automated method. I know I can change a single PDF in Acrobat by going to the Advanced tab on the Document Properties and setting the Page Scaling to Default, but I do not want to change hundreds of PDFs manually. I have also tried creating a PDF package and changing the document properties, but it only affects a single PDF in the package.
    I am really looking for a JavaScript code to use in a batch sequence that will change the page scaling to either "fit to printable area" or "shrink to printable area" and save the document with that setting so I can distribute them to others with the page scaling already set and ready from them to print.

    I have been able to use code in Acrobat 6 Standard (Advanced - JavaScript - Document Actions - Document Will Print) to change the page scaling on documents, but it only saves the action in Acrobat 6 and does not save the print setting when the PDF is opened in Reader or Acrobat 8. I tried copying the full acro_script from Acrobat 6 to 8 using a batch sequence in 8, but it does not work.
    Code used in Acrobat 6:
    var pp = this.getPrintParams;
    pp.Handling = pp.constants.handling.shrink;
    Is there a way to convert this code to work in 8? And is there somewhere else in Acrobat 8 (I have Pro) to enter JavaScript besides in a batch sequence?

  • Batch sequence memory leak?

    I wrote a JavaScript batch sequence and ran it in Acrobat 9 Pro on a folder of PDFs. Acrobats memory use steadily increased until it hit 1.1 GB. Then an Acrobat dialog said no files were processed, the memory use dropped back to normal and the CPU usage dropped to zero. So it looks like the problem includes a memory leak. As a test, I replaced my batch sequence with a simple, one-line test:
    var r = test;
    It has the same behavior. Any ideas?

    thanks for your reply.
    i have gone through those APIs you have mentioned and understood that we can run any custom command or existing global command using those APIs.
    my requirement is to launch the sequence file created. is there any way to directly launch the sequence file or else do i need to process the sequence file to know the command and parameters?
    if i need to process the sequence file, it will be always "Recognize text using OCR" and parameters may differ. for this, what is the command i need to execute?
    i am new to this environment, please dont mistake me.
    thanks in advance.
    regards

  • Can you create toolbar icons to launch batch sequence?

    As per subject is it possible to create a toolbar icon in Acrobat 8 to launch a specific batch sequence?
    Thanks
    Steve

    Thanks,
    It seems that each time I delve into Acrobat javascript I can do part of the job in a batch sequence and the other part in folder level java but not the lot in either one!
    The stumbling block was setting initial page opening options via a folder java script so all the actions would be triggered by a toolbar button (update doc info, set security options and initial view of the PDF currently open in Acrobat).
    Thanks anyway at least I know I did not miss how to add the buttons in the Adobe guides.
    Steve

  • Possible to do make Batch Sequence Searchable by date?

    I want to know if it is possible to edit/create new script to Edit Batch Sequence - Searchable, recognize text Using OCR, but to only do it for a date range? How would I go about doing this.
    Right now it takes multiple screens and clicks to make documents searchable, I would like to create a script that tells you the last time you did a batch searchable request, allows you to select a date range, folder would ideally be built in - so I do not have to select it everytime and then on selection of date range, it runs and completes the request. Is this possible? Where do I start?
    Thanks,
    haleygurl86

    Date of what? Do you mean the file's creation date?
    If so, that's not possible. You can access the file's creation date in a script, but a script can't OCR a file.
    The best way would be to create an input folder and paste into it the files you want to OCR.

  • Additional Batch Sequences for Acrobat 9 Pro

    In my downloaded version of Acrobat 9 Pro, there are only a few batch sequences.
    The last time I bought Acrobat on a CD was version 5, and many additional batch sequences came on the CD.  By "additional" I mean that they were not automatically installed when Acrobat was installed, but they could be installed manually.  One could simply copy the additional batch sequences from the CD into the Acrobat installation, after which all of them would be available via the Acrobat interface.
    Is the same true with a CD version of Acrobat 9 -- i.e., has the Acrobat 9 CD additional batch sequences that can be copied into the Acrobat installation?
    If so, is it possible for a user of the downloaded version of Acrobat 9 Pro to obtain those additional batch sequences?
    On my Acrobat 5 CD, the additional batch sequences were in --
    (optical drive letter):\Batch\Sequences
    In my Acrobat 9 Pro installation (under Windows XP Pro), one would copy additional batch sequences to --
    C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Sequences\ENU
    In both Acrobat 5 and Acrobat 9, it appears that the names of all batch sequence files end in the extension .sequ
    I would particularly like to obtain the "List all Bookmarks" batch sequence.  I copied that sequence from the Acrobat 5 CD to the Acrobat 9 installation, and it "sort-of" works.  The main problem is that its list of bookmarks is limited to one page, regardless of the number of bookmarks.  Any bookmarks that would be listed on pages 2, 3 etc. of the list of bookmarks are not listed at all.
    Is it possible for me to download or otherwise obtain the Acrobat 9 "List all Bookmarks" batch sequence?
    Thanks!

    Thank you, try67, for that insight.
    Here is the "List all Bookmarks" batch sequence from the Acrobat 5 CD:
    /* List all Bookmarks */
    /* Recursively work through bookmark tree  */
    function PrintBookmarks(bm, nLevel)
        if (nLevel != 0) { // don't print the root
            bmReport.absIndent=bmTab*(nLevel-1);
            bmReport.writeText(util.printf("%s",bm.name));
        if (bm.children != null)
              for (var i = 0; i < bm.children.length; i++)
                PrintBookmarks(bm.children[i], nLevel + 1);                          
    bmTab = 20;
    bmReport = new Report();
    bmReport.size = 2;
    bmReport.writeText(this.title);
    bmReport.writeText(" ");
    bmReport.size = 1.5;
    bmReport.writeText("Listing of Bookmarks");
    bmReport.writeText(" ");
    bmReport.size = 1;
    PrintBookmarks(this.bookmarkRoot, 0);
    global.bmRep = bmReport;  // make global
    global.wrtDoc = app.setInterval(
        'try {'
        +'       reportDoc = global.bmRep.open("Listing of Bookmarks");'
        +'       console.println("Executed Report.open");'
        +'       app.clearInterval(global.wrtDoc);'
        +'       delete global.wrtDoc;'
        +'       console.println("Executed App.clearInterval");'
        +'       reportDoc.info.title = "Bookmark Listings";'
        +'       reportDoc.info.Author = "A. C. Robat";'
        +'} catch (e) {console.println("Waiting...: " + e);}'
        , 100);
    I am not a programmer, and so would be grateful if you would advise how that sequence should be modified to incorporate your suggestion.
    Thanks!

  • Batch Sequences can't convert 10.000 pdf-files at one time

    I have Acrobat Professional 7.0 and I am running on Windows XP.
    To convert from PDF to EPS I am using Advanced - Batch processing - Batch Sequences.
    Every week I have around 5.000 PDF-files which have to convert to EPS without any problems.
    Sometimes I have more than 10.000 PDF-files. After converting to EPS I thought Acrobat Pro was finishing to convert all the PDF, but if I look at the number of EPS, it seems Acrobat Pro didn't convert them all and it didn't give any error message.
    This always happened when I have more than 10.000 PDF-files.I think Batch sequences cannot convert above 10.000 files at one time.
    Is this a known issue? Is there any solution?

    File > Export >  Export Multiple Files will work as well.
    You can choose your conversion settings in Edit > Preferences > General > Convert from PDF.

  • Running a batch sequence in Acrobat 11

    Hi All:
       I am running a batch sequence in Acrobat 11 on the Mac and as quickly and conciesly as I can, I want to outline the steps in the process:
    1.)  Select the batch sequence to be run.
    2.)  Select the files upon whic to run the batch sequence.
    3.)  Click Start.
    4.)  The text of the script appears on the screen, highlighted.
    5.)  Click OK to close the script editor and run the script on the first file.
    6.) The text of the script appears on the screen, highlighted.
    7.)  Click OK to close the script editor and run the script on the first file.
    8.) The text of the script appears on the screen, highlighted.
    9.)  Click OK to close the script editor and run the script on the first file.
    <continue the last two steps for each document you process>
    If the user has selected thirty documents to process in this sequence run, then she must see the script apear thirty times, and must press the OK button thirty times to actually run the script on the next Acrobat document.  Ditto for sixty and ninety documents.This is cumbersome and tedious not to mentionn dangerous to the script.  Im ny preactice run I accidently tapped teh spacebar and completely wiped the script!.  Is there any way to tell the program to skip displaying the script at the start of each cycle and just move on to the next job?

    Click the commands you added to the Action and make sure that none of them has the "Prompt User" check-box underneath it ticked.

  • PDF Optimize in a Batch Sequence?

    Does anyone have any ideas on how I can run PDF Optimize on many files at one time? I want the same Optimize options applied to each file in my directory, there are several hundred that need to be optimized. I've researched a bit about batch sequences but optimize does not seem to be part of batch.

    In Acrobat 8 Professional the PDF Optimizer is available in the output options of the batch sequence. You don't need the scripting forum.

  • Using "automating batch sequence" query

    Hi,
    I am trying to add text content to an area of the page in a group of pdf files without having to open each file. I am not replacing existing text. After checking,  I could not find a batch sequence to do this in Acrobat v7.1. Could this feature be available in Acrobat v9.?  and/or would I have to use the (acrobat v7.SDK) to create a script and plug in to do this? or if not, in Acrobat v.9, use the SDK to create the script and plugin?  I would appreciate any information.
    thanks,
    je112

    It's not possible to just add running text to a PDF using a batch process or a script. What you can do is insert a field with text and then flatten it.
    This will have a result similar to adding text to the document, but it will not be an integral part of the running text (ie the text you add will not "push" the rest of the text forward).

Maybe you are looking for

  • Purchase order qty.

    Dear SAP Friends, I have a puchsae order of 1000 qty,out of that i received 800 qty. Now creating Requirement of 1200 qty(Md61) & take MRP Run. It shows Planned order of 1200qty in rec/reqd.qty coloumn,1400 qty in available qty coloumn. What it mean?

  • Issue in S_ALR_87012078

    Hi, When i am executing report S_ALR_87012078 for open items....system showing output like this.... Please guide...how can i see all the records with 223 (showing in Remaining).... Suggest..

  • How to save user input data in pages into database ?

    Dear Friends, Hello. I am developing my first PeopleSoft application using PeopleTools 8.49 and SQL Sever 2005. In application designer, I have created fields, records, records' underlying tables in database, and pages. After users type in data into

  • Read ABAP CDS view data in HANA CDS view

    Hi experts, We have created some ABAP CDS views, which we would like to reuse in a HANA CDS view. When I refer to the ABAP CDS view as "SAP<SYSID>"."Z_ABAP_VIEW_NAME" in the HANA CDS view definition, I get a syntax error: Cannot find artifact... Is i

  • Are there charges for imessaging internationally if one user is on wifi and the other isn't?

    My fiancee is using his ipad in Asia (on WiFi) and I'm using my IPhone in the U.S. to imessage. Are there any charges? What if I'm not on wifi? Is it still free? I have unlimited data.