Copy link to clipboard
Copied
I'm trying to understand how templates work in pdf forms.
The tests show that the template created on the basis of the page exists only together with the page on the basis of which it was created.
For example, I created a document whose page 2 (empty without any texts or controls) served as a template to create a template :-).
I created a template from the console level and everything is OK. I can add it "spawn" with a script any number of times to the document, I can do something with scripts on these new pages. But if I delete page 2 right after creating the template, the template is automatically deleted as well. What am I doing wrong?
Copy link to clipboard
Copied
When you use page 2 as template page don't delete page 2. Page 2 is the template page.
Copy link to clipboard
Copied
Hmm, that's a bit of a problem. I can't add a blank page from within the script. I also cannot manipulate static content (plain text) from within the script. I can't hide the page that is the basis of the template (I'm wrong?).
So how to create a document, a perfect example is an invoice, where I have some header part with static elements, a table with a variable number of rows, maybe on many pages, with details about the invoice items, then I have another small table summarizing the amounts, and a footer of the document ( not to be confused with the footer of the page) in which I also have static texts and dynamically calculated fields and e.g. QR codes for bank payments?
So is it even possible to do it using scripts and Adobe DC or Adobe Pro?
And all I want is how to add a blank page from the script...
Copy link to clipboard
Copied
You can hide the template page.
Copy link to clipboard
Copied
Will you reveal the secret how to do it?
After creating the template it has the hidden attribute but the page is visible. My question is the most serious.
Copy link to clipboard
Copied
How does you create the template page?
Copy link to clipboard
Copied
From the console with the command:
this.createTemplate({cName: "PustaStrona", nPage: 1});
Where page with index 1 (i.e. no. 2 in the document is empty).
When I execute the script (from the manual):
var t = this.templates;
for ( var i=0; i < t.length; i++){
var state = (t[i].hidden) ? "visible" : "hidden"
console.println("Template: \"" + t[i].name
+ "\", current state: " + state);
}
I get the result
Template: "PustaStrona", current state: hidden
true
Copy link to clipboard
Copied
The line
var state = (t[i].hidden) ? "visible" : "hidden"
is not correct.
Copy link to clipboard
Copied
Page 259 of the "JavaScript for Acrobat API Reference" manual ...
OK, but that doesn't really matter what the problem is.
Copy link to clipboard
Copied
It does, because you're reporting it incorrectly. It should be:
var state = (t[i].hidden) ? "hidden" : "visible";
Copy link to clipboard
Copied
The script in the API Reference is wrong.
The property hidden of your template page is not set to true.
Copy link to clipboard
Copied
OK trivial, I was so suggested by your entries that I expected some magic š and here one line and it's done!
Copy link to clipboard
Copied
Is this an LCD form? If so, you should ask here:
Copy link to clipboard
Copied
What is LCD form?
This is a regular form created with Adobe Acrobat Pro if that's what you're asking.
Copy link to clipboard
Copied
There are two types of PDF forms (well, more actually). They have different JavaScript APIs.
- Acrobat forms (also Acroform)
- XFA forms (also Designer forms, AEM forms, XML forms, LiveCycle Designer forms, LCD forms)
Many people don't notice the "V" in LiVeCycle and call them LifeCycle forms. Hence the need to clarify.
Copy link to clipboard
Copied
Your title threw me off. If this is a form created in Acrobat then we can move on.