Flatten, save and email Submit Button using java

New Here ,
Jul 18, 2018 Jul 18, 2018

Copy link to clipboard

Copied

I want to flatten, save and email a PDF using javascript. The document will be saved on a local server but emailed to someone who will not always have access to. I want the file to be sent as PDF but when it arrives to the recipient they get the error message that the file cannot be found as they do not have access to the server..

What is the best javascript to use here?

I'm using Windows, have Acrobat DC.

TOPICS
Acrobat SDK and JavaScript

Views

752

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 ,
Jul 19, 2018 Jul 19, 2018

Copy link to clipboard

Copied

Flattening requires using Acrobat.

Saving (assuming you want to specify the file-name) requires installing a script on the local machine.

Are those two things possible in your case?

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
New Here ,
Jul 19, 2018 Jul 19, 2018

Copy link to clipboard

Copied

I'm not exactly sure - so - lets assume for now it's not possible and forget flattening the file and just focus on save and email.

In the case I described I would need someone without access to local server (working remotely) to be able to view the PDF.

Currently the actions I have added to my SUBMIT button are:

MOUSE UP

- run javascript:

flattenFields()

function flattenFields() {

    if (app.viewerType=="Reader") {

        for (var i=0 ; i<this.numFields ; i++) {

            var f = this.getField(this.getNthFieldName(i)) ;

            if (f==null) continue;

            f.readonly = true;

        }

    } else {

        this.flattenPages();

    }

}

- execute a menu item: File > Save As (user nominates the Folder in Server and saves)

- Run javascript

var url = "mailto:software@cliffordwallace.com.au?subject=New Feature Request&body=I would like to submit a new feature request. Please find attached.";

this.submitForm(url,true);

All I want is for the form to be saved as PDF and emailed to the software email flattening it isn't imperative.

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 ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

OK, and what's not working with the way you have it now?

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 ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

LATEST

You should do it all using a single script, like this:

function flattenFields() {

...

}

flattenFields();

app.execMenuItem("SaveAs");

var targetURL = "mailto:software@cliffordwallace.com.au?subject=New Feature Request&body=I would like to submit a new feature request. Please find attached.";

this.submitForm(targetURL,true);

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