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

saveAs java function, wont work!

New Here ,
Jan 13, 2018 Jan 13, 2018

Copy link to clipboard

Copied

I´m trying to create a java-instruction, that, when I press a button, save the current PDF-form under a nwe name. The name of the PDF will be fetched from a field within the PDF-form.

BUT - I can´t get the "saveAs" function to work!

I´m using the Adobe Acrobat Pro DC.

I want to use the java-command because I need to be able to name the new file from a field in the form.

I´ve been trying a couple of different syntax:

this.saveAs();

this.saveAs("file1.pdf");

event.target.saveAs();

event.target.saveAs("teat.pdf");

...

I am lead to belive that it is a problem with security, a saveAs or save function might be able to change data on the computer without the users controll. BUT - the command exists - how do I set it up to work?!

The form will later be mail to different recipients, where I need the same function to work. SO - I can´t place a script in the Java-folder since it won follow the document to the new user?!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.0K

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 ,
Jan 13, 2018 Jan 13, 2018

Copy link to clipboard

Copied

Read the documentation of the saveAs method.

Info: Acrobat uses JavaScript, not Java.

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 ,
Jan 13, 2018 Jan 13, 2018

Copy link to clipboard

Copied

I have - and it still do not have a solution for this to work. This obiously means that my understanding of what I´m doing isn´t as good as it need to be!

However - that is why I´m trying to seek some help here...

1) Is it possible to create a "button", and using Java-code, from the button, to initiate a saveAs command?

2) If it is - Do I have to do any set-up of the file or program/user to get this function to work? If so - how and where?

3) I´m going to use this form on both PC and tablet (Android), is it posible?

4) Where do I go wrong??!?

I´ve understod from another thread that I need to have a folder level script to automate he saveAs function. But why won´t i start at all? Is there an alternative? It do NOT need the save function to be forced without the users input. It would accually be prefered if the user is informed, and asked, if he accepts the saveas action, - but I need the filename to be suggested, so he/she only need to press yes/no or accept/cancel, or something...

As I´ve understood the problems lies in this: ...These methods can be executed only in a privileged context, which includes console, batch and application initialization events. All other events (for example, page open and mouse-up events) are considered non-privileged.

So - how do I run around/solve this problem?

  • I need to have a Save/saveAs function
  • I need it to be executed/initialized by a mouse-up event, the same event that will mail the document to a recipient.
  • I need to be able to suggest the file-name
  • I can´t place a folder level scripts on ALL the recipients computers/tablets
  • I need it to work on PC and Android
  • It should be executed just before I e-mail the document to a recipient, because I need to change the name of the document I e-mail, AND because I want to save a copy of the sent file in/on my computer/tablet.

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 ,
Jan 13, 2018 Jan 13, 2018

Copy link to clipboard

Copied

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
LEGEND ,
Jan 13, 2018 Jan 13, 2018

Copy link to clipboard

Copied

It’s JavaScript not Java!! This is never abbreviated to Java because Java is different.

Info: nothing will work in Android. Savingvisnt even a concept. 

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 ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

LATEST

Here is an article on exactly this topic:

https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

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