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

Need javascript to place a jpg into acrobat form field

$
0
0

Anyone up for a scripting challenge? I want to place a logo in a restricted box in a PDF as part of our co-marketing efforts. I am current working in CS6 (acrobat X) and have the following, On Mouse up I am running a javascript; // Mouse Up script for a button event.target.buttonImportIcon();This will only allow for a PDF to be placed, is there a script that will allow for a .jpg to be placed? I can provide a PDF sample. This will be such a pain if our customers have to convert to a PDF rather than use existing jpg. Any help is welcomed!


Finding pages with comments/markup in many documents (need help)

$
0
0

I'm trying to make a script that will find all pages with comments and markup (annotations) for a batch of many documents. The details like which pages have those should be logged to the console, and the user should be alerted if a document does indeed have comments.

 

Here's my code: [JavaScript] Find Markup - Pastebin.com

It works flawlessly when I just run it on one document, but when I add it to an action and run it on many, it becomes very unreliable. Some documents with comments are logged with only a few of the commented pages, and others seem to be completely ignored. Any thoughts on what might be causing this?

Date Field in Adobe Acrobat X

$
0
0

I have a form that users fill in. One of the fields on this form is a date. Through the properties I have set the date format of dd/mm/yyyy. What I was hoping to be able to do next is, get it to auto populate. So when the field onFocus it executes something similar to the now() you can use in MS Access etc.

 

Is there a way of getting it to add the system date automatically if so, how?

 

Many thanks in anticipation of a speedy helpful response

 

Kindest Regards

 

Toni

Display Filename in PDF File

$
0
0

Hi there, hoping for some help on what I think is quite a simple issue.

 

I want to create a blank single page PDF file which has a text field automatically and dynamically completed based on the file name of the pdf document. So for example if the file is named "My Sample File.pdf", the pdf file will display "My Sample File.pdf" and that is all. If I then rename the pdf file in Windows Explorer to "My Renamed File.pdf", when I next open the file it will display "My Renamed File.pdf".

 

I would then insert this one page pdf into an array of existing pdf files as their new page no1 to effectively be a title page for each created automatically based on their current filenames.

 

My research suggests this is possible using Javascript in a text field, or a form field (although I would prefer text field), however, as I have no experience of Javascript or its implementation within Acrobat, is proving impossible for me to do. The nearest I have got is a script which puts the filename as a watermark; unfortunately that script keeps overlaying the new filename over the old filename watermark, rather than updating it. For information that script was:-

 

this.addWatermarkFromText({

cText: this.documentFileName,

nTextAlign: app.constants.align.center,

nHorizAlign: app.constants.align.center,

nVertAlign: app.constants.align.bottom,

nFontSize: 12,

nVertValue: 12});

 

Ideally I would like the script to strip the file extension and if possible split the output onto two lines based on the filename portion which preceeds/follows a comma in the filename (which it would also strip). For example, if a had a file which was named "My Sample File, created on Monday.pdf", it would display as:-

 

My Sample File

created on Monday

 

If anyone has any ideas on this, it would be greatly appreciated.

 

Regards and thanks in advance,

Malcolm Dowers

Javascripts folder for Acrobat X on MAC

$
0
0

there is a Javascripts folder for Acrobat 9 under the install location, but I do not see that for the acrobat x installation on MAC.

any ideas?

 

thanks!

is there any way to get windows environment variables like %USERNAME% with javascript?

$
0
0

is there any way to get windows environment variables like %USERNAME% with javascript using Adobe 10 pro?

How to Apply Security or Remove in Batch using Acrobat X

$
0
0

I’m using Acrobat X Pro. I’ve used Acrobat Pro 6-9. I need to remove security in batch and apply security to about 100 PDFs. I’m totally lost in Acrobat X. Where are all of the batch sequence commands that were in Acrobat 9? Can anyone point me to an article or tutorial on batch sequences and the new “Action Wizard”.

 

Thanks.

Can i create a button that allows users to insert a line into a table if neede more space

$
0
0

if so how in step by step please and thank you


Open PDF file locally + on web server with Javascript for all browsers

$
0
0

Dear,

 

I have the following code that needs to open an image (PDF file) that is located in a folder above my PDF from which it is called. My code is associated to a 3D annotation object in my PDF file.

 

var openImage = function() {

if((strImagePath.indexOf('http://')!==0) && (strImagePath.indexOf('https://')!==0)){

if (strImagePath.indexOf('file://') === 0) {

strImagePath = host.decodeURI(strImagePath);

strImagePath = strImagePath.replace("file://", "");

strImagePath = strImagePath.replace(":/", "/");

strImagePath = strImagePath.replace("|/", "/");

}

  1. host.app.openDoc(strImagePath);

            } else {

host.getURL(strImagePath)

}

};

 

The PDF should be opened from a HTML page that is hosted on a web server, but also can be opened from the harddrive.

This code works when the PDF file is opened from a hosted website. It also works when the PDF is opened local in Chrome, Firefox and Internet Explorer. But to make it work in Safari on OSX I need to change host.app.openDoc(strImagePath) to host.getURL(strImagePath). But then it only works local in Safari and Firefox.

Does anyone know how I can make this work for all these webbrowsers?


Thanks a lot for your help !

Tom

Background Based on Dropdown Selection (Different Field)

$
0
0

Greetings;

 

I have a form that has many required fields, but they vary based on drop down selections...the good ol' "If yes, Why?"

 

So I have a drop down {DropdownA} that defaults to have a background colour - it is always required - (which is removed once a selection other than ' ' is made), but if it is 'Yes', I need another field {DropdownB} to have the background colour applied.  If it is 'No' {DropdownB} should remain without a background.

 

I have about 4 hours of JavaScript experience, so please be kind

can't select fields for calculations

$
0
0

someone suggested I try this section.

 

 

Hi

 

I am using acrobat 9 pro and i can't slect field for calculations.

 

I can select all of them by clicking on select all and can deselect all.

 

but I cannot choose individual fields.

 

TIA

Disable field highlighting?

$
0
0

Good Morning,

 

Working on a form that will be distributed to a number of users.  The form utilizes a lot of scripts to highlight fields that require attention.  The form works/shows well when the preset "highlight fields" is turned off (currently done manually).

 

Is it possible to disable field highlighting using a script or by changing the preferences so that when the document is opened, the form fields are not highlighted?  During testing, the "highlight fields" option is turned on by default on other users machines.  I searched on the Internet and came across the following:

 

Layout: Ready event

app.runtimeHighlight = False

 

Can this be used and if so, where would it be entered (hopefully not in every field).


Thanks

Javascript Code to Print Multiple Page Ranges in Acrobat

$
0
0

Hi All,

 

I am very new to Javascript (used it for the first time this morning) and was looking for some help.

 

I have built a fillable pdf form in Acrobat that I am required to print on a very regular basis.

However, when I print it, there are only particular pages that I need to print as opposed to the entire document.

 

I have put in a Print button that executes the below code when pressed:

 

this.print (true, 1, 25) ;

this.print (true, 27, 28) ;

 

This allows me to print two different page ranges, but it separates them into two different print jobs.

Is there a code that will allow me to put them into the same print job, so that it selects pages 1-25, 27-28 rather than doing them separately?

I am currently using Adobe Acrobat X Standard.

 

Any input would be much appreciated.

 

Thanks!

Dialog 'Save As', 'Print' return value

$
0
0

Hello,

is it possible to get return value of these dialog boxes? I create forms in Adobe Livecycle ES2 and from xfa.host.messageBox I can get 4 values to each answer.

 

Thanks you.

doc.saveAs() and trusted function

$
0
0

About three years ago, I posted on this forum a question about creating a trusted function to save to a specific location.  I cannot find the original post.  I remember at that time I was looking for a way to save to the user's desktop folder which path changes from user to user.  Somebody came up with this:

myGetPath = app.trustPropagatorFunction(function(v1,v2){

app.beginPriv();

return app.getPath(v1,v2);

app.endPriv();

});

myTrustedGetPath = app.trustedFunction(function(v1,v2) {

app.beginPriv();

return myGetPath(v1,v2);

app.endPriv();

});

 

safeSaveAs = app.trustPropagatorFunction(function(doc,vPath){

app.beginPriv();

doc.saveAs({cPath:vPath});

app.endPriv();

});

myTrustedSaveAs = app.trustedFunction(function(doc,vPath){

app.beginPriv();

safeSaveAs(doc,vPath);

app.endPriv();

});

 

After reading throught the API reference and this tutorial, I don't understand the difference between the trusted function and the trust Propagator function or why I need a trust propagator.

 

What I need now is to save to a predetermined folder so I guess I can drop the getPath part.


Code Problems

$
0
0

 

I am trying to create a custom calculation script that takes the results of two fields as strings and prints the two strings together with additional text.

 

I have Adobe XI Pro.This is what I have that does not work.

   

Function () {


Event.value = this.getField(“PatientName”).valueAsString + " was seen on " + this.getField(“DateOfEvaluation”).valueAsString;

 

}

 

 

 

The form contains both fields “PatientName” and “DateOfEvaluation.” It doesn’t matter if either or both fields have value. The error is that a character is illegal.

 

If I reduce it to Event.value = " was seen on ", the script is accepted but doesn’t show up in the form box upon reopening the document.


I have tried several iterations more complex than the first simple function above. The more complex iterations involve defining variables, and have come back with the error saying that a semicolon is missing from the beginning of the second or third line (despite that every line ends with a semi colon.)


Any help is appreciated.

Need help with a simple calculation.

$
0
0

I will apologize up front. I have no knowledge of writing Javascripts. I can use them if somebody writes them for me, but that's it. I've created a simple form dealing with money. I have different text boxes for the user to enter a number based on what type of currency it is. Currency.jpg

In the left column, they will enter a number. I would like for the right column to be calculated from that. However, the currency amount (ie. 100, 50, 20, etc) isn't a text field. It is simply text that entered in another program. What I'm looking for is a way to do this without having to make the currency amounts a text field. Something along the lines of X*100=.

 

If you can give any help or suggestions, I would greatly appreciate it.

 

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

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!

How to copy data from one textbox and combine that with pre-existing data in another textbox when triggered by button event?

$
0
0

 

Hi guys,

 

I’m a bit green at all this, but I know this is possible to achieve using javascript.

 

Any help would be much appreciated.

 

Viewing all 12130 articles
Browse latest View live


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