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
![]()
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).
Okay
Let us assume the file is combined.
How do I Create Bookmarks with a script?
I would like to take the text from the Main heading from the Contents page, and use that text as the name for the Bookmark.
For example. I have a mag that use content heading such as Regulars and Reviews.
I woud like Regulars to be a bookmark; AND
I would like Reviews to be a bookmark.
It must also link the bookmark to a SET DESTINATION where the first article from that heading is on the pdf. For example if the First article for Regulars is on page 10, it must go to page 10 when you click that bookmark.
Basic tasks that can be done manually, however when you have 1000s of Pdfs to go through, this is tedious and repetetive.
**********************
White lines I am referring transparency images which I not flattened before converting to PDF. You can see white lines on a pdf...
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.
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:
- this.bookmarkRoot.createChild({cName:"Page 1", cExpr:"this.pageNum = 0", nIndex: 0})
- this.bookmarkRoot.createChild({cName:"Page 2", cExpr:"this.pageNum = 1", nIndex: 1})
- this.bookmarkRoot.createChild({cName:"Page 3", cExpr:"this.pageNum = 2", nIndex: 2})
Will try this in a bit.
What about the other processes which I have queried:
-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
-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
******
Example:
Let us just say that there are 3 Main headings on the content page. They are:
CONTENT PAGE:
They also have PAGE NUMBERS where each article starts for the Headings...
CONTENT PAGE:
Based on the example above, does the script understand HOW TO identify a text? I know you said it is complex to do this BUT...
Can it identify text with a certain color, and/or font style?
The reason I ask this is that if it could identify a text with a certain color (and maybe also a font style), it would pick those up and create bookmarks based on those specific requirements on the text from a certain page.
Also...
Is it able to select the number of the heading and use that number as the set destination?
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.
The latter answer you wrote..., I assume you referring to this.bookmarkRoot.remove();
I have more queries. Can Scripting, also:
1. Execute a plug-in software, which I have installed to use inside Acrobat, to run inside Adobe Acrobat Pro?
2. Extract seperate pdf pages from 1 to the end of the Pdf file and place them in a specific folder.
Also, where could I find the batch sequences which I have created in the Acrobat directory folder? I created a sequence but I cannot find it inside the Acrobat folder at Program files called sequence (PC)? I want to duplicate the same sequence and modify it a bit for a second processing batch.
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")
this.extractPages({nStart:5, cPath: "TestExtract1.pdf"});
It just saves the entire extract which I have asked to extract, into one full pdf file.
My purpose what I want it to do, is for it to save the SEPERATE/single pages from the original pdf mag, and save those single pages into a specific folder. How can I do this?
"
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")
"
I tried using that code in the console inside acrobat. It did not return anything?
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.
Got the script to work eventually for extraction. The next issue is how to extract single pages for multiple pdf files, without it overriding the extractions.
For example,
If we have two PDF files in the source folder, and the javascript executes, it extracts and saves each single pdf file as it should.
The issue lies when it extracts the next PDF file, because it is overriding the extracted single pages which it did for the previous pdf file.
Is there a method ,or a coding, that will give me the source file name of the file I am busy extracting.
Purpose what I would like to achieve, is for the extracted single page to be saved, with the source pdf file name along with the page number from which it is extracting.
This will then not overwrite any files becuase every file will have a different name, obviously.
e.g. saveAs("/c/extracts/" + SOURCE_FILENAME + "_page_" + (page_counter +1));
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.
lol...my bad ![]()
It is actually working...but it is adding the ".pdf" extension. How can I remove the extension of the DocumentFileName, so that I only adds just the filename and no extension?
eg. If the two magazines I have are called Bananas and Apples, it is doing this:...
Bananas.pdf_page 1,
Bananas.pdf_page 2,
Bananas.pdf_page 3
...
I would like it to do this:
Bananas_page 1
Bananas_page 2
Bananas_page 3
Is there a way to read multiple pdf files with different filenames, and do the following:
If filename has the words "apple"
then
add bookmarks for "apple"
elese
if filename has the words "banana"
then
add bookmarks for "banana"
...
(The bookmarks are based on the main headings of the content page from the pdf mag file.)
The end object is to do this in batches/ all at once...
North America
Europe, Middle East and Africa
Asia Pacific