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

Adding Instance Number

libraboy
Registered: Dec 14 2007
Posts: 94
Answered

Hi,

I have 3 page of document, page 1 & 3 are static pages and page 2 is dynamic page, all pages with the number of pages. How can I create a blank text field in page 1 counting pages for page 2.?

Example: Every you add page in page 2... Text field in page 1 is counting every form you adding.

Please help me....

Thanks

My Product Information:
LiveCycle Designer, Windows
mingdichen
Registered: Jan 7 2010
Posts: 29
I think the pdf needs to be dynamic. I don't know how you can set certain page as static and other pages are dynamic.

I had a dynamic file and use
Page1.occur.max (5);
Page1.instanceManage.addInstance(1);
to add max 5 pages.

This problem I have is after adding the pages and saved the fiel, once I re-open the file, the added pages are not there.

Maybe, you can try my code in the Click event of the button and let me know your result.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The PDF will of course need to be dynamic. The subform for Page 2 will need to be made repeatable.

But to add page numbers. Look in the "Custom" library tab. There you will find a "Page n of m" component.

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/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

mingdichen
Registered: Jan 7 2010
Posts: 29
The page which has the Add button on is repeatable already. I can use Add button to add more pages successfully and save it under a new name. But, when I reopen it, it only has original 3 pages. All the pages I added are not there.

Any other ideas? Can I email my file to you?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
A dynamic for automatically creates the repeated subforms it needs to match the data in the data model. If you haven't saved any data in the created subforms it won't keep them around.

There are a couple of solutions.

1. Automatically fill in some data.
2. On the "File > Form Properties" dialog select the "Defaults" tab. Check "Automatic" under the "Preserve Scripting Changes to Form when Saved" section.If this doesn't work I'll take a look at the form.

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/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

libraboy
Registered: Dec 14 2007
Posts: 94
This doesn't help me at all.. The custom library when I inserted sheet n of m is counting every pages. Page 2 is a repeated form and I want to create a text field in page 1 so everytime I add more pages using page 2 that text field in page 1 is counting. Any idea? I will email you the file if you want.

thanks for your help!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So you want to display the number of instances on page 1? That's simple. If your repeatable subform was called "Page2", then the number of instances is:

_Page2.count

Place this code into the calculation event of a text field.

Have you seen this video? It discussed many of these issues.
https://admin.adobe.acrobat.com/_a200985228/p87746471/

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/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

mingdichen
Registered: Jan 7 2010
Posts: 29
It seems still not working. Do you mind if I email it to you?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Post it to Acrobat.com and then put the link on your response.

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/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

mingdichen
Registered: Jan 7 2010
Posts: 29
Here is the link:https://acrobat.com/#d=renA7rjlsvDnagK5nDEeHA
mingdichen
Registered: Jan 7 2010
Posts: 29
Thom,

thank you for any suggestion. I wrote up a reply in detail but the forum blocked me since less than 10 times posts.

I am also using your 15 min increment method to calculate hours. But, it seems it gives me problem from time to time.

For example, 07:00 to 07:30, sometime it gives me 0.75 hours. And, I found the sTime.valueOf() and eTime.valueOf() calculation is not always the same. It ends up with additional 16 miliseconds, and it round up to another 0.25 hours.

Any idea??

Here are the Codes:

var Msg = "Ending time is earlier than Starting time."
var stime = In3.rawValue;
var etime = Out3.rawValue;

if(stime != null && etime != null) {
var oStime = util.scand("HH:MM", "1/1/1970" + stime);
var oEtime = util.scand("HH:MM", "1/1/1970" + etime);
var fStime = oStime.valueOf();
var fEtime = oEtime.valueOf();
var diff = fEtime - fStime;
}
var fSecd = diff / 1000;
var fMin = fSecd /60;
var fHr = fMin /60;
var DecHours = Math.ceil((fHr -Math.floor(fHr))/.25)*.25;
var DiffHours = Math.floor(fHr) + DecHours;


if(diff<=0.)
{
app.alert(Msg);
xfa.host.setFocus(In3);
}
else this.rawValue = DiffHours;
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Did you make the file publically accessible?

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

libraboy
Registered: Dec 14 2007
Posts: 94
Hi Thom,

Still not working :( Can you please check my file

https://acrobat.com/#d=d5YOmZyZp1MU408V3s-R*Q

The should be in page 1 on the bottom page part.

Called
How many positions are required to deliver the outputs defined in the Needs section above?

thanks
mingdichen
Registered: Jan 7 2010
Posts: 29
Thom,

Sorry about the delay, now the file is set correctly for you to review. Here is the link:

https://acrobat.com/#d=renA7rjlsvDnagK5nDEeHA
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
mingdichen,
Very strange, either your form is not saving data or it is constantly being reset. I can export data out of the form, but importing doesn't work. It's a very big and busy form. At what point did you discover that it was not saving data? Has it ever worked? I would suggest Starting with a blank form and copy pieces one at a time from the current form. Test at each stage to make sure data can be saved and restored. I would also suggest that you organize the form fields on each page into subforms so the hierarchy is easier to navigate.


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/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
libraboy,
I added a text field to the first page of your form and place this script in the calculation event:

_Page2.count;

It shows the number of page 2 instances just like I said it would in a previous post.

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/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

libraboy
Registered: Dec 14 2007
Posts: 94
Hi Thomp,

it works.... :) Thanks for your big help

Thanks so much!
mingdichen
Registered: Jan 7 2010
Posts: 29
Thom,

Thank you for your advise. I need to rework it over again. The form was save in Static form first, as a second version, I then saved it in dynamic form to give user more flexiblities. But, it does not work so I need to retrace back to earlier day to see what happened.

I will keep you posted. Thank you for your time and efforts.