These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Batch process question

2ndshift
Registered: Mar 25 2010
Posts: 15

Hello all,
 
Using Acrobat 9 Pro, I have a bunch of converted PDF's in which I would like to perform a batch process, but I'm stumped. I can get pieces of the sequences but when I try to put them together it doesn't act like I would expect.
 
It goes something like this...
 
Command 1: Convert .docx to pdf (haven't got to this part yet)
 
Command 2: Detect and delete form fields from pdf's (this is what I have but doen't work):
for(var i = this.numFields - 1; i > -1; i--) {var fieldName = this.getNthFieldName(i); this.removeField(fieldName); }
 
Command 3: Add form fields at the bottom of the page, then in each field add a message and the date and time it was printed when it is printed:
for (var i = 0; i < this.numPages; i++)
{
var fd = this.addField("DocMessage", "text", i, [50,1,600,30]); fd.textSize=8; fd.textFont = "Arial"; fd.alignment = "center"; fd.fillColor = color.transparent; fd.textColor = color.black; fd.readonly = true; fd.print = true; fd.display = display.noView; } var strJS = 'var ofield = this.getField("DocMessage");';// Add Field to Document Script var strJS = 'var ofield = this.getField("DocMessage");'; strJS += 'var theDate = (new Date((new Date()).valueOf() + 1000 * 60 * 60 * 24 * 0));'; strJS += 'ofield.value = "This copy is an uncontrolled document and may not be reproduced without permission. Printed: ";'; strJS += 'ofield.value += " " + util.printd("mmm d, yyyy h:MM tt",theDate);'; this.addScript("AddMessage",strJS);
this.dirty = false; // prevent save prompt;
 
Command 4: Add electronic signature/certification (haven't got to this yet)
 
What am I doing wrong?
 
Any help would greatly be appreciated.

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
For #2, what does happen when it's executed? Any errors?

You haven't said what's wrong with #3.
2ndshift
Registered: Mar 25 2010
Posts: 15
Lets say that when the PDF is originally created, there are no Form Fields. If you ask to detect form fields, the fields become visible.

If you run #3 by itself it doesn't work. You have to detect the form fields, then delete whatever comes up, then run #3...presto, #3 works.

If you detect the form fields first then run #2, it actually deletes the fields, but then will not run #3.

Is there a way to run the form wizard to detect and delete fields in a batch process???
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
This doesn't make sense to me, and is not normal. You definitively should be able to add fields to a document that doesn't already have any. I would try starting simpler, by just creating a simple text field on the first page and go from there. Just run your first line of code and not the rest for the time being. If that doesn't work, then something else is wrong. If it does, there may be a problem with the rest of your code.

Also, the following:

fd.print = true;

should be removed.

2ndshift
Registered: Mar 25 2010
Posts: 15
When you use the wizard to detect fields when converting from a .docx to pdf, there are usually some fields. I guess what I am trying to do is either detect the fields and remove them before running #3...or detect the fields, keep them, then run #3 which adds another field to each page.

fd.print=true because I only want it to be viewable on print.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
The print property is deprecated in favor of the display property, which is what you subsequently use correctly, so it's superfluous.

I guess what I don't get is why you're choosing to detect fields if all you're going to do is remove them. Can you clarify why you're doing this?
2ndshift
Registered: Mar 25 2010
Posts: 15
I'll go through the steps that I am performing:

1. Convert .doc to PDF using AAPro
2. If I run #3, I don't get anything
3. I go to the Add or Edit Fields function under Forms
4. It says: Currently there are no form fields in this PDF. Do you want Acrobat to detect form fields for you?
5. I click yes and it lists the form fields that were detected (there are many)
6. I sort the fields alphabetically then delete them all
7. I save and close
8. I run #3 again and ...now it works!!??

I am wondering why I have to go through the motions of detecting and deleting before I run #3. If this is something I MUST do, then I would like to run a batch process to detect, delete and run #3. The problem is I can get it to do all three separately, but when used together, it doesn't work.

I tried using the default functions in the batch processing options (detect form fields, order form fields) in a combination of ways, but to no success.

Is there another way to achieve what I would like to do? Or is there something else that I am missing?

Thanks for your help.
2ndshift
Registered: Mar 25 2010
Posts: 15
Another question...I used the Preflight option to "Flatten annotations and form fields" after detecting the fields, then ran #3...and it worked. So I figured I would go make a new batch sequence:

detect form fields>flatten layers then run #3...and it didn't work!!??I guess the Preflight action works, but can I run a Preflight action with multiple documents at the same time?
2ndshift
Registered: Mar 25 2010
Posts: 15
Whoops, I just found the Preflight in the batch sequence setup.
Detect form fields>Preflight action> run#3...
But it still doesn't work.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
OK, so it appears you've stumbled upon a workaround for not being able to add fields programmatically. I'm suggesting that you ignore this and find out why you are unable to add the fields in the first place. Did you take my suggestion and keep it simple at first?

Also, change the code to:

var fd = this.addField("DocMessage", "text", i, [50, 30, 600, 1]);

The two Y coordinates are switched.
jasmineb
Registered: Dec 8 2010
Posts: 2
I have Acrobat 9 Pro. I use the Batch Processing for Detect form fields. When it do that it created the fields I need but the wrong type. Is there a way I can change the type of them in JavaScript? I need something down simple as possible for the clients can do less things in Acrobat.

Currently, the Client will open document. Select sign and use the Topaz signature hardware. Then I created a batch process for adding a watermark for stamping. So all they have to do is just sign and batch process a stamp at top of page.

Jasmine
Tuskegee Alumni!!!!

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Hi Jasmine,

I created a tool that allows you to convert one type of form fields in a PDF to another.
Have a look here for more info: http://try67.blogspot.com/2010/10/acrobat-convert-form-fields-type.phpYou can contact me personally if you're interested in it.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Altering the document will invalidate any signatures that have been applied prior.
rhino
Registered: Dec 8 2010
Posts: 5
Hey George, Call me when you get a chance. Thanks Rhino
jasmineb
Registered: Dec 8 2010
Posts: 2
Ok. I got it to work with adding the signature field to the pages in Javascript. Is there a way you can give me heads up on how to prevent the security properties from changing with the person sign? I tried addWatermarkFromFile() and add watermark. It will not let me add a watermark to a file that have been sign. I see that a previous Acrobat version had a batch process for adding a stamp.

All we trying to do now is add a watermark in batch processing to a sign document with allowed changes. Is it possible to at least at a stamp in batch processing with our custom stamp?

Jasmine
Tuskegee Alumni!!!!