How can I add a custom stamp to multiple files?

Community Beginner ,
Jun 06, 2019 Jun 06, 2019

Copy link to clipboard

Copied

I am trying to batch add stamps to the bottom right corner of a large number of files. The stamp only needs to include the filename (minus the file extension) and one value to be entered by the user at the start of the action. I see documentation to add the standard stamp and in the position I want, but I can't seem to get the dynamic stamp name to insert that in a batch.

My ultimate goal is to add a small amount of white space to the bottom of the first page of each document, insert the stamp with the user info and filename, flatten the pdf, and scale the document back to 8.5" x 11". Is this something I'll be able to actually get to?

Thanks all!

TOPICS
Acrobat SDK and JavaScript

Views

276

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 06, 2019 Jun 06, 2019

Copy link to clipboard

Copied

The document file name is the "documentFileName" property of the document object.

In a stamp script the document object being stamped is in "event.source.source" property

So your stamp script could look like this:

event.value = event.source.source.documentFileName.replace(/\.pdf$/i,"");

I haven't tested this in a batch process, but it will work in a regular dynamic stamp. But it should also work when the stamp is applied inside a batch processing script.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 07, 2019 Jun 07, 2019

Copy link to clipboard

Copied

HI Thom, thanks for the reply!

So my actual issue is finding a way to call the custom stamp during the Adobe action process. I can't seem to get the stamp name for each individual file without first placing the stamp. I spent most of the day yesterday and decided maybe a FreeText annotation would work better than a dynamic stamp.

The issue I am running into now is once i add the space for the footer and FreeText annotation, how do i "burn in" the annotation and resize the page back to 8.5" x 11"  is that something that can be done through the script or do i have to manually print each file to the virtual PDF printer and choose the fit option? I am trying to automate this process as much as possible.

Thanks again!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 07, 2019 Jun 07, 2019

Copy link to clipboard

Copied

The stamp name never changes. Its always the same.  But a free text annot works great and it's easy if all you want is text. Stamps are better if any graphics are involved.

You can flatten the document after applying the text annots.

So Page resizing and scaling are two different things. Sizing is done with the "setPageBoxes" function. Scaling is a different animal all together and much more difficult. As you've suggested, printing to a file, i.e. refrying the PDF is one technique, and somewhat representative of the options available in JavaScript. If you were writing a plug-in, Then the actual page content could be scaled.

So down to business. Yes, the easiest way to scale a PDF page is to print the doc to a file. This also flattens all interactive content. This does not always work when printing to a PDF. But since you are specifically scaling the PDF it might work. If not, print to PostScript, then open the post script file to convert it back to PDF.  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 07, 2019 Jun 07, 2019

Copy link to clipboard

Copied

i'm trying to automate this task as much as possible. basically i want to put a larger freetext box on the first page in newly added white space at the bottom so that none of the content of the document is covered by the freetext, and page numbers on all of the rest of pages also in newly created white space at the bottom and then flatten and resize the whole thing back to 8.5 x 11 and flatten. Printing each file to PDF after the process completes each time I do this seems a bit cumbersome, but it sounds like scaling the pages down through a script is also a bit tedious. Can you point me in the right direction on that?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 07, 2019 Jun 07, 2019

Copy link to clipboard

Copied

LATEST

Yes, scaling a PDF is cumbersome. The Acrobat JS model has no built-in features for this, so you have to find a creative way to get around it. And I already told you how to do it. Look in the Acrobat JS Reference for the PrintParams object.

Look at the example for the "fileName" property, here:

Acrobat DC SDK Documentation

There are a couple of other ways to scale PDF pages. Both requires creating a new document with exactly the same number of pages, but blank. Then you apply the content of the original to the new blank page as either a watermark or a button. Both of these mechanisms control the scaling.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines