Division Script in Acrobat 5

Just trying to get a simple division script to work
var a = this.getField {"Loan Amt"};
var b = this.getField {"Comp5"};
event.value = a.value / b.value
keep getting this message
SyntaxError:missing; before statement at Line 1
help is appreciated
Thanks

You're using curly braces where you should be using parentheses. Also, you should make sure the denominator value is not zero before you do the division:
(function () {
    // Get field values as numbers
    var a = +getField("Loan Amt").value;
    var b = +getField("Comp5").value;
    // Perform the calculation
    event.value = b ? a / b : "";

Similar Messages

  • Help with Custom calculation script in Acrobat 8

    Hi all, I am using acrobat 8 on OS 10.5
    I am trying to add certain fields (numbers) and then subtract another field value to give an end result.
    I don't know anything about Javascript, would anyone be able to help with any info on how I achieve this result? I can only see Add, x and average etc... nothing there for subtraction
    Thanks for any help in advance
    Swen

    This should get you started:
    >if (event) {
    // get values from two text fields
    var a = Number(this.getField('Text1').value);
    var b = Number(this.getField('Text2').value);
    // subtract the values and show it
    this.event.target.value = a - b;
    Place this in a 3d text field, as a Custom Calculation Script.

  • Java Script Adobe Acrobat 5.0

    O Adobe Acrobat 5.0 suporta java Script?
    O que eu posso fazer com o java Script dentro do Acrobat?
    Daniel
    [email protected]

    Acrobat 5 has been obsolete for more than 10 years! It sounds as if this was an upgrade looking for an even older version.
    Let's forget that and look at the problem with Adobe Reader. What is the problem there?

  • CloseDoc is interrupting a batch run script in Acrobat X

    I am using a batch script to split a PDF file and then process (send via email) the individual pages.  Because extractPages opens the new page each time it's called, I had inserted a closeDoc referencing the new doc object so that I didn't end up with multiple open pages or crash Acrobat.  The script below worked fine when tested in Acrobat 8, but in Acrobat X I get a Dead Object error, so I've commented this out.  The script below is just a snippet from a larger script, but it does work in A8, all of those variables are defined and have values within the process.
    I checked the API and it says:
    In versions of Acrobat earlier than 7.0, a document that closes itself by executing this.closeDoc
    terminates any script that follows it. In Acrobat 7.0, the script is allowed to continue and to terminate
    naturally. However, if the Doc of the closed document is referenced, an exception will be thrown.
    I am not referencing the document object called 'send_document' after this call except in if statements that won't be run, is this still an issue, that the doc object is referenced at all?  Would it help to use a different variable name for the doc object in each section of my if/then statement?
    Right now I'm being forced to work around it because I can close all the open documents at the end, but Acrobat crashes if we open more than 50 docs, and we do have multipage PDFs with more than 50 pages we need to process.  Does this seem like an error I should report or an issue with how I'm implementing closeDoc?
         send_document = this.extractPages(cnt, cnt) ;
                send_document.mailDoc(
                    bUI: false,
                    cTo: send_to,
                    cSubject: subject_line,
                    cMsg: message_text
                send_document.closeDoc(true) ;
    Thanks ahead for any clues/help,
    JP

    Since you're not specifying the cPath parameter of extractPages it does not
    return a Doc object, but null, according to the reference file.
    Edit: My mistake, it's the other way around...
    I've run your code and it seems to work fine (although it didn't go completely smoothly as I still had to manually allow the appliction to email the files).
    Have you tried debugging it to see where the "Dead Object error" occurs?

  • 'flatten.txt' script for Acrobat 9 Flatten Document Menu Item

    Hello,
    I was following the steps in this blog (Add a Flatten Document Menu Item to Acrobat) to add a Flatten Document menu item in Acrobat 9, and the link the 'flatten.txt' script is dead.  The page directs you to this link:  https://acrobat.com/?d=KlVeiP4I1SXCRcTpRh-2wQ, which is just the Adobe Document Cloud webpage.  Does anybody have a copy of the 'flatten.txt' script?  I've used this before on my last computer, but since re-installing I have not been able to add this feature to Acrobat 9.  Any help is appreciated.  Thanks

    You need to contact Rick Borstein to update the link for the missing file. See his blog entry In case files are missing. Adobe has closed Acrobat.com and started a new service for Acrobat DC.
    There are any number of scripts to provide add this feature with some options.
    PDFScripting free automation tools
    Selective Flattener by UVSAR, you may need to research where the user scripts are stored in the newer versions of Acrobat.
    In the future, you should either copy your custom scripts to a remote location for restoration or keep a copy of the scripts and documentation on removable data or a networked location as a backup.

  • Template generating script crashes acrobat x application

    Hi,
    I am fairly new to acrobat scripting. I have been beating my head against the wall on this one and have come to ask the collective. The following script works if numberPages is set to 1 (one new page is generated based on the template). When I change numberPages to 2 or more, the application crashes. Any suggestions?
    This is on acrobat x, windows 7
    Thanks,
    Roland
    var mypath = "Template1.pdf";
    numberPages = 1;
    this.insertPages({cPath: mypath, nPage: -1});
    t = this.createTemplate({cName:"signoff", nPage:0 });
    t.hidden = true;
    // spawns number of pages
    for (i = 0; i < numberPages; i++){
      t.spawn(i, true, false);

    Looks like I finally figured it out. It was something quite silly. Apparently, hiding the template before spawning it is a bad idea (at least under certain circumstances...when there are comments in the source file and a form in the template file). This script seems to work just fine so far:
    var mypath = "Template1.pdf";
    numberPages = 6;
    this.insertPages({cPath: mypath, nPage: -1});
    t = this.createTemplate({cName:"signoff", nPage:0 });
    // spawns number of pages
    for (i = 0; i < numberPages; i++){
      t.spawn(i, true, false);
    t.hidden = true;

  • Java Script in Acrobat

    I am trying to make a popup Menu under a button in Acrobat X. For this I added a Javascript in the Button menu.
    I get the impression that there is a limit to the amount of lines Acrobat can manage because I get error messages that are not logical and when I delete a random line everything is ok.
    Is there anybody with experience in this matter?

    It gives diverse SyntaxErrors. Missing spaces or other things in diffenet lines. There is really no logic in that. And when I reduce the ammount of lines, no matter what line I delete, it functions.
    I can give you the script on a point where it doesnot function anymore. The thing I added last was the second submenu. And thank you for reacting!
    var cChoice = app.popUpMenuEx
            {cName: "Tg. Winterberg",oSubMenu:
            {cName: "De Jazzbarones",cReturn: "2"}
            {cName: "Maas",oSubMenu:
            {cName: "Cash.",cReturn: "3"}
            {cName: "DOX - I Have a Dream",cReturn: "4"},
            {cName: "BonteHond/Pompei - Dutch Vinex Wonder Boys",cReturn: "5"},
            {cName: "BEER Muziektheater",oSubMenu:
               [{cName: "Dali, of hoe word ik beroemd",cReturn: "6"},
               {cName: "Ik ben niet bang",cReturn: "7"}]
            {cName: "BonteHond/NTjong - Zebra Zebra",cReturn: "8"},
            {cName: "BonteHond - Harig Hondje",cReturn: "9"},
            {cName: "De Toneelmakerij - KoudVuur!",cReturn: "10"},
            {cName: "De Toneelmakerij/Firma Rieks Swarte - De Storm",cReturn: "11"},
            {cName: "Esther de Koning/STIP",oSubMenu:
            {cName: "H.O.T.-het begin",cReturn: "12"}
            {cName: "Het Houten Huis",oSubMenu:
            [{cName: "Hotel Perdu",cReturn: "13"},
            {cName: "Beet!",cReturn: "14"}]
            {cName: "Het Laagland",oSubMenu:
            [{cName: "WIM IS WEG",cReturn: "15"},
            {cName: "ROBIN HOOD",cReturn: "16"},
            {cName: "KOFFERS OP REIS",cReturn: "17"}]
            {cName: "Hetpaarddatvliegt",oSubMenu:
            [{cName: "Later als ik dood ben",cReturn: "18"},
            {cName: "Rooi kop",cReturn: "19"}]
            {cName: "Maas",oSubMenu:
            [{cName: "Alleen op de Wereld",cReturn: "20"},
            {cName: "Wild Thing",cReturn: "21"},
            {cName: "De Nieuwe Jetse",cReturn: "22"},
            {cName: "Helaas Pindakaas",cReturn: "23"}]
            {cName: "Raaijmakers & Geerlings/STIP - Niet Huppelen!",cReturn: "24"},
            {cName: "Theater Gnaffel",oSubMenu:
            [{cName: "Apenstreken",cReturn: "25"},
            {cName: "Peter Pan en de verloren jongens",cReturn: "26"}]
            {cName: "Theater Sonnevanck",oSubMenu:
            [{cName: "Tijl Uilenspiegel",cReturn: "27"},
            {cName: "Engel met vieze voeten",cReturn: "28"}]
            {cName: "Tg. Winterberg/STIP - Op een klein stationnetje",cReturn: "29"}

  • Is it possible to simulate a table for reference in  the "Custom Calculation Script" in Acrobat?

    I am attempting to simulate a table in a Acrobat form where the formula looks at the number or name from another field and looks through the code for the name or number reference and returns the value associated with the number or name. Is this possible in Acrobat forms?
    Bruce

    Yes, it's possible. You can get the name of the field that is being calculated using event.target.name, and then you can manipulate that name to get a row number (for example) and access other fields in that row.

  • Future Date Script in Acrobat, 6 months after current date

    Hey guys I have been working on this for hours and I am not sure why I cannot figure this out.  I am looking to have 1 field box in the form auto populate the current date and another field box to auto populate a date 6 months from the current date.  My current date code is attached, I have been playing around with so many variations that I do not want to confuse anyone with my other ugly code fragments.
    var bFirstTime=1;
    var f=this.getField("todaysDate");
    if (bFirstTime=1) {
    f.value=util.printd("mm/dd/yyyy",new Date());
    bFirstTime=0;
    //app.bFirstTime);

    Have you tried a document level funtction that runs when the PDF is opened. The following script fills in today's date if the field has not been field in and computes the date in 5 months using the parts of the date and the value of today's date.
    // one time use document level function
    ( function () {
    // update fields only if balnk
    if(this.getField('todaysDate').defaultValue == '') {
    // get current date time object
    var oNow = new Date();
    // get some date parts
    var fYear = oNow.getFullYear(); // 4 digit year
    var fMonth = oNow.getMonth(); // get zero based month
    var fDate = oNow.getDate(); // get date of month
    var sFormat = '%,302.0f/%,302.0f/%,304.0f';
    // fill in field
    this.getField('todaysDate').value = util.printf(sFormat, (fMonth + 1), fDate, fYear);
    // make permanent
    this.getField('todaysDate').defaultValue = this.getField('todaysDate').value;
    // compute date 6 months from today
    fMonth += 6;
    var oNew = new Date(fYear, fMonth, fDate);
    // get some date parts
    fYear = oNew.getFullYear(); // 4 digit year
    fMonth = oNew.getMonth(); // get zero based month
    fDate = oNew.getDate(); // get date of month
    // fill in field
    this.getField('newDate').value = util.printf(sFormat, (fMonth + 1), fDate, fYear);
    // make permanent
    this.getField('newDate').defaultValue = this.getField('newDate').value;
    // debugging aid
    app.alert('dates updated', 2, 0);
    } else {
    app.alert('dates not updated', 1, 0);
    } // end not empty
    return;
    } // end function
    () // call funtion
    ); // end document level function

  • Script for Acrobat Reader to save as read only after filled out.

    Hi
    I have created a work proposal form to be filled out with an estimate of work to be done and the cost.
    Is there a script that will then let me save the form as read only so recipient can not make any changes?
    Ron A

    Thanks GKaiseril
    I found this in the forums from a previous post by try67
    It works perferctly.
    However in his post he left off the last bracket }
    for (var i=0; i<this.numFields; i++) {
    var f = this.getField(this.getNthFieldName(i));
    if (f!=null && f.type!="button") f.readonly = true;
    Ron A

  • How to do Script in Acrobat reader pro * Monthly Payment*

    Hallo,
    I hope somone can help me with script.
    I need an editable PDF file that  have two text field. text field1 have price, text field2  shoud be calculate automaticly monthly payment,
    Example:
    if the price in  filed1:100-300 $---------------shoud be in field2  $10/monthly.
    if the price in  filed1:301-349 $------------shoud be in field2  $11/monthly.
    if the price in  filed1: 350-399 $------------shoud be in field2  $12/monthly.
    if the price in  filed1: 400-449  $------------shoud be in field2  $13/monthly.
    thanks

    For the "field2" custom calculation script, one could use:
    // get the value of "field1"
    var nPrice = this.getField("field1").vallue;
    // set monthly payment base on the range of value of field1
    switch(true) {
    case (nPrice >= 100 && nPrice < 301) :
    // price is greater than or equal to 100 and less than 301
    event.value = 10;
    break;
    case (nPrice >= 301 && nPrice < 350) :
    // price is greater than or equal to 301 and less than 350
    event.value = 11;
    break;
    case (nPrice >= 350 && nPrice < 400) :
    // price is greater than or equal to 350 and less than 400
    event.value = 12;
    break;
    case (nPrice >= 400 && nPrice < 450) :
    // price is greater than or equal to 100 and less than 301
    event.value = 13;
    break;
    default:
    // all other prices
    event.value = "";
    break;

  • How do I run scripts in Acrobat.

    This is simple I know but my only experience is with Indesign and there is an SDK and a pallette that the user selects from. I am not sure if acrobat shares any similarities. Any help or direction would be appreciated.

    Read this:
    http://acrobatusers.com/tutorials/where_js_goes

  • Creating a document script for Clock in Acrobat Professional.

    Hi,
    I am trying to add a field on my PDF form which shows a continuous clock.
    I do not know how to add code to a document script in Acrobat Professional.
    "Advaned/ Javascript/ Set Document Actions" is greyed out.
    Thanks in advance,
    Damo.

    It sounds like you have Acrobat 9 or earlier?  And is this a LiveCycle form?
    In therory, clock code is very simple. It just writes the formatted time to a text field. But the details depend on the type of form, LiveCycle or AcroForm
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    All About PDF Stamps in Acrobat and Paperless Workflows - THE BOOK!
    The Acrobat JavaScript Reference, Use it Early and Often
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)
    Having trouble, Why Doesn't my Script Work?

  • Scripting in Adobe acrobat

    Hi
    Is there anyway you can script Adobe acrobat to automatically scan a document, i am using it to scan all incomming snail mail, but it annoys me i have to do it inside the program. is there a API?
    Regards,
    Allan Bogild Pedersen
    www.allan-bogild.com

    Acrobat Scripting Forum http://forums.adobe.com/community/acrobat/acrobat_scripting
    Acrobat SDK Developer Forum http://forums.adobe.com/community/acrobat/acrobat_sdk

  • LC4: how start Acrobat action wizard script or trigger preflight correction?

    Hi!
    I need to work with layers (OCG) in a single site PDF.
    seperate the different element types into different layers (done by preflight correction script)
    hide the text layer
    export the pdf without the hidden text-layer as img
    import the new img as background layer.
    save pdf
    I was able to do all steps in 4 different action wizard scripts in Acrobat XI. How can I access them in a LiveCycle process?
    If this is not possible, how can I access preflight corrections into a LiveCycle process to achieve the same?
    Thanks a lot!
    Andreas

    Hi!
    I need to work with layers (OCG) in a single site PDF.
    seperate the different element types into different layers (done by preflight correction script)
    hide the text layer
    export the pdf without the hidden text-layer as img
    import the new img as background layer.
    save pdf
    I was able to do all steps in 4 different action wizard scripts in Acrobat XI. How can I access them in a LiveCycle process?
    If this is not possible, how can I access preflight corrections into a LiveCycle process to achieve the same?
    Thanks a lot!
    Andreas

Maybe you are looking for

  • Iphone 3gs software update version 6.1.6 not able to do it need help and also want to know if i do not update it will my phone stop working

    Hi I am getting a message of updating my iphone 3gs software version ios 6.1.6 but i am not getting an option to download it how can i update this version on my phone and if i will not update it will my phone stop working i am confused as i tried a l

  • Displaying streamed images in Web Dynpro

    Hi All, I have following scenario to programme. - The DB have "images" stored as BLOB. - I need to read the images (stream) and make them visible in Web Dynpro UI. Problem is i only one way to providing images in Web Dynpro. The images are picked fro

  • How do I create this kind of synth track?

    I'm trying to recreate the synth instrument used in this song in Garageband... from 0:05-0:13 http://www.youtube.com/watch?v=vW1hv37imjw I'm not sure how I should go about doing so...I don't want to be playing individual keys for each chord pressed.

  • Clarification on manual updating....

    I just want to make sure I'm clear on this before I do something and lose all my songs. I've loaded all of my cds onto my iPOD (close to 6000 songs). My wife thinks that having so many tunes in iTUNES is slowing down our computer. In the name of dome

  • Live stream won't play on Windows

    We're using QTSS and QTBroadcaster to stream a live event. Everything works fine on Mac clients, but Windows clients simply can't get the stream unless it's opened directly in QuickTime Player. We have a website with an embedded link for the stream,