Skip to main content
philip43378290
Participant
May 19, 2017
Question

Stamps

  • May 19, 2017
  • 2 replies
  • 9883 views

Hello,

I read a lot on internet.
Who can help me or put me in the right direction.

I use Adobe Acrobat DC pro.
I've created a stamp. When a user put this stamp on a document the 'stamp' ask for some questions :

The user has to fill in the question. One question is the filename.
So I want that when the user has filled in the questions that document with stamp will be saved in a folder and filename the user has filled in.
I read a lot about mySaveAs and Adobe LiveCycle and buttons and Folder Level Scripts but it don't work.

How can I give the information filled in by the user in the stamp to the Folder Level Script so the document will be saved with the filename the user has filled in ?

And also for the folder. The folder : "/c/ " and then the company name the user has filled in.

Thanks and regards.

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
May 22, 2017

You've got a bit of a conundrum.  A stamp script, i.e., the code in the calculate script on a field on the stamp is very limited. It is run before the stamp is applied to the document.  In order to save the file after the stamp has been applied requires a code to be run after the dynamic stamp has already finished running. So a stamp script is not the correct place to save a file. There are also other issues with document and system state that will probably prevent you from saving a PDF from a stamp script.  And of course, as try67 has pointed out, the script in your post points to the wrong document.

To do this requires a folder level automation script that performs all actions, accept applying the values to the dynamic stamp.

First, the code you show above is overly complex. You only need this.

mySaveAs = app.trustedFunction(function(doc,path) {

app.beginPriv();

doc.saveAs(path);

app.endPriv();

});

That's it. the app.trustPropagatorFunction() is for adding trust to object members.

Next, how are you creating the popup dialog that collects all the info?

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
May 22, 2017

This can be done, but it requires developing a custom-made script, as well as installing a script on the local machine.

Also, the folders will have to exist in advance. A script can't create a new folder, nor can it save a file to the root C:\ folder, as that is not considered a safe path.

Known Participant
May 22, 2017

Thx for the info.

Can you give me the code for the custom-made script as well as the script on the local machine ?

I used this script, I found on internet, but doesn't work.

1) This scripts save as file : mySaveAs.js

2) Your button code on the "calculate" button.

Can you help me ?

Your folder level function:

mySaveAs = app.trustPropagatorFunction(function(doc,path) {

app.beginPriv();

doc.saveAs(path);

app.endPriv();

})

myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path) {

// Privileged and/or non-privileged code above

app.beginPriv();

mySaveAs(doc,path);

app.endPriv();

// Privileged and/or non-privileged code below

});

Your button code:

// build file name

var myFileName = doc.getField("LastName").value + doc.getField("FirstName").value + ".pdf";

// add folder name

myFileName = "/c/temp/" + myFileName

myTrustedSpecialTaskFunc(this, myFileName);

try67
Community Expert
Community Expert
May 22, 2017

Your code is pretty much there, I think, but to access the parent document from a calculation script in a stamp you need to use event.source.source, not "doc" or "this".