• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Stamps

New Here ,
May 19, 2017 May 19, 2017

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript

Views

4.2K

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 Expert ,
Jun 09, 2019 Jun 09, 2019

Copy link to clipboard

Copied

You can use a global variable to save the name of the stamp used and then access it through your save script, or you can save that stamp's name into something like the file's metadata.

Votes

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
New Here ,
Jun 09, 2019 Jun 09, 2019

Copy link to clipboard

Copied

LATEST

Thx.
That was the solution.
In the stamp I added this line in a Text field : globel.stampname = "Stamp";

Then in the MyProcSave.js I added a line :

If (globel.stampname = "Stamp") .............

And that works.
Thanks for the quick support.

Votes

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
New Here ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

I changed the code in the calculate (see below)

Now the PDF is saved with the name you filled in the "Filename" text box.
But the stamp is not on is. Is like the original PDF.
The stamp = Filename : (and then the name you filled in).
But the saved file under c:/temp/ has the name I filled in but without the stamp.

Example : I fill in the filename : test and the filename under c:/temp/test.pdf.
That OK but how can I get the file with stamp ?When I fill in the console  : this.filename or this.documentfilename is for both undefined.

var cAsk = "Give Filename";

var cTitle = "Filename";

if( event.source.forReal &&

(event.source.stampName == "#Filename")){

var cMsg = app.response(cAsk, cTitle);

event.value = cMsg;

event.source.source.info.DocumentState = cMsg;

var Filenaam = cMsg;

var myFileName = Filenaam + ".pdf";

myFileName = "/c/temp/" + myFileName

mySaveAs(event.source.source, myFileName);

}

Votes

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 Expert ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

And the reason the file is named "undefined.pdf" is because of this line:

var myFileName = event.source.source.Filename + ".pdf";

event.source.source refers to the document object being stamped,

but there is no "Filename" property of the document object. It should be

var myFileName = event.source.source.documentFileName + ".pdf";

Something that you should always do when writing code (any code for anything) is to verify the names of the things referenced in the code.

For example, open the console window, enter and run this:

this.Filename

It will return "undefined"

Now enter and run:

this.documentFileName

See what happens

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

Votes

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 Expert ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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