Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Save As button with field entry (rawValue) rename

Avatar

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
zekik97070415
Level 1

10-02-2016

Hello there,

please help me with this issue.

I want to have "Save as" button, when I click it rename file name in specific field entry name( rawValue ) and Save it silently with massage box.

Tried as much I can learn, because I have no clue with js coding. I understand that part with js file in Adobe JS folder, but have to put wright code.....

Thx in advance.

Files: https://mega.nz/#!OQQSAAZS!N0coQsfr6XVr7WdyPGvKwo0b1OuFicy5Qc7kjLjRF7E

Capture+field+Cbr.PNG

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

29-02-2016

Hi,

if you're using an XFA form, then you just need to take over the scriptings from the sample form you can download from my blog.

The script I've posed earlier doesn't work with XFA forms as the syntax is especially for static AcroForms, so forget about it.

Answers (10)

Answers (10)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

15-03-2016

Hi David,

you forgot to copy the script object "Utils" from my sample into your form, so the function call in you save button points to nowhere.

Anyway, you can get it work easily.

Just replace the buttons current script with:

function lcbSave (vDoc, vPath, vCurrentName, vDefaultName) {

    if (vCurrentName === vDefaultName) {

        try {

            event.target.lcbSaveAs(vDoc, vPath);

            xfa.host.messageBox("File was saved under:\r\r" + vPath.toUpperCase(), "File Saved", 3, 0);

            xfa.form.execInitialize();

        } catch (error) {

            xfa.host.messageBox(error.toString().replace("RaiseError: ", "") + "\r\rEnsure the destination folder exists and there isn't already a file with the same file name in that folder!\n\n" + error, "Failed to save file", 0, 0);

        }

    } else {

        app.execMenuItem("SaveAs");

    }

}

lcbSave (event.target, pathToNewFile.rawValue, event.target.documentFileName, "test.pdf");

Avatar

Avatar
Level 1
davidurbanek
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
davidurbanek
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
davidurbanek
Level 1

12-03-2016

Hello,

I used your expamle files. It helped me, but I still have a problem.

I need to create a button in static PDF form, which will always save PDF to C:\Tmp\toPrint and the file name will be taken from field "barCode" from the form.

I finaly able to display the path to new file, but the button does not work.

You can download my files at http://www.uschovna.cz/zasilka/HTUK8VMMEU62PF87-7IV/

Can you help me with this please?

Thank you very much.

David

Avatar

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
zekik97070415
Level 1

25-02-2016

LCD sava as btn.PNG

Avatar

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
zekik97070415
Level 1

25-02-2016

Field name.PNGAdobe XI JS notice.PNG


function lcbSave (vDoc, vPath, vCurrentName, vDefaultName) {


if (vCurrentName === vDefaultName) {


  try {


   event.target.lcbSaveAs(vDoc, vPath);


   xfa.host.messageBox("File was saved under:\r\r" + vPath.toUpperCase(), "File Saved", 3, 0);


         xfa.form.execInitialize();


  } catch (error) {


   xfa.host.messageBox(error.toString().replace("RaiseError: ", "") + "\r\rEnsure the destination folder exists and there isn't already a file with the same file name in that folder!\n\n" + error, "Failed to save file", 0, 0);


  }


} else {


  app.execMenuItem("SaveAs");


}


}


Mine situation in pictures and JS code which is in Adobe JS folder.

Avatar

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
zekik97070415
Level 1

25-02-2016

Of course. I know that is right solution...

I just don't know how to name my file, what to replace in yours codes, rename in yours codes, etc....

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

25-02-2016

Avatar

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
zekik97070415
Level 1

25-02-2016

Nope, I cant understand what should I change, with what, etc.

Avatar

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
zekik97070415
Level 1

24-02-2016

Dear

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

23-02-2016

Looks like you're using an AcroForm indstead of an dynamic XFA form.

You can recycle my solution for XFA forms to use it in AcroForms to.

All you need is to install the Folder Level Script from my solution into you Acrobats JavaScript folder and to add a button in your AcroForm that executes a JavaScript:


var cDefaultName = "LCB_SaveAs_AcroForm_v3_en.pdf", //The default name of the form (before it is saved by the script)


    cDirectory = this.path.replace(this.documentFileName, ""), //The current directory


    cSeparator = "_", //A Separator for spaces or invalid characters in file names


    cSavePath = cDirectory.concat(this.getField("FileName").value.replace(/\.pdf$/g, "").replace(/[\s\!\?\<\>\'\"\*\/\\\=\?\^\`\{\}\|\~]+/g, cSeparator)).concat(".pdf"); //The save path



if (cSavePath) {


  lcbSave (this, cSavePath, this.documentFileName, cDefaultName);


} else {


  app.alert({


  cMsg: "Please enter a name for the file first.",


  cTitle: "Can't save form!",


  nIcon: 0,


  nType: 0


  });


}


Sorry, I can't upload a sample file, Adobe's cloud thinks my AcroForm-sample file contains a virus for some reason?!

Anyway, you should be able to get it work with the script above!

Avatar

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
zekik97070415
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
zekik97070415
Level 1

17-02-2016

Nobody?