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

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;    }


)();


Auto Printing PDF docs in FTP folder

$
0
0

Ok so here is the deal,

 

I have an FTP folder set up in a Windows 2003 server environment. I will be recieving PDF docs into an FTP file a few times a day and I would like to know if there is a way for me to make it so that the PDF documents print automatically once they get to my FTP folder.

 

Any ideas? I have seen some software around the internet that does something like that but I think there has to be another way.

Adobe Pro DC simple question.

$
0
0

Hi all,

 

I am new to Adobe Acrobat DC, and I am sure this is something simple, but I have very little JavaScript "know-how."  I am working on something for work and I am looking to use some sort of conditional formula.  Below is a brief description of what I am trying to do:

 

I have a form and I would like to sum up a range of text boxes across, but only if the first text box is not empty.  (i.e.  Text Box 1 has the date in it, so now I would like Text Boxes 2-10 to sum up in Text Box 11)

 

I mostly work with Excel, and as I said I am somewhat new to scripting so any help would be greatly appreciated.

 

Also, if anyone has any suggestions for resources I could use to learn more about JavaScript and its uses within Adobe Acrobat DC.

 

Thanks all,

Using Acrobat Action Wizard to auto-tab to next field

$
0
0

I’m trying to speed up the process of creating an interactive pdf form in Adobe Acrobat through Action Wizard using Javascript, as I use and change the forms many times a day. I’m struggling to make the auto tab work through Action Wizard – I have some fields that require only one number and I like it to automatically go to the next field once that number is entered. Example of some of the code I currently use in Action Wizard:

 

for (var i = 0; i < numFields; i++) {  var fName = getNthFieldName(i);  var f = getField(fName);  var fTool = getNthFieldName(i).userName;  if (fName == "C1”) {  f.charLimit = 1;  f.alignment = "center";    f.setAction("Keystroke", "AFNumber_Keystroke\(0, 0, 0, 0, \"\", false\);");  }  if (fName =="C2”) {  f.charLimit = 1;  f.alignment = "center";    f.setAction("Keystroke", "AFNumber_Keystroke\(0, 0, 0, 0, \"\", false\);");  }

}

 

So I would like C1 to have some code that automatically goes to C2. Is there any way this is possible with just Action Wizard? Currently I’ve been doing it manual using:

 

function tab_next(next_field_name) {    if (event.willCommit || AFMergeChange(event).length === event.target.charLimit) {        getField(next_field_name).setFocus();    }
}

 

And the Keystroke script:

 

tab_next(“C2”);

 

If anyone knows a way to do this, that would be much appreciated. Thanks!

Open and close PDF files from a CVS list

$
0
0

I would like to perform some actions on a list of files. I have them in a CSV file. I can read it in OK in the Console but cannot open them. The paths are correct, I can open one. But in the loop it does not work. Why?

 

var oFile = util.readFileIntoStream("/C/test.txt");
var cFile = util.stringFromStream(oFile, "utf-8");


var n = cFile.split(",");


//second part
for (var i in n) {
  var otherDoc = app.openDoc(n[i]);  otherDoc.closeDoc();
}

 

undefinedInvalid Location "/D/test.pdf". File or folder does not exist.

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

App.openDoc:2:Console undefined:Exec

 

undefined

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 automatically set Print Scaling to 'None'

$
0
0

Is there any way to automatically set print scaling to 'none' on an existing PDF document?

 

This setting is set manually by going to File > Properties, and then going to the 'Advanced' tab and changing the 'Page Scaling' preference from 'Default' to 'None'. This preference can then be saved with the document.

 

There seems to be no way to do this via javascript but if anyone has found a way to automate this that would be great!!!

 

Ideally I want to run this as a batch process across a number of PDFs. Maybe as a last resort there is a way to do this using "execMenuItem"????

 

Many thanks in advance for your help!!!!

 

HJ

Need Script to Continue After Clicking OK on Alert Box

$
0
0

My form has multiple required fields. In order to ensure the form has been filled out completely, the submit button on the form has a javascript action on it to check the contents of the required fields, and if necessary, return the user to that part of the form to enter the required information.

 

Just before the form is mailed, I am checking for a value of "Vendor_Guidelines" in field 18. If that field's value is "Vendor_Guidelines", I would like to pop up an alert reminding the user to include the guidelines when submitting their request. They should be able to click "OK" on the alert, and continue with submitting their form.

 

Below is the expert of the script on the submit button. Once the alert displays, I really don't really need to set focus back to f18, I just need the user to be able to click OK and allow the script to continue so the form can be submitted.

 

Thanks in advance for any ideas on this.

 

 

 

 

              else if (f18.value == "Vendor_Guidelines")

  {

  app.alert ('You checked the Vendor/Buyer Guidelines checkbox on page one of this form. Attach the guidelines to this request email.');

  f18.setFocus();

  }

  else

  {

        // Email PDF.

        var m = this.getField("ad_desc");

        var mysubject = m.value + " - Request Form Submission";

        this.mailDoc(true, "requestforms@ducjvh.com", "", "", mysubject);

  }

}


Script for calculating start time and end time

$
0
0

I am using Adobe Acrobat Pro and needing a script to calculate start time and end time for a timesheet (start time and end time are hh:MM) 24 hours please see below can anyone help me ......

 

Untitled.jpg

how keep excel formulas

$
0
0

Hi,

I have a bookkeeping excel spreadsheet and I want to convert the excel spreadsheet to an editable

PDF document that will keep the entire workbook and formulas intact.

 

In other words, I an excel spreadsheet I created with all the formulas in each cell.

The 1st sheet is the Sales Page where I enter my sales and then I log in my expenses for each

month (Jan - December) at the end of the year I have the formulas set up to transfer my income and expenses  to the

last page (YTD) which will tell me profit and Loss for the year.

 

I understand I need to use Java to create a PDF in order to keep the formulas intact. How do I do this?

Do you have a video showing how to do this?

 

Thanks

How to create sequential number field?

$
0
0

I have created a pdf file and I'd like to have a field with sequential numbers.

For instance, if I open my pdf now and it has number 1 in the field, 'd like to have number 2 in the field the next time that I open the file, and so on...

autofill date fields with today's date - Acrobat DC ?

$
0
0

I had auto fill a form field with today's date working well in Acrobat 10, but having trouble getting it working in Acrobat DC.

 

I have a form with 3 date fields named Date_1, Date_2, and Date_3.  I would like to set all 3 to Todays Date if the form is opened and these fields are empty.

 

Here is the code I created:

 

//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------

//<Document-Level>
//<ACRO_source>Enter Todays Date If Blank</ACRO_source>
//<ACRO_script>
/*********** belongs to: Document-Level:Enter Todays Date If Blank ***********/
function EnterTodaysDateIfBlank()
{
var f = this.getField("DATE_1");
if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());
var f = this.getField("DATE_2");
if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());
var f = this.getField("DATE_3");
if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());
}

//</ACRO_script>
//</Document-Level>

_________________________________________________________________________

 

I see no JavaScript error message for the above.  I am not sure how to "trigger" execution of this function upon form opening.

 

There is ample documentation for this on earlier versions of Acrobat on the web, but very little posted on Acrobat DC.

dynamic stamp with an incremental number

$
0
0

How to create a dynamic stamp with an incremental number every time I stamp in the PDF. This will be used by only one person and installed on a single computer. Thanks for your help in advance.

Why does the Javascript that controls certain text fields not re-render immediately?

$
0
0

I am creating a form in Acrobat XI Pro.

 

I made several text fields asking for Room Number. Other text fields create sentences based on those Room Number inputs. For instance, if a user enters a room number into the text box "Room1", the code for "TextBox1" is the following:

 

var roomnumber = getField("Room1").value;

if (roomnumber != "") getField("TextBox1").value= "Enter square footage of Room "+roomnumber+" here:";

else getField("TextBox1").value="";

 

I'm finding that TextBox1 does not continuously re-render as the text in "Room1" changes. If I change the entry in Room1, TextBox1 stays unchanged for a while. After I click on another box in my form and then out again, the Javascript for TextBox1 "catches up" and shows the correct text.

 

I know my code is correct, because EVENTUALLY the text boxes behave correctly. Shouldn't all text fields be constantly re-calculated any time someone interacts with the form?

I would like to automatically flatten document when dynamic stamp is applied.

$
0
0

Good afternoon,

 

I am looking to automatically flatten my document when I place a dynamic stamp. I am pretty new to Java and have cobbled together code to make my stamp, learning on the way.

 

I have tried adding this.flattenPages() to the script, but when I do Acrobat crashes when I place the stamp.

 

I cannot install the menu bar script to add a flatten document button, because I don't have admin permissions.

 

Thank you in advance for any help.

Patrick


Javascript won't work - JavaScript for Reader Mobile API Reference (Android)

$
0
0

I have created a Form with the new Adobe Acrobat Pro DC (trial version).

The Javascript code just won't work on a mobile phone.

Doc - JavaScript for Reader Mobile API Reference (Android this shows that what I want to do is supported.

But not even the simplest command will work on my phone. (I am using Adobe Acrobat DC - PDF reader for Android)

 

Any suggestions of what I could be doing wrong?

 

Best,

Menno

Search PDF doc based on value selected from a Dropdown Box

$
0
0

Can someone pleae help me figure out a way to search a pdf for a the value selected from a dropdown box. The document is being used at workstations that do NOT have keyboards, only a mouse. I have made many attempts on my onw with no success. Any assitance would be greatly appreciated!

Immediate change to Text Field's character limit?

$
0
0

I have a PDF form that I am trying to make more foolproof. As a user enters their credit card number, I want it to check the first two digits to see which kind of card it is (Visa/MasterCard/American Express) and select the appropriate radio button for them, as well as limit the number of digits that can be entered in that credit card number field. I have it mostly figured out, but it seems that changing the character limit (charLimit) of the Card Number field doesn't actually take place until the focus leaves the field, then re-enters it. Here's the code I have so far, in the Custom Keystroke Script property on the Format tab of that field:

 

event.rc = /^\d*$/.test(event.change);


var thisField = event.target;
var amexTest = /^3[47]/;
var mcTest = /^5[1-5]/;
var visaTest = /^4/;
var firstTwo = event.value.slice(0,2);
var ccButtons = getField("Credit Card Buttons");
if (amexTest.test(firstTwo)) {
    thisField.charLimit = 15;    ccButtons.value = "AMEX";
} else if (mcTest.test(firstTwo)) {    thisField.charLimit = 16;    ccButtons.value = "Master Card";
} else if (visaTest.test(firstTwo)) {    thisField.charLimit = 19;    ccButtons.value = "Visa";
}

 

It looks like my pasted code got a little cut off toward the end for some reason, but I think that's enough to show what I want to have happen. Because this script runs at every keystroke, then after the first two characters are typed, I want it to limit the number of characters to what is appropriate for that type of card. This should help a bit in having people mis-type their number. However, as I said, the change doesn't actually take place until the focus leaves and re-enters that field.

 

What can I do to make the change immediate?

Hide/Show layers with Javascript

$
0
0

Hello,

 

I am trying to find a Javascript method for hiding/showing layers in a pdf document. I would like to be able to use an if/else statement to set the visibility of multiple layers.

 

Let's say I have 5 layers on a single page, all set to hidden by default. This page also has a field with 5 options relating to each of the 5 layers. Once an option is selected, an if/else will use this method to set the appropriate layer to visible.

 

Thank you!

Acrobat Pro DC: Need Help Linking Text Fields to Enable Text Overflow

$
0
0

I'm using Acrobat Pro DC and I'm trying to link two form fields in such a way that the text from box1 will overflow into box2. Anyone know how to do this? I'm a novice so I'll need some step by step help. I've done some research but have only found solutions for previous Acrobat versions so the instructions are essentially useless. Please and thank you!

Viewing all 12130 articles
Browse latest View live