These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Selecting pages then emailing the selected pages with a Button

MSP
Registered: Sep 16 2008
Posts: 25

Hello,

I was wondering if there is a way to insert a check box in the bottom left corner of every page, then at the end of the document putting a button which, when clicked emails me which pages were selected. I am a beginner with Javascript in Acrobat, but have read through the manual(briefly) and have a somewhat vague understanding of it. Thank you for viewing my post and I look forward to hearing from you.

MSP

My Product Information:
Acrobat Pro 8.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Look at this post

http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=15808

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

MSP
Registered: Sep 16 2008
Posts: 25
Basically I want to keep track of which pages have the checkBox checked then at the end email me the name of the bookmark for the pages checked. I don't want the entire pdf page of the checked ones. I have a copy and can just find which pages they want if I get this email. I have this code to put a check box in the corner.

var inch = 72;  for(var i=0;i<this.numPages;i++){var aRect = this.getPageBox( { nPage: i} );aRect[0] += 0.5 * inch;aRect[1] -= 0.5 * inch;aRect[2] = aRect[0] + .5 * inch;aRect[3] = aRect[1] - 24; var f = this.addField("Print Checkbox,"checkbox", i, aRect)}

It keeps giving me an error.

missing ) after argument list
12:Console:Exec
undefined

This is all I have so far. The next step will be to get the box to check then open a hidden label telling them to not forget to hit the submit button on the last page. Then the last page button looping through and seeing which checkBoxes are checked and emailing me the name on the bookmark for that page. Does this sound like the best way to do something like this? I am very open to any suggestions as I am a beginner, but this sounds like the best way from my perspective. Thank you for your time and I look forward to hearing back!

MSP
MSP
Registered: Sep 16 2008
Posts: 25
Or possibly a finished button which shows hidden fields of their information so we will know who sent this to us.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You're code is missing a quote after "Print Checkbox" in the add field line,
Details are important

Very nice automation script. You might consider working out a way to add the page names as the export value for the check box. This will make collecting the information that will be emailed easier.

Your methodology sounds fine. If all you want is the names of the pages that are selected then you can use the "app.mailMsg" function.


Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

MSP
Registered: Sep 16 2008
Posts: 25
Ok I have the script to put the checkBox and a textBox in each page of the document. How do I put javascript into each checkbox which makes the text visible. This is the code I have.
var inch = 72; try{  for(var i=0;i<this.numPages;i++){var aRect = this.getPageBox( { nPage: i} );aRect[0] += .1 * inch;aRect[1] -= 28 * inch;aRect[2] = aRect[0] + 100;aRect[3] = aRect[1] - 100; var bRect = this.getPageBox( { nPage: i} );bRect[0] += 2 * inch;bRect[1] -= 29 * inch;bRect[2] = aRect[0] + 500;bRect[3] = aRect[1] - 150; var f = this.addField("Print Checkbox","checkbox", i, aRect); var j = this.addField("LblPrintInfo","text", i, bRect);j.alignment = "left";j.defaultValue = "Please go to last page to finalize print order."; var nHide = f.isBoxChecked(0)?display.visible:display.hidden; this.getField("LblPrintInfo").display = nHide;} }  catch (e){app.alert(e);}

Thank you, I really appreciate your help!

MSP
MSP
Registered: Sep 16 2008
Posts: 25
Possibly something like this??

f.setAction("MouseUp", "this.isBoxChecked(0)?j.display.visible:j.display.hidden;");
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Close, "this" refers to the document object. you want "event.target". Also "j" has no meaning outside the scope of the automation code, so it can't be used in the event code.

f.setAction("MouseUp", "this.getField('LblPrintInfo').display = event.target.isBoxChecked(0)?display.visible:display.hidden;");
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

MSP
Registered: Sep 16 2008
Posts: 25
var inch = 72; try{  for(var i=0;i<this.numPages;i++){var aRect = this.getPageBox( { nPage: i} );aRect[0] += .1 * inch;aRect[1] -= 28 * inch;aRect[2] = aRect[0] + 100;aRect[3] = aRect[1] - 100; var bRect = this.getPageBox( { nPage: i} );bRect[0] += 2 * inch;bRect[1] -= 29 * inch;bRect[2] = aRect[0] + 500;bRect[3] = aRect[1] - 150; var f = this.addField("Print Checkbox","checkbox", i, aRect);var j = this.addField("PrintButton","button", i, bRect);var buttonLink = this.addLink(i, bRect);var myRoot = this.bookmarkRoot;var myChild = myRoot.children[0]; j.display = display.hidden;j.strokeColor = color.blue;j.borderStyle = border.b;j.lineWidth = 1;j.fillColor = color.white;j.buttonSetCaption("Click Here to Finalize Print.");j.textSize = 24;j.textColor = color.red;j.textFont = font.Times; f.setAction("MouseUp", "this.getField('PrintButton').display = event.target.isBoxChecked(0)?display.visible:display.hidden");f.setAction("MouseUp", f.exportValues=["myChild.name"];);//not sure how to export the value. buttonLink.setAction("this.gotoNamedDest(this.pageNum = this.numPages);");//goto the last page } }  catch (e){app.alert(e);}

This is what I have now. I just figured out a problem though, the checkBox is carried out throughout the pdf. If I check page one then go to any other page it is also checked. This might mean we need to use another data type here. Also when I run the javascript then click on the checkBox it doesn't show it is checked until I click off of it onto another part of the page. I think this has something to do with the checkBox being highlighted. I have just now started to look at bookmark's I don't know if this is the right way to get the name of the current page's bookmark. This also ties into the exportValues in the checkBox. How do I get the exported value, do I just export it to a text file or variable within the document? Also how would I then go about collecting the exported values from the checkBoxes. Thank you so much for your help as I could not have done this without you! Thanks!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
In PDF, all fields with the same name have the same value. You need to give the check boxes and other fields all different names. Also, don't put spaces in the field names, it's bad form.

For example

var f = this.addField("PrintCheckbox" + i,"checkbox", i, aRect);
This is too many issues all at once on a single tread. You're going a bit fast. Please post each issue to a new forum thread. That makes it easier for you to get an answer and its good for everyone else who's searching for an answer on a similar topic.

You're code is pretty good so far, but you need to read some more about Acrobat JavaScript. Have you read over the Acrobat JavaScript Guide? Have you looked over the articles at JavaScript Corner? Have you check out the videos at www.pdfscripting.com? These are all great places to find general information.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

MSP
Registered: Sep 16 2008
Posts: 25
Ok, I'm sorry! How do I use ("PrintButton" + i)

f.setAction("MouseUp", "this.getField("PrintButton" + i).display = event.target.isBoxChecked(0)?display.visible:display.hidden");

The getField("PrintButton" + i) is incorrect, but that is exactly what I called it in the code previously.

MSP