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

Modifying a pdf page using Javascript

$
0
0

Hi all,

 

- I am having an html report that consists of many html pages.

- Each page of these html pages contains a table or more, in addition to some buttons that hides/display specific rows in these tables. And these buttons are programmed using Javascript.

 

I would like to convert these html files to a single pdf file.

My question is: If I converted the report to html, will my buttons work. I mean will my Javascript buttons hide/display table rows in the pdf pages ?

 

Thank you,

Moustafa


Need to create date/timestamp or watermark when printed.....

$
0
0

I want to be able to have the time/date printed out on a pdf when it is printed. I could be as a header/footer or a watermark. It doesn't really matter. Is this possible? Can it be done in adobe reader. I need to do this on networked pc's and I just want them to print the pdf and it automatically print the date and time on it. The networked pc's only have adobe reader.

 

Thanks!

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

Acrobat Forms - javascript to hide/unhide text box if any one of a number of radio buttons is enable

$
0
0
I have a form which I am designing in Acrobat 9 which has a section where there are three questions, each with a pair of radio buttons - one for 'yes' and one for 'no'. They are in the style of a check box (with a tick). I need some help to write some code which will unhide a single field (or multiple fields if I need to use something similar at a later date) if any one of the 'yes' radio buttons is checked. So if all three radio buttons were checked, the field would be hidden but if you then changed your mind and clicked a yes button, the field would be visible.

I am new to this so any help would be greatly appreciated. Many thanks in advance! I hope that i have explained this clearly btw.

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 that will show top scores

$
0
0

I am working on an form where people answer questions, add up the results to find out in what area they score highest.

I have the calculations set up to auto fill the score sheet, but I would like the results page to  auto fill with the name of the top 3 scores in order 1, 2, 3.

Is this possible with Javascript? I am an absolute beginner.

pdf form conditional checkboxes

$
0
0

Hi.

 

I'm building a pdf form in Acrobat 8 Professional. I want to add JavaScript to 3 checkboxes to achieve the following:

if checkbox 1 or 2 is checked, uncheck checkbox 3; and if checkbox 3 is checked uncheck both 1 and 2.

 

It seems straightforward, but I have not been able to find a solution either in the Acrobat guide nor online. I have no experience in Javascript other than copying and pasting, so I'm not sure I'm using the right language to search. If anyone can provide any guidance, I would greatly appreciate it.

 

Thanks a lot!

Detecting a failed POST communication in a Form's javascript

$
0
0

My PDF form has a 'Submit' button that is a standard button with Javascript responding to the button's 'Mouse Up' event.

The Javascript calls the function 'submitForm', and this results in a POST to a website who's URL is written into the form's js code.

A POST can fail to achieve the desired communication through no fault of the form, its js code or the Adobe Reader in which the form is being hosted. For instance a simple communication break or lots of noise will cause such a failure. Adobe Reader certainly detects the occurrence of an unsatisfactory response to the POST, as it advises the user via a simple 'alert' dialog.

The function 'submitForm' returns 'true', regardless of the condition of the communication. ( I have never seen this stated, but my testing indicates that the return of 'true' is not affected by any communication failure.)

I need the code behind the form to be advised of a POST communication failure, so that it can make a particular adjustment to the form. Presumably this would be achievable by use of an event listener, but I cannot find any information on a hookable event in Adobe Reader that is related to such a failure. Does anyone have any ideas?


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


)();

Open Data Object - Open File attachment within pdf document

$
0
0

I am trying to build a script which will open file attachments embedded in a pdf document.

 

I have used the following javascript to list all embedded files within a document so I can retrieve the name

 

var d = this.dataObjects;

for (var i = 0; i < d.length; i++)

console.println("Data Object[" + i + "]=" + d[i].name);

 

The console reported:

 

Data Object[0]=MTP-300-X-1210_A.pdf

Data Object[1]=MTP-300-X-1240_A.pdf

 

 

I then used the following script to open the file     

 

this.openDataObject("MTP-300-X-1210_A.pdf");

 

Console reports back as follows and does not open the file:

 

[object Doc]

 

Can anyone please offer assistance in how to open an embedded pdf attachment within a document?

 

Many thanks!

Printing a PDF via Acrobat Javascript

$
0
0

Hi -

 

I have a need to print a PDF programmatically, via Javascript.  The PDF is embedded in a Web page.  I use postMessage to communicate with the PDF.

 

I've created a simple HTML page with an embedded PDF, and a Javascript link to call my "Print" function. Here's a code snippet:

 

<body>

         <a href="javascript:doPrint();">Print</a>

         <object id="PDFObj" data="testPDF.pdf" type="application/pdf" width="400" height="400" />     
</body>

 

In the HTML document's HEAD, I've added the following Javascript which posts the message to the PDF:

 

<script language="JavaScript">
        function doPrint() {
            pdfObject = document.getElementById("PDFObj");
            alert("Hello from Javascript...");
            pdfObject.postMessage(["Print", "Print"]);
       }
</script>

 

Finally, I've added an Acrobat Javascript function in the PDF document to listen for the postMessage event:

 

function myOnMessage(aMessage)
{

    app.alert("Hello from the PDF");

       // print routines here

   
}

var msgHandlerObject = new Object();
msgHandlerObject.onMessage = myOnMessage;
msgHandlerObject.onError = myOnError;
msgHandlerObject.onDisclose = myOnDisclose;

function myOnDisclose(cURL,cDocumentURL)
{
return true;
}

function myOnError(error, aMessage)
{
app.alert(error);
}

this.hostContainer.messageHandler = msgHandlerObject;

 

Here's my problem: when I test this code and click the HREF Javascript link, I see "Hello from Javascript..." and "Hello from the PDF," so I know the postMessage event is working.  However, I've tried every print command I know in the myOnMessage function, and nothing seems to work:

 

app.execMenuItem("Print"); // doesn't seem to work

this.print(); // doesn't seem to work, even when I pass in all the params, etc

 

I've also tried getting print params and passing those in, nothing seems to work.  Am I missing something?  Environement is Acrobat 9 Pro, browser's tested include Chrome 2.0, IE6.  I've attached two files, the HTML bit and the PDF I'm trying to print.  Any help is greatly appreciated!

What action besides the mailto: one will work with a submit button to activate the required fields?

$
0
0

I have a submit button that uses the mailto: function to activate the required fields property on a pdf fillable form, but our users would prefer that the form not generate an email. Please let me know what I could replace the mailto: action with so the submit button will only activate the required fields proptery.

 

Thanks for the help!

 

Ken K. 

Insert Signature Field (JS)

$
0
0

I'd like to insert a signature field at certain coordinates on first page of my document.

Any help?

Script to Insert a Custom Stamp/Annotation

$
0
0

Hello,

 

I have created a new custom stamp and need to add a script to "Batch Processing" to insert this stamp on 1,000 drawings.

 

The sample script available from the JavaScriptfor Acrobat API Reference inserts a stamp from the "Standard" Stamp File.

 

The standard stamp file is located in the following directory:

 

C:\Program Files\Adobe\Acrobat 8.0\Acrobat\plug_ins\Annotations\Stamps\ENU\Standard.pdf

 

The script needs to be modified to insert a stamp from a custom stamp menu called "Doc Control" and the custom stamp name is "Received".

 

The actual file which contains the custom stamp is located in the following directory:

 

C:\Documents and Settings\username\Application Data\Adobe\Acrobat\8.0\Stamps\Doc Control.pdf

 

 

Please find below the script which needs revising to include the new custom stamp.

 

 

var annot = this.addAnnot({

page: 0,

type: "Stamp",

name: "myStamp",  rect: [400, 400, 550, 500],

contents: "Received Stamp!",

AP: "NotApproved" }); This part of the script needs revising to refer to the new custom stamp not the stamp in the standard stamp file?

 

Any assistance will be greatly appreciated - Thank you.

 

 

 

 

 

 

 

How can I add form field value to the file name in save as dialog box

$
0
0

I do not want the form to be saved automatically, just want the form to auto populate the "file name" only.

 

A little background on the forms I want to use:  My company has 70 retail outlets, I'll use one of our pdf forms called an "Incident Report" as an example.  I would like for a store manager to be able to complete the form, then email the form to the main office (I already have javascript to add field values and form name to the email subject line), once the main office receives it, I want for them to be able to file the pdf electronically on our server.  We have mutliple forms that we use so I do not want any of the forms to automatically save anywhere, (at this time anyway) I just want the office personnel to be able to click "save as" (or whatever they will need to click) and the form automatically add certain field values from the pdf they have received, of which will be different each time the form is sent to the office (Date, store #, employee name etc.) in addition to the name of the form in the "File name" of the "Save As" dialog box.  The main office employees will decide into which server file the pdf should be saved.

 

I'm using Acrobat 8 professional, the stores and office personnel use Adobe reader.

 

One little note:  We currently print and file a lot of paper on a daily bases, as soon as I can get this to work, we are going green.

 

Me and a lot of trees in this will really apprecitate any help you can give with this!  :-)


cancellation of chained actions

$
0
0

Hello,

 

I have a chain of actions bound to an event (as seen below). Is it possible to cancel all following actions in the first javascript?

 

I was googling it but no success.

 

Thank you.  

 

I chained.png

Keep Text in Uppercase

$
0
0

I am using Adobe Acrobat 9 Standard. I have script to change lowercase to uppercase in many form fields on a PDF. But if I return to the field that has already changed lowercase to uppercase, it goes back to lowercase until I exit the field again. These fields are used a lot to copy and paste into other applications and I want the fields to remain in uppercase once they are converted.

 

Please help!

 

I am using this to convert to uppercase: event.value = event.value.toUpperCase();

 

Thanks,

Brandy

How do I invoke Word PDFMaker from a macro?

$
0
0
Hi,

I need to automate creating PDF's from Word with hyperlink fields converted precisely. The Adobe toolbar "Convert to Adobe PDF" button does exactly what I need. How do I invoke this type of conversion programmaticially, e.g. from a Word macro? Can anyone point me to a SDK document that discusses this?

(BTW, printing the document to the "Adobe PDF" printer will not work. I need the exact functionality of the toolbar button).

Problem with Adobe XI

$
0
0

   Hello

 

I had a custom stamp with a date in the middle of it MM DD YYYY. Was working fine in Adobe X but when the IT upgraded to XI I lost everything. I re-created the stamp with the date using the date script that I found in the forums for XI. When I create the stamp it updates to the current date but the next day it still shows the same date, in other words the script is not updating the date. Any ideas I really cannot find anything on this online?

 

Thanks,

JavaScript Validation to Submit Form

$
0
0
Hi,

How do you validate all the fields in JavaScript when the user clicks the Submit button so that if any required fields are empty or any field validation fails, nothing (submission, JavaScript code, execute menu items, etc.) will be executed? I found something about execValidate() but it didnt work for me. It wouldnt do anything. I am using Adobe Acrobat Professional 8.0.

For instance, I have a field set up to accept numbers between 1111 and 9999. If the user enters 1 and tabs out of the field, he gets an error message and the value is deleted. The field is also set as a required field. But if the user clicks the Submit button, all JavaScript code will be executed, menu items too. The only thing that fails is "Submit a Form" only for the required field part. What can I include in the JavaScript code to check if all fields are valid, according to their corresponding rules, and if yes, continue to execute all the other actions. If not, cancel all and let user make the necessary changes.

Thank you for your help!
Viewing all 12130 articles
Browse latest View live


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