Skip navigation
alienA2
Currently Being Moderated

Javascript/ Batch Processing - Query (Please assist/advice)

Sep 19, 2011 11:23 PM

Hi

 

Where can I find on the internet a JavaScript that will do the following for BATCH PROCESSING:

 

 

-Combine single PDF files

-Crop the pages

-Check the sequence of the pages that it goes from 1,2,3 and so on

-ad metadata to the PDF

-set view

-add bookmarks based on the content page's major headings (e.g. Regulars)

-Making single PDF files over 1.5 MB smaller

-Fix white lines

-Make the final file as a PDF that is compatible with Acrobat 5 or later

 

Thanks

 

 
Replies 1 2 Previous Next
  • Currently Being Moderated
    Sep 20, 2011 12:14 AM   in reply to alienA2

    You're mixing and matching different things here.

    First of all, a batch process is meant to process each file in the same way. It can't combine single PDF files for you.

    What you can do is use a batch process to collect the paths of the files, and then combine them later on with a script.

    For example, this tool (created by me) uses a batch sequence to collect the file paths and then combines all files in the same folder:

    http://try67.blogspot.com/2010/10/acrobat-batch-combine-all-files-in.h tml

     

    After you have your combined file(s) you can indeed use a batch process to do most of what you asked for, whether with a script or one of the built-in commands.

    Some things I'm not sure you can do at all (like "fix white lines"... what do you mean by that?, or to add bookmarks based on the page's content).

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2011 1:22 AM   in reply to alienA2

    The problem is not creating a bookmark with a script (read about the Bookmark object and its createChild() method in the Acrobat JS Reference).
    The problem is identifying the text you want to use for that bookmark.

    The only way I can see this being possible is if this text is always in the same coordinates on the page (more or less), or if it's always the laregest text on the page. Both of these options require quite a complex script to identify this text, though.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2011 3:15 AM   in reply to alienA2

    That's quite easy to do, using the method I've mentioned before.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2011 4:14 AM   in reply to alienA2

    Do you mean an example? Yes, in the reference file.

    Here's an example I sent recently to someone on a different forum:

     

    This code will create 3 bookmarks that go to pages 1 to 3:

     

    1. this.bookmarkRoot.createChild({cName:"Page 1", cExpr:"this.pageNum = 0", nIndex: 0})
    2. this.bookmarkRoot.createChild({cName:"Page 2", cExpr:"this.pageNum = 1", nIndex: 1})
    3. this.bookmarkRoot.createChild({cName:"Page 3", cExpr:"this.pageNum = 2", nIndex: 2})
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2011 4:35 AM   in reply to alienA2

    Look at the various actions that are available to you when you create a new batch sequence. You can do most on the items on that list using those actions.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2011 5:35 AM   in reply to alienA2

    I'm not following you... What do you mean, exactly?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2011 6:55 AM   in reply to alienA2

    this.bookmarkRoot.createChild({cName:"Front Cover", cExpr:"this.pageNum = 0"})

    this.bookmarkRoot.createChild({cName:"Back Cover", cExpr:"this.pageNum = this.numPages-1"})

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2011 5:04 AM   in reply to alienA2

    Can it identify text with a certain color, and/or font style?

    No.

     

    Is it able to select the number of the heading and use that number as the set destination?

    No.

     

    I would like to delete the existing bookmarks first then add my own bookmarks. How do i do this?

    Use the method remove() of the Bookmark object.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2011 10:41 AM   in reply to alienA2

    I assume you referring to this.bookmarkRoot.remove();

    Well, this.bookmarkRoot.remove() will remove all the bookmarks, but the remove() method can also be used to remove specific bookmarks.

     

    1. Execute a plug-in software, which I have installed to use inside Acrobat, to run inside Adobe Acrobat Pro?

    I don't think so. The other way around (plugin executing JS code) is possible, though.

     

    2. Extract seperate pdf pages from 1 to the end of the Pdf file and place them in a specific folder.

    Yes. See the extractPages() method of the Document object.

     

    where could I find the batch sequences which I have created in the Acrobat directory folder?

    Acrobat has two folders for batch sequences, one for system ones and one for user-defined ones. You can find out what the user-defined path is on your machine by executing the following code from the console:

     

    app.getPath("user","sequences")

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 22, 2011 5:17 AM   in reply to alienA2

    Then call it multiple times, each time for each page number you want to

    extract (using different file names, obviously).

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 22, 2011 5:17 AM   in reply to alienA2

    Did you execute it using Ctrl+Enter?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 23, 2011 12:27 AM   in reply to alienA2

    You need to specify the cPath parameter with a unique file name (you can use

    the value of the iterator i in the file name)...

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 23, 2011 1:18 AM   in reply to alienA2

    Almost. The path needs to have the correct syntax used by Acrobat JS for

    files, and must also end with ".pdf", so something like this:

    cPath: "/c/extr/page" + 1 + ".pdf"

    (I'm assuming here you're running this code from a batch process. If not,

    you'll need to place the entire thing in a trusted function, as is explained

    in the Reference)

     

    Also, when you extract a page it is not automatically opened, so there's no

    need to close it.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 24, 2011 10:11 AM   in reply to alienA2

    You need to use some kind of unique identifier in the filename, for example

    you can use the original file name or define some kind of global counter

    that you increment after each save.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2011 2:03 AM   in reply to alienA2

    this.documentFileName

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2011 2:40 AM   in reply to alienA2

    I don't really understand. documentFileName returns just the file name

    (including the extension).

    If you don't want the full file name there are various options of editing

    it, like with a regular expression or with the various methods of the String

    object. You'll need to define what it is, exactly, that you want to do,

    though.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2011 7:01 AM   in reply to alienA2

    this.documentFileName.replace(/\.pdf$/i,"")

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2011 12:35 AM   in reply to alienA2

    In the batch process script, you can use something like this:

     

    if (/apple/.test(this.documentFileName)) {

         // then add the "apple" bookmark

    } else if (/banana/.test(this.documentFileName)) {

       // then add the "banana" bookmark

    }

     

    etc.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2011 1:12 AM   in reply to alienA2

    If you want, you can contact me by email: try6767 at gmail dot com.

     
    |
    Mark as:
1 2 Previous Next
Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points