Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all 12130 articles
Browse latest View live

Create one report from multiple pdf files

$
0
0

I have an action script to create a report listing the document file names from multiple pdf files.

The script is creating multiple reports for each pdf file, instead of appending each document file name in the single report.

If anyone can help to amend the script so that a single report is created will be most appreciated

 

// Begin job

var docfile = this.documentFileName;

if ( typeof global.counter == "undefined" )

{

global.counter = 0;

}

// Main code to process each of the selected files

try {

global.counter++

global.report = new Report()

global.report.writeText("Report on File \#"+global.counter + docfile + "\r\n");

global.report.open("job report")

} catch(e) {

console.println("Batch aborted on run #" + global.counter);

delete global.counter; // Try again, and avoid End Job code

event.rc = false; // Abort batch

}

// End job

if ( global.counter == global.FileCnt ) {

console.println("End Job Code"); /

/ Insert endJob code here

// Remove any global variables used in case user wants to run

// another batch sequence using the same variables

delete global.counter;

}


Dropdown choice translation into values

$
0
0

Hello, I have created a character sheet for a game and I am stuck trying to translate drop down menu choices into numerical values to work with. The point is that a character is supposed to gain different bonuses according to the race chosen (as shown in the human/elf example below). Now I have the dropdown menu "Races" and I would like to have all the "racialmodXXX" added to the corresponding text fields (for example the "Agilitytotal" text field should be computed by adding the entered value in the "Agility" text field + "racialmodagi".)

 

This is what I have entered into the validation box of the "Races" dropdown menu:

 

var racetype = this.getField('Races');

var racialmodbody = '0';

var racialmodagi = '0';

var racialmodreac = '0';

var racialmodstr = '0';

var racialmodwill = '0';

var racialmodlog = '0';

var racialmodint = '0';

var racialmodcha = '0';

var racialmodedge = '0';

var racialmodmag = '0';

 

if (racetype.value == 'Human')

  {

racialmodbody.value='0';

racialmodagi.value='0';

racialmodreac.value='0';

racialmodstr.value='0';

racialmodwill.value='0';

racialmodlog.value='0';

racialmodint.value='0';

racialmodcha.value='0';

racialmodedge.value='1';

racialmodmag.value='0';

}

 

 

if (racetype.value == 'Elf')

  {

racialmodbody.value='0';

racialmodagi.value='1';

racialmodreac.value='0';

racialmodstr.value='0';

racialmodwill.value='0';

racialmodlog.value='0';

racialmodint.value='0';

racialmodcha.value='2';

racialmodedge.value='0';

racialmodmag.value='0';

}

 

The text field "Agilitytotal" is supposed to report "(Agility) + (racialmodagi)" by calculation but it doesn't. Once I remove (racialmodagi) from the calculation window, it works properly.

 

Sorry for the wall of text but maybe some of you have an idea how to solve this.

 

Thanks a lot in advance!

How to initialize a date field to today's date?

$
0
0

I've got a text field formatted as date.  I'd like the form to come up with the field initially filled to today's date, but to be overridable by the user.

Is there a place to use document level javascript code when you first open the document?  Or can you use the default attribute?

 

How do i insert decoment level code into the pdf?

If Else Statement for PDF Form

$
0
0

I am unfamilar with JavaScript and need to create a calculation for a PDF form. The form is used to determine profit. There is a radio button called payroll with two values, "internal" and "external". One calculation to determine costs will need to say: if payroll equals "internal" then 1.02 else .98. This number will then insert in the costs field. The other calculation to determine markup will need to say: if payroll equals "internal" then 1.2 else 1.4. Thanks in advance for the assistance.

How to Auto-populate TextField in Acrobat x with a value determined by user check box selection?

$
0
0

I have a group of 3 Check Boxes for user to select their Work Shift:  The check boxes are set up to be mutually exclusive (same name: "EMP_Shift", different Export Values: Day, Evening, Night).

 

Form Field properties name:      EMP_Shift (for all 3 check boxes)

Acrobat edit panel field names:  EMP_Shift#0, EMPShift#1, EMPShift#2

Export Values:                         Day, Evening, Night (chose these only because they are descriptive)

 

I need to Auto-populate a Text Field named EMP_WorkShift with "Day" if EMP_Shift#0 is selected, "Evening" if EMPShift#1 is selected, or "Night" if EMPShift#2 is selected.

 

Is there a script I can use to accomplish this in Acrobat Pro X.

Export bookmarks from a PDF- Create Bookmarks report not working-Please help

$
0
0

Downloaded and installed the add in " Create Bookmark Report".

From the following site: https://acrobatusers.com/actions-exchange?trackingid=JZXYQ

Local machine being used runs most current updated Windows 10 pro and using Adobe Acrobat XI Pro

But I don't get a report.

Something I maybe missing.

 

1st screen shot of add in being used:

(there are number of bookmarks in the Bookmarks 2, 3, & 4)

Create Bookmark Report.png

2nd screen shot of report but no bookmarks- also wanted a csv report but none available:

Create Bookmark Report.2png.png

Setting one field equal to another

$
0
0

I have a document that has 15 pages. The last page is a summary page containing important fields that were populated on the 1st 14 pages. Example: I want the marital status on the last page to be equal to marital status on first page and bank account# on the last page equal to bank account# on page 2. Whenever they make changes on any of the fields on pp 1-14 that are also on page 15, I want the changes to be reflected on the page 15 fields but not vice versa, therefore I think I need to make the corresponding fields have different names and make them read only on the last page. How can I do this with Javascript.

 

I know nothing about java script but am not new to programming.

Link a text box to a dropdown list selected value

$
0
0

I have a drop drown list with 5 names in an Adobe Acrobat PDF. Based on the person's name you select in the drop down list I would like the text box to auto populate with that person's phone number. For instance:

 

Drop Down List Field Name ('Name')

Jake

Bob

Maria

 

Phone Numbers Field Name ('Number') in order for simplicity Jake's number is 100 and so on.

100 //Jake//

200 //Bob//

300 //Maria//

 

My code is not working and I am close to figuring it out, do you know what the problem is?

 

var x=100;

var y=200;

var z=300;

 

if(this.getField('Name').value='Jake')

    this.getField('Number').value=x;


Remove bleed and crop marks

$
0
0

Hello,

 

I have 300 pdf files approximately. I need to delete crop and bleed marks present in the document. I am doing now with pitstop. Is it any way to this via javascript? I am novice in Acrobat scripting.

 

Thanks,

K

If/then checkbox script help in Adobe Acrobat Form...

$
0
0

If have an order form that has two different pricing fields (regular price per item & subscription price per item) for each line item and then a quantity and then a total field. Lastly, there is a checkbox on the form that indicate if they are signing up for a monthly subscription.

 

What I am trying to do is create a script that totals each line by the regular price multipled by the quantity or subscription price by quantity if the subscription check box is checked ("Yes"). So far, I've tried several scripts I found in the forum but no luck at all.

 

The check box is near the billing fields toward the bottom so all the line items appear first in the top section of the form. So, an individual would fill out each line and the calculations would just total each row (reg price * qty) as you go down the form...then when you check the subscription box all the line totals would change to reflect the subscription pricing for each row (which can be different). Just need help with one row and I can duplicate for each row.....

 

Here is what I have that does NOT work yet.....:

 

 

 (function () {


if (this.getField("sub").value==="Yes") {
     var b1 = this.getField("Price1b");     var c1 = this.getField("Qty1");     var d1 = this.getField("Price1");     event.value = b1.value * c1.value;
} else event.value = d1.value * c1.value;    }


)();

Changing color of button/checkbox on click.

$
0
0

I've been delegated the task of putting together a PDF for a Sports and Fitness expo. I don't really have a great deal of experience with Acrobat or

Javascript. I am open to suggestions as to the best way of doing this. So... we have a segment of the floor plan (see attached). Each of the squares represents a booth space. What I need to do is create buttons/checkboxes over each booth space so that once a sponsor has confirmed which space they want we can email them back with an official looking document with that booth space highlighted. It needs to be a semi-transparent yellow color so that you can read the numbers underneath. Each box needs to be able to be checked and unchecked upon click. Thanks in advance for any help.

Floorplan.png

Javascript to Embed file attachment

$
0
0

I found a Javascript on the forum that allows me to have a form user attach a file in Adobe Reader to a PDF form.  The script is below and works great...as long as I am viewing the saved document on a computer.  I have discovered that Adobe Reader Mobile doesn't recognize file attachments added as annotations (only embedded files).  Can someone help me modify this script so that the file is actually embedded and not added as an annotation?  My follow-up question is the javascript to detach the file with a button.  I am using Adobe Acrobat DC to program the form.  Thank you so much for your help!!!

 

The way this is programmed is that on the button itself with a Mouse Up action, the following Javascript is run:

 

 

if (app.viewerVersion < 11) {

    import_pre_11();

} else {

    import_11();

}

 

Then there is a document level javascript for attaching the file that is programmed like this:

 

// Initialize attachment number

attachment_num = 1;

 

// Initial location of file attachment icon

// The x value is incremented below

var oFAP = {x_init: -72, x: -72, y: -72};  // Below lower-left corner of the page

 

function import_pre_11() {

 

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

 

        app.alert({

            cMsg: "You must user Reader version 11 or later to attach files to this form.",

            cTitle: "Attach File Error",

            nIcon: 3,

            nType: 0

        });

   

        return;

    }

 

    // Prompt user to import a file

    app.alert({

        cMsg: "Click the OK button to select a file from your system.",

        cTitle: "Attach File",

        nIcon: 3,

        nType: 0

    });

   

    try {

   

        var rc = this.importDataObject("Attachment" + attachment_num);

        if (rc) {

            attachment_num += 1;

            app.alert({

                cMsg: "Attachment successful.\r\rOpen the Attachments panel to access the attached file(s).",

                cTitle: "Attachment Successful",

                nIcon: 3,

                nType: 0

            });

           

        } else {

            app.alert({

                cMsg: "Attachment cancelled.",

                cTitle: "Attachment Cancelled",

                nIcon: 3,

                nType: 0

            });

        }

       

       

    } catch (e) {

        app.alert({

            cMsg: "Could not attach file.",

            cTitle: "Could not attach file",

            nIcon: 3,

            nType: 0

        });

    }

 

}

 

function import_11() {

 

    try {

 

        var annot = addAnnot({

            page: event.target.page,

            type: "FileAttachment",

            author: "Form user",

            name: "File Attachment",

            point: [oFAP.x, oFAP.y],

            contents: "File attachment on: " + util.printd("yyyy/mm/dd HH:MM:ss", new Date()),

            attachIcon: "Paperclip"

        });

 

        annot.cAttachmentPath; // Prompt user to select a file to attach

       

        oFAP.x += 18;  // Increment the x location for the icon

       

       

    } catch (e) {

 

        app.alert({

            cMsg: "Could not attach file.\r\rPlease report this error.",

            cTitle: "File attachment error",

            nIcon: 3,

            nType: 0

        });

 

    }

   

}

Help with Save As using JavaScript

$
0
0

Hi All,

 

This is my first attempt at using Javascript...

 

I am attempting to create a Save As button on a form that will:

  • Create a file name based on fields;
  • Save to a specific folder (And if it doesn't exist then create folder);
  • Bring up the "Save As" box for confirmation (as opposed to a silent save);
  • Bring up a warning IF Adobe is going to save over an existing pdf (aka has the exact same name);
  • Close Adobe after all of the above is executed.

 

So far I have been fairly successful. I have been able to do a silent save, saving to a specific location and saving the file name based on fields. I need help building the rest of the functionality into the code if possible.

 

Thanks in advanced!

------------------------------------------------------------------------------------------ -------------------------------

The code I have so far is:

 

Trusted Level Function

saved in Notepad under the Adobe / Javascript folder

 

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

});

 

PDF Button

Code under button that is executed on Mouse up click

 

// build file name

var myFileName = getField("Work_Pack").value + " - " + getField("Form_Name").value + " - " + getField("Todays_Date").value + ".pdf";

// add folder name

myFileName = "/c/temp/Saved Forms/" + myFileName

myTrustedSpecialTaskFunc(this, myFileName);

 

this.closeDoc() ;

 

------------------------------------------------------------------------------------------ -------------------------------

How do I use Acrobat JavaScript to perform digital signature (e-sign) in multiple PDFs documents?

$
0
0

With this script, I can perform batch signature:

 

// Choose handler

var manipulador = security.getHandler("Adobe.PPKLite");   

 

// login -- change as appropriate

manipulador.login("test123", "/D/Users/p004826/AppData/Roaming/Adobe/Acrobat/10.0/Security/Israel.pfx");

 

// informations

var myInfo = {password: "test123",

                    reason: "Salvar como teste",

                    mdp: "defaultAndComments"};

 

//Invisible Sign

this.certifyInvisibleSign({

oSig:manipulador,

oInfo:myInfo,

cDIPath:"/c/temp/sigSign.pdf",

cLegalAttest: "Certificado ussando o JavaScript",

bUI:false

});

 

But, it accomplishes only with a .PFX file saved locally. I'm trying to find a way that makes the user to insert a card and enter a password to make the e-signature. Does anyone know any other way?

Sorry for my bad english

 

Thank you!!!

How do you view javascript that is embedded in a pdf?

$
0
0

I am using Adobe Acrobat Professional 8.

 

I have gone into edit->preferences->javascript and checked "enable javascript debugger" and restarted.

 

Upon opening a pdf with embedded javascript, I see no menu options or anything pertaining to javascript in acrobat.

 

What do I need to do to view the javascript that is embedded in a pdf file?


Communicating between Acrobat and VBA

$
0
0

Hello,

 

Can someone please redirect me to an example or documentation to call a VBA Script within Javascript. I would like to set up such that when you press a button on the Acrobat pdf file it runs the VBA code.

 

I would like to send a string of data from a text field in Acrobat into my VBA code and then return the result (text string) of my vba code back into acrobat pro.

 

Please advise!

extraction of TOC details/Splitting PDF as per TOC

$
0
0

I have some PDF files and would like to split them into different pdfs as per the TOC given in the file. Using JavaScript, would like to create an action which can read TOC from the pages it is available upto and then split the files as per the TOC.

I am new to JS on acrobat. Any help would be appreciated!!

Thanks,

NotAllowedError: Security settings prevent access to this property or method.

$
0
0

hey guys,

     I'm getting this error when I click in the check box in adobe. do I have a settings issue or a syntax issue or what? can anyone help?

 

NotAllowedError: Security settings prevent access to this property or method.

  1. Doc.insertPages:4:Field Check Box6:Mouse Up

 

Here is the code

  1. this.insertPages({

nPage : -1,

cPath : "/G/SYNC/TEMP PM/M2T3/P10779-C.pdf",

nStart: 0

});

editing a pdf file using javascript: how to do?

$
0
0

just realized that it is possible to edit PDF files using javascript.

 

I have some, very small, experience in the past writing controls in javascript but honestly I don't know how to edit a pdf file using this language.

 

I especially don't know where to begin...

 

May someone help me?

 

examples and steps to begin are really appreciated :-)

 

thanks!

How to Auto-populate TextField in Acrobat x with a value determined by user check box selection?

$
0
0

I have a group of 3 Check Boxes for user to select their Work Shift:  The check boxes are set up to be mutually exclusive (same name: "EMP_Shift", different Export Values: Day, Evening, Night).

 

Form Field properties name:      EMP_Shift (for all 3 check boxes)

Acrobat edit panel field names:  EMP_Shift#0, EMPShift#1, EMPShift#2

Export Values:                         Day, Evening, Night (chose these only because they are descriptive)

 

I need to Auto-populate a Text Field named EMP_WorkShift with "Day" if EMP_Shift#0 is selected, "Evening" if EMPShift#1 is selected, or "Night" if EMPShift#2 is selected.

 

Is there a script I can use to accomplish this in Acrobat Pro X.

Viewing all 12130 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>