Copy link to clipboard
Copied
Created a report with several hidden templates spawned from a dashboard page. When users begin or finish, they "save as," renaming the file. I'm trying to create a button that, among other things, would reduce file size by deleting the hidden templates but I can't find any info on something akin to a "removeTemplate" method or accessing by template name and unhiding (so I can delete via pageNum). Any ideas or solutions? Thanx in advance.
Yeah, wasn't sure about that... Unhiding them and then deleting is the last
option, then.
On Thu, Jul 7, 2016 at 10:20 PM, jotasprout <forums_noreply@adobe.com>
Copy link to clipboard
Copied
The Document object has a method with exactly that name, removeTemplate, which takes the template name as a parameter and then removes it.
Copy link to clipboard
Copied
For future reference: Doc methods
Copy link to clipboard
Copied
RTFM, right? Honest, I have my API Reference, SDK, and Object Specification open pretty much all the time. I pinky promise I would never ever bother y'all in the forums without exhausting all other sources first.
Copy link to clipboard
Copied
My apologies, I should be more specific. I want the user (who has Acrobat Pro) to execute the script via button-click. I saw the removeTemplate method in the JavaScript API, but, as it states, it only seems to work in the console. When I attach the script to a button, it doesn't do anything.
Copy link to clipboard
Copied
If you want to use it from a button then you must also install a trusted function in a folder-level script. However, I think your approach is wrong. Removing the template is not going to help you much with the file size. Instead, you're better off deleting the template page entirely. If the Template object still exist it doesn't really matter, and the deletePages method does not require a trusted context, so you can use it directly from a button (in Acrobat only, unless the pages you want to delete were spawned from a template, in which case you can also use it in Reader).
Copy link to clipboard
Copied
Exactly--I want to delete the pages themselves (which, unless I'm mistaken, also deletes the associated template) but I don't know how to refer to the pages since they're hidden templates. Must I unhide them first or could I do something like ...
this.deletePages(this.getTemplate("mytemplate").pageNum);
Copy link to clipboard
Copied
Nope, that didn't work.
Copy link to clipboard
Copied
Not 100% sure, but I believe it will work if you specify the page number as
-1.
Copy link to clipboard
Copied
I felt so stupid for not thinking of that myself that I'm actually glad it didn't work. I'm just going to try unhiding them and deleting the last few pages of the doc (since they'll manifest at the end ... if we can say "spawn," I can say "manifest").
Thanks for all your help today.
Copy link to clipboard
Copied
Yeah, wasn't sure about that... Unhiding them and then deleting is the last
option, then.
On Thu, Jul 7, 2016 at 10:20 PM, jotasprout <forums_noreply@adobe.com>
Copy link to clipboard
Copied
And that worked beautifully.
Copy link to clipboard
Copied
Note that the doc.removeTemplate method isn't available with Reader, and with Acrobat it's restricted to privileged context. The hidden property of a template object isn't controllable with Reader either.
Copy link to clipboard
Copied
(in Acrobat only, unless the pages you want to delete were spawned from a template, in which case you can also use it in Reader).
Yes but… This is available for Adobe Reader XI (11) and Acrobat Reader DC only, not in older versions.
jotasprout this may be the cause of your issue?
Copy link to clipboard
Copied
No, I'm using Acrobat Pro DC and my client will be using Acrobat Pro XI so that wouldn't be an issue.