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

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!!!


Drop down A to populate Drop down B, C, and D

$
0
0

I have several drop downs. Drop down A, B, C, D and so on. All the drop downs have the same names in them but different values. For instance, drop down A has a list of names and export value is the person's address. Drop down B has the same list of names but export values are the person's SSN's. Drop down C has the same names but export values are $15 or $23 etc (their hourly pay rate). And so forth for the additional drop downs.

 

What I would like to do is when I select the person's name from Drop down A  then all the other drop downs will show that name but will return that drop down's value automatically into the text field connected to showing the results for that drop down. Text fieldA would show the value of Drop down A. Text fieldB would show the value for drop down B. Text fieldC would show the value for drop down C (and so on).

 

Is this possible? Could someone help me out with an example script that I can try out? That would help greatly. Thanks guys.

process aborted when reading data from a text file (util.readFileIntoStream, stringFromStream)

$
0
0

When I run this script in console (Acrobat DC) it always stops after 50 iterations with this error:

 

NotAllowedError: Security settings prevent access to this property or method.
App.openDoc:13:Console undefined:Exec

 

My guess is that it cannot find the next path in the test.txt file that has a list of paths. Why? Are there size limitations to this? If I delete the processed paths from the file, it continues fine, for the next 50 paths, and then stops again.

 

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

var n = cFile.split("\n");
//console.println(n.toSource());

//iterate through array of file paths and operate
for (var i in n) {
    var dc = app.openDoc(n[i].replace(/(\r\n|\n|\r)/gm,"").replace("\uFEFF", "").replace("\t", ""));    // Change the author names from "Smith, Jon" to "Jon Smith"    var names = dc.info.Authors;    for (var i in names) {        names[i] = names[i].replace(/,/g, "");        var nameParts = names[i].split(" ");        if (nameParts.length>1) {            var tmp = nameParts[1];            nameParts[1] = nameParts[0];            nameParts[0] = tmp;            names[i] = nameParts.join(" ");        }    var namesAsString = names.join(", ");    dc.info.Authors = [];    dc.info.Author = namesAsString;    }    console.println(namesAsString)    app.execMenuItem("Save");    dc.closeDoc();
}

How do I convert Excel formula to Javascript?

$
0
0

I tried using Online Excel Formula Beautifier to convert an Excel formula to javascript for use in Adobe Acrobat Pro XI >Forms>Text Field Properties>Custom Calculation Script but it didn't work.  (I first changed the Excel cell numbers to the correct names of the (Acrobat) form fields in the following calculation)

 

Excel formula using field names: 

=IF(Goals=1,GA1,IF(Goals=2,(SUM(GA1,GB1)/2),IF(Goals=3,(SUM(GA1,GB1,GC1)/3),IF(Goals=4,(SU M(GA1,GB1,GC1,GD1)/4)))))

 

Converted Javascript calculation using above website: 

(Goals===1,GA1,IF(Goals==2,((GA1,GB1)/2),IF(Goals==3,((GA1,GB1,GC1)/3),IF(Goals==4,((GA1,G B1,GC1,GD1)/4)))))

 

There is no error message, but no results in the field. I would love it if someone could help me with this script.  Thanks!!!


Windows 8.1, Acrobat Pro XI

Image reveal

$
0
0

I'm wanting to create a form that would have a dropdown menu field with selections of different product descriptions that, when selected, would 'trigger' another field to reveal one of a few different product images. Is this possible and, if so, how would I do it?

How to put field data into an array and pass it to a .php page on a webserver

$
0
0

I have to pass pdf field data to a .php script I have on a webserver. I am assuming I will have to use ajax and json.

Find, Highlight and Delete Null Pages?

$
0
0

While trying to come up with a way to quickly reduce the size of large PDFs that are viewed on line, I thought I would highlight a key word on the pages I need and then delete pages without annotations. I decided to replace step 2 in the Find and Highlight Words action with my own script. The script I came up with, (my first ever) works fine on the 35 page document that I used to develop it:

var pageArray=[]

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

{

     Aannots = this.getAnnots(i);

     if (Aannots == null)

  {            

   pageArray.push(i);

   };

    pageArray.sort();

    pageArray.reverse();              

}

for (var j = 0; j < pageArray.length; j++)

{

this.deletePages(pageArray[j],pageArray[j])

}

 

but when run on a very large, 2000+ page doc, it deletes some pages, then hangs or finishes with:

"TypeError: Invalid argument type.

Doc.deletePages:62:Batch undefined:Exec

===> Parameter nStart.""

in the console.

If I keep rerunning this code in the console, it eventually deletes all the unannotated pages.

Since the arguments come from the array, I print it out and am surprised that it is not in the reversed numerical order I expected.

Could that be the problem?  or one of them?

Thanks for any help you can give . . . at 65, I don't know if I'll live long enough to figure this out myself!

Javascript equivalent of 'Go to page view'?

$
0
0

I have a PDF with several attached PDFs which I need to open. Several of them are opened with a button, which works fine using 'Go to page view' as their action. This works with Acrobat Pro or Reader in all tests I have tried. But, a few of the files have to open with a dropdown selection, which I have coded using the following in the 'validate' event of the dropdown menu:

 

    var oDoc = openDataObject(fileName);

     if (oDoc != null) {

       var filePath = oDoc.path;

        oDoc.closeDoc();

        try {

            app.openDoc({cPath: filePath, bHidden: false});

        } catch (e) {

            app.alert('Error in app.openDoc: ' + e.message);

        }

    }

 

This works, but not in all cases. Is there a way to call the same 'Go to page view' command via javascript from the dropdown menu?


Split PDF Files by Bookmarks

$
0
0
Can anyone please let me know how do I split PDF Files by bookmark using Java Script.

I am making a Visual Basic utility to read the bookmarks in PDF Files and split them based on the bookmarks. I am able to split the PDF Files by using Arts PDF Split Pro. However since I am already using Adobe Standard, I would like to do it with Adobe itself.

Thus, I pay license for only one software and not two.

Thanks
Rahul

Extract pages from file and rename

$
0
0

I have a combined file that I need to break apart into separate files. But I'm having trouble making this work for 2 pages. Let me provide some background. I have a pdf with lets say 10 pages that I need to break into 5 files(F1, F2, F3, F4, F5).  The script below would return 5 files appropriately named but the contents shifted or in some cases duplicated. For Example: F1 would have Pages 1 and 2; F2 would have pages 3 and 4, F3 would have 4 and 5; F4 would have 6  and 7; F5 would have pages 8 and 9.  I'm generalizing here but the gist is that the pages somehow get skewed in the end. Thoughts anyone?


/* for extracting 2 page pdfs from main file, insert file names in first line between brackets*/


var filename = ["F1","F2","F3","F4",F5",];


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

     this.extractPages({

     nStart: i, nEnd: i + 1,

     cPath : filename[i] + ".pdf"

});


Calculation with a field and a dropdown

$
0
0

Hi,

I want to create a Field that give me the amount of product needed according to the length of the site and of the box (selectable in a list)

 

I've try that :

 

 

var a = Number(this.getField("SiteSize").value);

var b = Number(this.getField("DropdownBoxSize").value);

if (b==0) event.value = "";

else event.value = Math.floor(a/b);

 

 

but it's not working.


Any idea ?

Calculating Age from DOB field in Acrobat

$
0
0

Hello everyone,

 

I am placing this JavaScript code below in the calculate tab in the custom calculation script window for an Adobe acrobat form I am creating.  The user will enter in the DOB field "mm/dd/year" and the age output should be in the "age" field.  For the moment the code works up to the the day 12th day after that the age does not show up in the age field and if I put a date of 1/16/1973 my age should be 39, but my age comes out as 38.  Can anyone tell me what I am missing in the code?  All so its not accounting for the leap year.   Any help will be appreciated.  Thanks!

 

event.value = "";

dobValue = getField("dob").value;

if (dobValue!="") {

dob = util.scand("dd/mm/yyyy", dobValue);

today = new Date();

age = today.getFullYear() - dob.getFullYear();

if (today.getMonth() < dob.getMonth())

age;

else if (today.getMonth()== dob.getMonth())

age;

else if (today.getDate() < dob.getDate())

age;

else if (today.getDate() == dob.getDate())

age;

event.value = age;

}

Default date field a specific day of week?

$
0
0

Hi:

 

I am almost done with a new hire packet, and our company's traditional first day are on Mondays and thus would like to auto-populate the "Start Date" field as the next Monday after... But of course I want it to be able to be changed to a different starting date (e.g. holidays, getting a head start on new hires for 2 weeks out, etc.).

 

Example: If today was Tuesday, May 24, 2016, I want the default date to auto-populate 5/30/2016 (the next Monday)... But since our company actually closed in honor of Memorial Day (may our fallen heroes rest in peace), I want to be able to manually change it to 5/31/2016 (and yes, I'm doing this on my day off).

 

Can someone do me a huge favor and post the code for me since I'm no expert on coding (the most relevant answer was just to look for "getDay()" and I have no clue where to go from there)? Thanks a lot!

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!!!

Field to display today's date (mm/dd/yyyy) +15 days.

$
0
0

Good morning,

I thought i nailed this one but it's doing something strange. My script is wrong but i'm learning as I go...

 

I added a script that auto-populates today's date and adds + 15 days to the date. When I Preview the field, it works find. However when I tab over to another field and add a value (doesn't matter what the other fields are), the initial date field keeps adding more days. Example, if the next two fields were simple check boxes (not tied to the date field in any way) and I were to check the boxes back and forth, the date field keeps jumping to a higher date.

 

var myDate = util.scand("mm/dd/yyyy", this.getField("GLOBAL__POSTING_DATE_15").valueAsString) ;

myDate.setDate(myDate.getDate() + 15);

event.value = util.printd("mm/dd/yyyy", myDate)

 

Is there a way to keep the date displayed and not get updated unless the user manually changes the date and only then does it add 15 days to that new date?

 

Thanks,

Edgar Arreguin


Easy way to count pages from multiple pdf files?

$
0
0

Where I work, we typically produce several thousand PDF and TIFF files a day.  Each individual file can have anywhere from one to over three hundred pages.  Is there an easy way to count the total number of pages from ALL the files using acrobat or another Adobe product? 

Dynamic Page Numbering script isn't working on spawned pages?

$
0
0

I'm working in Acrobat Pro XI on a 4 page document with a button that allows a template pages to be inserted after page 3.  I created a button for this and it is working fine.  But each page has a text field that is supposed to auto update all of the page numbers.  The code looks like this:

 

event.value="Page "+(event.target.page+1)+" of "+this.numPages;

calculateNow();

 

On the four pages visible when the file is opened it is working perfectly; they will update from "Page 1 of 4" to "1 of 5", etc. without any problems.  However, the inserted template pages are very random.  Sometimes the first spawned one will work and say Page 4 of 5 but sometimes it will say Page 0 of 4.  It's worth mentioning that even when it says Page 4 of 5 printing that page shows it saying Page 0 of 4 again.  And any additional pages spawned after that will list a bunch of random numbers out of the correct number of pages.  So it will look like "Page 7, 6, 5, 4, 31 of 9".

 

I've been looking through a lot of previously asked questions and haven't seen any quite like this. 

Acrobat Pro X document open event

$
0
0

Hei,

 

Where I can find document open event. I would like to save my pdf-form when I open it? If there is no  action wizard for this purpose, can somebody tell me how I can script this.

 

Thanks to your help!

How to open pdf in editable mode in the browser

$
0
0

I have downloaded 4 blank pdf templates. I need to open these templates  with the help of drop down select box. For eg. If user selects option 1 then one pdf will be opened and if user selects option 2 then another pdf will be opened in the browser. But the problem is that these pdf must be opened in editable mode so that user can fill some data and then save it. I am facing the problem to open these pdfs in editable mode. I am using jsp and java script. I am not able to implement the code of opening the pdf in editable mode. Please help.

RaiseError: File does not begin with '%PDF

$
0
0

I have an application which has below script:

var oDoc = event.target.openDataObject("testing123");

 

This script works fine if I run it on my local machine.

 

But I am planning to place the pdf (application) on the server. After placing the pdf on the server, I tried to open the pdf through local browser, I got an error 'File does not begin with '%PDF'.

 

I added one line:

 

var thePath = oDoc.path;

 

After running, I got local machine path where pdf is placed. On Server, no path is coming in the debugger.

 

Server doesn't have Acrobat install on it. Each user has acrobat to open the pdf

 

Please advise.

Viewing all 12130 articles
Browse latest View live


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