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

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"

});



How to count checked checkmark boxes

$
0
0

Hi,

 

I am looking for a script that will help me count all the 'Yes' check marks that have been checked. There are questions and each have 3 boxes: Yes, No, Somewhat. I only need the formula box at the bottom to count the number of check mark boxes that have 'Yes' checked.

Check boxes are named from 'check 1' to 'check 7' with each box having a different export value (Yes, No, Somewhat).

 

I am using Adobe Acrobat X on a Mac.

 

If anyone can help, that would be great. Thank you!

Can i show/hide textbox based on radiobutton click inside a dialogbox? example please...

$
0
0

Hi:

 

I am trying to find examples of showing/hiding text boxes based on radiobutton click inside a dialog using acrobat pro. I am not finding any examples. Can someone please guide me?

 

Thanks in advance.

How to Extract Text coordinates from PDF

$
0
0
Hi,

can anyone tell me how to get coordinates in pdf document using VB or .NET, suppose if some text is written in pdf document then how can i get coordinates of that text. Its very Urgent.

Thanks in Advance.

Clear form after submitting, Adobe X Standard

$
0
0

I am trying to set up a form in Acrobat X standard that will clear the fields after it has been submitted. The form is on a local network and is being distributed using the Forms tool. Employees need to fill in the form then click the submit button on the top right side of Adobe reader, not a button field in the form. I am trying to keep employees from having one person answer the questions  then letting others change the name and resubmit. Is there a script that can do this? I am new to Javascript so I have no idea how to do this or if it can be done.

exportAsFDF method fails to export Comments made unless a document is Reader Extended

$
0
0

Problem-Description:

Adobe Reader 11 JavaScript exportAsFDF method fails to export Comments made unless a document is Reader Extended

 

Method:

1. Open a document that has NOT been Reader Extended

2. Add comments to the PDF file

3. Use the following JavaScript to export comments

 

// Import permission

statImport = PDDocPermRequest(pdDoc,PDPermReqObjAnnot,PDPermReqOprImport,NULL);

sprintf(szMsg,"canLoadMarkup() AnnotPerm(import)= %d.\n",statImport);

traceMsg(szMsg);

// Export permission

statExport = PDDocPermRequest(pdDoc,PDPermReqObjAnnot,PDPermReqOprExport,NULL);

sprintf(szMsg,"canLoadMarkup() AnnotPerm(export)= %d.\n",statExport);

if (statImport == 0 && statExport == 0)

{

// see ShowPermissions.cpp from Adobe Plugin SDK sample.

// statImport = -1 - permission denial

// statImport = 0 - permission granted

// statImport >= 1 - permission either unknown or pending

sprintf(szMsg,"##### reader and permissions granted: %s", prodName);

traceMsg(szMsg);

retFlag = TRUE;

}

else

{

sprintf(szMsg,"%s: Reader implies NOT okay to load markup", prodName);

traceMsg(szMsg);

retFlag = FALSE; // Reader can not load markup.

}

 

Result:

No comments are exported

 

Expected:

That if the file allows commenting via checking the PDDocPermRequest then it should also allow exporting comments.

open file using Javascript

$
0
0
I am trying to open a file using a javascript dropdown menu. I know acrobat allows users to open a single file using the standard features, but I have about 30 different files that need to be referenced. the general idea is currently;

window.open("C:\Documents and Settings\Desktop\" + event.value + ".pdf");

Besides the fact it doesn't work at all, I'm getting an error message "unterminated string literal". This is due to the \ right before the end of the directory string. but I cannot think of a way to finish the directory string without using this methoid. (i've also tried assigning the '\' to it's own variable but that is throwing the same error. if you have any idea, please let me know. I may have fixed this issue, i'm using \\ instead of \ after Desktop, but the file still will not open. I've also tried using app.launchURL to no avail. please help me with another open command, please.

Custom Format Script Help

$
0
0

I am not too familiar with scripting but am hoping someone can provide some guidance or at least somewhere online that will show me how to do this.  Here's what I'm trying to do:

 

I have a text field that I need users to enter a specific number format in.  They have three choices of formats but only one type must be entered.  If I go by the arbitrary format options, they would look like this: 99-9999999OO, 999-99-9999, or 999999-99999.  Now, is there a way to write a script so that it forces the user to enter the text/number in one of those three formats only?  I am able to set up an arbitrary mask and get one of them but I need to provide options to the user.

 

If there is some good reading online where I can figure this out myself, let me know.  Otherwise, any input would be greatly appreciated.

 

Thanks,

 

Dustin


How to copy multiline text into new single line text box

$
0
0

I have a form that has several fields. My question revolves around three fields in my form. One of them is a multiline textbox ("Purpose") that is required. One is a text box for amount ("AmountR1"). The last is a single line text box ("DescriptionR1"). My goal is that if Purpose has data, AmountR1 is not 0, & DescriptionR1 is blank then Purpose needs to copy over to DescriptionR1. Due to the flow of the form, the script is in the validation of AmountR1.

//Set the source and destination vars

var Orig = this.getField("Purpose");
    Orig = Orig.replace(/[\n\r]/g, '<br>');
var MText = Orig.split("<br>");

var source = MText.join();

     source = source.replace(",", " ");

var destination = this.getField("DescriptionR1");

var AmtR = this.getField("AmountR1");

//See if destination is empty and if so, insert source value

if ((destination.value == '' || destination.value == null) && (source.value != '' || source.value != null) && (AmtR.value != "" || AmtR.value != null)){     destination.value = source.value;

}


 

However, my code is just putting "Null" in the DestinationR1 field. Any help would be appreciated.

How to redact a region with text to white?

$
0
0

I work out the following JavaScript code to redact the left header of PDF docs, but after running the code, the region redacted is in black, how can I redact the region with white rectagles? Thanks a lot!

 

for(var pg = 0; pg < this.numPages; pg++)
{  var rCrop = this.getPageBox("Crop",pg);  this.addAnnot({  type:"Redact", page:pg,  quads:[[0, rCrop[1], rCrop[2] - 345, rCrop[1], 0, rCrop[1] - 14, rCrop[2] - 345, rCrop[1] - 14]],  overlayText: "",  alignment: 1,  repeat:true });
}
this.applyRedactions({bKeepMarks: false, bShowConfirmation: false, cProgText: "Processing..." });

how to draw in Acrobat?

$
0
0
I know this is probably not the right place for that but...
I am developing a Asp.net app that deals with PDF forms. I have learned how to do the entire javascript on PDF documents, how to submit FDF data to my Web form, how to work with that data withthe Active X FDF toolkit, and fill form fields with data coming from my app.
Good.

I need to know how do simply draw 1 line in Acrobet. Or is this not posible in acrobet?

I have a form with whioch I am working and I dont lik the design. I want to add 1 litle black line in 1 place. That black line has to be part of the form design, the drawing behind the fields, but not part of a the collection of fields.

I cant seem to figure out how to do this...

I work with acrobat 8.1.2

Thanks

Exporting FDF files using Acrobat Reader

$
0
0
I have developed some forms using Acrobat Pro v9 that have buttons to save the data as FDF files using the exportAsFDF function and another button that saves the file as a PDF file with the new data.

This has been done as we normally only save the FDF file to save space but need the PDF file with data if we are E-mailing it to a client.

Both buttons work fine when used in Acrobat v9 but when a Reader enabled file is used in Adobe Reader v9 only the PDF button works. The FDF button does nothing when it is clicked.

I assume that this is because the security settings on the exportAsFDF function prevent its use in Reader by default.

Is there any way of enabling this function via Acrobat and the form so that the a user having Adobe Reader only can save an FDF file after editing the data?

How to format a text field for credit card numbers?

$
0
0

OK, I found this conversation, http://forums.adobe.com/message/3598185, that gave some useful insight, and I adapted the code presented in it to make sure the user types in a 16-digit number, and it tells them to do it right if they don't.

 

Here's my problem:

With the code as given, I can either get a single string of 16 digits (i.e.: 1234567890123456), or, I have to make the user manually type in the spaces to get the usual CC format (1234 5678 9012 3456).

 

What I'm hoping for is some code that will let me allow the user to simply type in 16 uniterrupted digits, but that will then display that entry in the expected format. (So, user types 1234567890123456, but the field once they tab or click out of it will show 1234 5678 9012 3456)

 

Here's the code I have thus far (like I said, copied alomst verbatim from the link above):

In the Format tab, under Custom Format Script:

function checkFormat(s) {

 

    if (!s) return true;

 

    var aRE = [

        /^\d{16}$/

    ];

 

    return AFExactMatch(aRE, s);

 

}

 

In the Format tab, under Custom Keystroke Script:

(function () {

 

     if (event.willCommit) {

 

         var isValid = checkFormat(event.value);

 

         if (!isValid) {

            app.alert("Please enter a valid 16 digit credit card number with no spaces or dashes.", 1);

            event.rc = false;

        }

    }

 

})();

 

I'm sorry it's so simplistic. Though I've rooted around in other programming languages (HTML, C++), so I'm not a complete noob, I don't know anything about Java at all...

Thanks in advance!

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

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;

}


Defaulting to current date for a text field

$
0
0
Acrobat Version 8.1.2
I would like to have my Adobe form take the current date default for a text field. Any idea how this can be done? I tried following on the Field Properties Calculate Tab "Custom Calculation script". Field name is TodayDate.

var TodayDate = this.getField("Today");
TodayDate.value = util.printd("mm/dd/yyyy", new date());

Anybody knows what am I doing wrong?

Prevent "Send Email" dialog until required fields are completed

$
0
0

I'm new to JS, & am struggling with one last piece of code.

I have a form with several required fields. I am sending the form as an email attachment and need the required fields completed before the form can be emailed.

Currently, I have an alert box display if any of the required fields are blank, but if I cancel the alert box, the "Send Email" dialog pops up right away and I can email the form even if the required fields are blank. I want the "Send Email" box to only appear after all required textboxes are completed.

The problem seems to be with the if/else line (IF any req. fields are blank, send alert. ELSE open the "Send email" box). What’s the best way to write this? Ideally, I'd like the alert to list the specific fields that are blank. Here's what I have at the moment - but obviously have something wrong):

 

if (requiredFields.length > 0) {
app.alert(error);

} else


var subject = this.getField("JobNumber").value + " --  Request Form";
this.mailDoc({
cTo: "me@mycompany.com",

})

 

 

(Using Acrobat XI - Thanks in advance!)

how can you calculate the difference between 2 compass headings

$
0
0

I need to calculate between to compass headings and provide the shortest answer with a + or a - in front of the result.

 

350 - 356 would result in + 6

350 - 345 would result in  - 5

355 - 002 would result in + 7

 

the end result will be applied to an iPad using PDF Expert as the reader

 

any help would be appreciated...thank you

Adding a date stamp using Acrobat XI

$
0
0

Hi there

 

I want to add a date stamp to a voucher PDF, so that when it is downloaded and printed out, it displays today's (system) date.

 

I followed the tutorial at: http://tv.adobe.com/watch/acrobat-x-tips-tricks/quick-tip-how-to-add-a-date-stamp-to-a-for m/   ,double checked the javascript, and this seemed to work. But when I checked the following day, the date displayed was still set at yesterday's date. It had not moved forward. I tried saving as Reader Extended/Enable More Tools, but that didn't work either and I think it removed the JavaScript altogether.

 

In the original, I went to  Edit All JavaScripts and this is the code that was there:

 

//-------------------------------------------------------------

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

//-------------------------------------------------------------

 

//<Document-Actions>

//<ACRO_source>Document Will Print</ACRO_source>

//<ACRO_script>

/*********** belongs to: Document-Actions:Document Will Print ***********/

var f = this.getField("DatePrinted");

f.hidden = false;

f.value = "Printed on: " + util.printd("mmm dd, yyyy", new Date());

//</ACRO_script>

//</Document-Actions>

 

 

Can anyone please help?

Javascript and document certification

$
0
0

I have document whit a text that has JavaScript to print that the document expires 48 hours after the print date.  When the document is signed/certified the java script stops working.  We are trying to create a document that will update the time stamp when it is printed and still sign/certify the document.  Is there a way to do both?

 

Thx

Viewing all 12130 articles
Browse latest View live


Latest Images

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