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

Weird bug with DC template spawning

$
0
0

Hi all!

 

Here is Weird bug  with DC template spawning i am struggling to solve.

I do my development in Adobe Pro XI.

Recently i got complaints from users saying  template spawning would not work in Adobe DC.

I installed Adobe DC reader and found this weird bug

I created simple PDF to illustrate it.

 

  1. PDF has hidden template named "RawDataPage"
  2. PDF has 6 pages initially
  3. First page contains 4 buttons.
  4. Button 1  adds 1 template  after page 6, Button 2  adds 2 templates  after page 6 and so on
  5. Close PDF without saving after button click, just observe spawning
  6. You can find PDF files and screenshots at dropbox link https://www.dropbox.com/sh/qap5j5tzyomrlxw/AABGFv6Z0jGKE62SO6pgy2YSa?dl=0
  7. I am going to update shared  folder upon information arrival
  8. find all js code below inline

 

//<AcroForm>
//<ACRO_source>ButtonApply1:Annot1:MouseUp:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:ButtonApply1:Annot1:MouseUp:Action1 ***********/     getTemplate("RawDataPage").spawn(6, false, false);


//</ACRO_script>
//</AcroForm>


//<AcroForm>
//<ACRO_source>ButtonApply2:Annot1:MouseUp:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:ButtonApply2:Annot1:MouseUp:Action1 ***********/     getTemplate("RawDataPage").spawn(6, false, false);     getTemplate("RawDataPage").spawn(6, false, false);


//</ACRO_script>
//</AcroForm>


//<AcroForm>
//<ACRO_source>ButtonApply3:Annot1:MouseUp:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:ButtonApply3:Annot1:MouseUp:Action1 ***********/     getTemplate("RawDataPage").spawn(6, false, false);     getTemplate("RawDataPage").spawn(6, false, false);     getTemplate("RawDataPage").spawn(6, false, false);
//</ACRO_script>
//</AcroForm>


//<AcroForm>
//<ACRO_source>ButtonApply4:Annot1:MouseUp:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:ButtonApply4:Annot1:MouseUp:Action1 ***********/     getTemplate("RawDataPage").spawn(6, false, false);     getTemplate("RawDataPage").spawn(6, false, false);     getTemplate("RawDataPage").spawn(6, false, false);     getTemplate("RawDataPage").spawn(6, false, false);
//</ACRO_script>
//</AcroForm>

 

I expect code to be working in the same way both in Adobe XI and DC

See versions below

VERSION XI - 11.0.13VERSION DC 15.010.20056
proXI-version.jpgreaderDC-version.jpg

 

 

 

Now compare results


Button 1 ->ADDED 1  OK in both Acrobates

 


Button 2 ->ADDED 2  OK in both Acrobates

 


ADOBE PRO XIADOBE READER DC
Button3 - > ADDED 3 - OKButton3->ADDED 3 - page 8 is broken
proXI-added3 tpl.jpgreaderDC-added3 tpl.jpg
Button4->ADDED 4 - OKButton4->ADDED 4 - pages 8,9  BROKEN
proXI-added4 tpl.jpgreaderDC-added4 tpl.jpg

 

 

 

MORE WEIRD STUFF

  1. SAVE PDF WITH  ADDED 4 PAGES FROM READER
  2. OPEN IN ADOBE XI
  3. SCROLL TO PAGE 7
  4. Error reading (14)
  5. Zoom jumps to 5983%

    TEMPLATE_SPAWN_DC_ISSUE_SAVED _FROM_READER_OPEN_IN_PRO.jpg

Need Script to Continue After Clicking OK on Alert Box

$
0
0

My form has multiple required fields. In order to ensure the form has been filled out completely, the submit button on the form has a javascript action on it to check the contents of the required fields, and if necessary, return the user to that part of the form to enter the required information.

 

Just before the form is mailed, I am checking for a value of "Vendor_Guidelines" in field 18. If that field's value is "Vendor_Guidelines", I would like to pop up an alert reminding the user to include the guidelines when submitting their request. They should be able to click "OK" on the alert, and continue with submitting their form.

 

Below is the expert of the script on the submit button. Once the alert displays, I really don't really need to set focus back to f18, I just need the user to be able to click OK and allow the script to continue so the form can be submitted.

 

Thanks in advance for any ideas on this.

 

 

 

 

              else if (f18.value == "Vendor_Guidelines")

  {

  app.alert ('You checked the Vendor/Buyer Guidelines checkbox on page one of this form. Attach the guidelines to this request email.');

  f18.setFocus();

  }

  else

  {

        // Email PDF.

        var m = this.getField("ad_desc");

        var mysubject = m.value + " - Request Form Submission";

        this.mailDoc(true, "requestforms@ducjvh.com", "", "", mysubject);

  }

}

Hide/Show layers with Javascript

$
0
0

Hello,

 

I am trying to find a Javascript method for hiding/showing layers in a pdf document. I would like to be able to use an if/else statement to set the visibility of multiple layers.

 

Let's say I have 5 layers on a single page, all set to hidden by default. This page also has a field with 5 options relating to each of the 5 layers. Once an option is selected, an if/else will use this method to set the appropriate layer to visible.

 

Thank you!

Save File with Different Settings

$
0
0

So I have PDF files that I continue to have to apply the same steps to. I am not really that great with programming. I have written 2 tools using the trustedSave MenuItem. I have 2 different tools created. I have commented in the steps I am not sure if are possible or not. I have the api book but again I am not a programmer....I stumble through the best I can

// TO SAVE WEB FILE
app.addMenuItem({    cName: "trustedSave",    cUser: "Save SIS File",    cParent: "Tools",    cExec: "saveSisFile();",    nPos: 0
});


function saveSisFile() {
    app.beginPriv(); {        // EMBED ALL PAGE THUMBNAILS        // USING SMALLEST FILE SIZE FROM PDF OPTIMIZER        this.saveAs("~/Desktop/" + this.documentFileName.substring(0, 11) + '_SIS.pdf');    }    app.endPriv();
}


// TO SAVE TILED FILE
app.addMenuItem({
    cName: "trustedSave",    cUser: "Save P File",    cParent: "Tools",    cExec: "savePFile();",    nPos: 0
});


function savePFile() {
    app.beginPriv(); {        // EMBED ALL PAGE THUMBNAILS        // DELETE PAGE 1        // PRINT - TILE LARGE PAGES - WITH 0.5" Overlap        this.saveAs("~/Desktop/" + this.documentFileName.substring(0, 11) + '_P.pdf');    }    app.endPriv();
}

Acrobat 8 Pro, Windows 7 64 bit machine

Automatic Number Generation When Opening an Acrobat Form

$
0
0

Hello,

 

I've created a PDF Job Ticket Form with several input fields using Acrobat Pro, now I would like to have this form automatically generate a sequencial number on each page of the form everytime it opens. This number would serve as a Job Number or an Invoice Number so it would need to be unique everytime it was generated.

 

I would assume this would be a simple script that could grab the previous job number and increase the value by one, but I'm am unsure how/where to save the previous job number in the form so that the number/field can be incremented sequencially each time it opens?

 

If this is possible I would greatly appreciate any help you can provide.

 

Thanks in advance!

How can I move the contents of many pages at one time?

$
0
0

Hi there.

I have a PDF document in which the top is not aligned with my top margin guide. I want to align all the pages to the top margin guide in Acrobat. How can I do that?

 

Any help would be appreciated

Can you import a signature with a Checkbox?

$
0
0

Hello,

 

I'm new to acrobat and javascript, but was wondering if you can make a fillable form that when opened in Reader, will populate a field with a signature depending on which Checkbox is ticked?

 

So I have a list of employees on the document with Checkboxes next to each name. Could the Checkbox that correlates with the Name, trigger a javascript action, that places that persons signature in a field within the same document, but not the same page?

 

I'm sure this is possible, but I imagine it could be quite complicated. Any help will be greatly appreciated.

 

 

Also, Acrobat is a great product and can really be beneficial to how we operate in our company. What can I do to learn more? Any suggestions of courses, online tutorials etc, will again be greatly appreciated.

 

Thank you

Can a field accept either TEXT or NUMBER?

$
0
0

I need a field(var L2) in a fillable form  to either be able to accept the letters "n/a" if the question is not applicable, or they need to be able to enter a dollar amount in that field that will function as part of another script (below). I don't want the field with the following script to show up blank if the user enters "n/a".   Do I need to edit the following script in order to make this function properly?  Right now, the form is not allowing me to enter any text at all.

 

var L2 = Number(this.getField("undefined_2").value);

var L3 = Number(this.getField("undefined_3").value);

var L4 = Number(this.getField("Percent").value);

event.value = (L2<L3) ? L2 : (L3*L4)/100;


Fillable PDF that populates a future buisness day

$
0
0

I have created a fillable PDF document that end users will utilize to book an event. The end user will enter the date they want the event to happen.   Further down the document i would like several read only fields to auto-populate with business dates along the way that show the end user some benchmarks of when things will happen.

 

 

Example:

End user enters an event date into TextBox1

Textbox2 auto-populates with a date X Business days before the event showing when the End User will receive a communication confirming that the event is still scheduled

TextBox3 will Auto-populate with a date Y business days before the event showing end user when the set-up for the event will begin

Finally TexBox4 with auto-populate with a date Z business days before the event showing when the end user may inspect the event site

 

 

 

I am able to have all the text boxes auto-populate with Calendar days using the below code.  However I want to be able to execute this doc using Business days not calendar days.    Is this possible?

 

 

 

 

 

For the calendar days I have a Document script called "countDays"

function countDays(z){

var a = (1000*60*60*24) * z;

var b = 0;

var c = new Date();

var d = this.getField("TextBox1").value;

if(d!=""){

var e = Date.parse(util.scand("mm/dd/yy", d));

c.setTime(e + a);

event.value = util.printd("mm/dd/yy",c);}

}

 

TextBox2 then has a Custom Calculate script of

countDays(-14)

 

TextBox3 then has a Custom Calculate script of

countDays(-7)

 

TextBox4 then has a Custom Calculate script of

countDays(-2)

Why does the Javascript that controls certain text fields not re-render immediately?

$
0
0

I am creating a form in Acrobat XI Pro.

 

I made several text fields asking for Room Number. Other text fields create sentences based on those Room Number inputs. For instance, if a user enters a room number into the text box "Room1", the code for "TextBox1" is the following:

 

var roomnumber = getField("Room1").value;

if (roomnumber != "") getField("TextBox1").value= "Enter square footage of Room "+roomnumber+" here:";

else getField("TextBox1").value="";

 

I'm finding that TextBox1 does not continuously re-render as the text in "Room1" changes. If I change the entry in Room1, TextBox1 stays unchanged for a while. After I click on another box in my form and then out again, the Javascript for TextBox1 "catches up" and shows the correct text.

 

I know my code is correct, because EVENTUALLY the text boxes behave correctly. Shouldn't all text fields be constantly re-calculated any time someone interacts with the form?

Javascript Issues When Delivering to Client Using Acrobat Reader XI

$
0
0

I am working on a form for a client that essentially takes a table of radio button values, applies a weighted percentage to them, and creates a score for each row in the table. The score is then tallied at the end of each of two tables. Ultimately, those two scores get averaged in the final row on page two and a result "Complete Action A" or "Complete Action B" shows up in a text field next to the score. The entire thing is working beautifully after multiple revisions. Or rather, it's working beautifully in DC Pro and DC Reader. When I send to the client who is using Reader XI, the last row (the if/then script for the average of the two scores and the text action) are not calculating at all. Any help would be appreciated. This is all confidential work for a client so I cannot post the actual file, but can share code snippets for the java.

Redact using quads

$
0
0

If you have your redactions already marked is there a way to loop through and gather the coordinates while applying another process using Acrobat Pro 9.5?  I was looking at this,  https://acrobatusers.com/tutorials/auto_redaction_with_javascript , and other examples but they all seem to be static numbers for the quads.  I'd just like to apply a strikethrough on the redactions I have marked and if possible place a stamp based of the quads coordinates.

Incremental search while typing in combobox?

$
0
0

Hi guys,

 

I am creating a form to be given out to a large amount of managers to fill in multiple times, and because of the size of the organisation I work in we have over 500 different job titles and over 100 different departments. At the moment all of these are in 2 different comboboxes and finding the correct option is a drag. I found a PDF which had been created in Lifecycle that had this feature but I was unable to load up the JS and take a look for myself and add it into Acrobat Pro as it said I have to open it via Lifecycle.

 

I have searched for hours for a solution I could incorporate into my PDF but it seems it either not possible or no one has really requested it.

 

Does anyone know if such a thing is doable in Acrobat Pro with Javascript?

Requesting assistance with printing document from mac

$
0
0

G'day Javacripters

 

Using Acrobat Pro DC for Mac.

 

I've only use Java to add barcodes and text boxes to my Applescript Objective C application, but would like to see if it's possible to directly set print settings, and print every page of my documents using Java. I've searched, but cannot find an answer.

 

Specifically, I want to set the following properties...

 

Printer : largePagePrinter as variable

Pages to Print : All

Size : Actual Size

Auto portrait/landscape : true

Tile Scale :100%

Overlap : 0.5"

Cut Marks : true

Tile only Large Pages : true

Orientation : Portrait

Auto-rotate pages within each sheet : true

 

Page Setup dialog

Format for : largePagePrinter as variable

Paper Size : largePaperSize as variable

Scale : 100%

 

At the moment I'm using the GUI to set each property, and it's slow, particularly for the separate Page Setup dialog, and we're processing 200 plus pdf's a day.

 

Is this possible? And if so, some guidance on coding would be appreciated.

 

Regards

 

Brian Christmas

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

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;

}

Text fields and number 0 problem

$
0
0

Hello.

I have very wierd problem and I hope, that somebody could help me.

I have group of 7 checkboxes, named "group". Each checkbox has his own export value. (-3, -2, -1, 0, 1, 2, 3). Then I have one text field, named "polje" where selected value is displayed. If user select check box with export value 3....text field showing number 3 and so on. I get this with this script:

getField("polje").value = this.getField("group").value;

 

So far everything works perfect. Now...problem. I have another textfield, named "procent". His mission is to show additional text by specific value.

If  field "polje" showing value 1, textfield "procent" must display "30%", if value is 2 then "60%"....and so on. Everything works fine...only with value 0...then textfield stay empty but it should display "0%". I dont know why.

Script I use:

 

var p = this.getField("polje").value;

 

if (p == "") {

    event.value = "";

}

else if (p == 0) {

    event.value = "(0%)";

}

else if (p == 1) {

    event.value = "(30-40%)";

}

else if (p == 2) {

    event.value = "(60-70%)";

}

else if (p == 3) {

    event.value = "(90-100%)";

}

else if (p == -1) {

    event.value = "(-30-40%)";

}

else if (p == -2) {

    event.value = "(-60-70%)";

}

else if (p == -3) {

    event.value = "(-90-100%)";

}

 

Where I do something wrong?

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.

Sort bookmarks alphabetically

$
0
0

I have several major bookmarks and quite a few subbookmarks below each of the major bookmarks, and the subbookmarks need to be alphabetical within their major bookmark category. I've not been able to find a feature in Acrobat Pro that will sort bookmarks. Does anyone on this forum know of such a feature or can point me to a script that will sort bookmarks?

Scan a folders/subfolders for PDF files to find the corrupt/unreadable one?

$
0
0

Hi...

We have archive share with 400.000 pdfs in many subfolders. Some of them is corrupted or unreadable. Need some way to find this pdfs.

 

tnx

Viewing all 12130 articles
Browse latest View live


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