Copy link to clipboard
Copied
Hello Everybody,
I’m new on the forum, so please be gentle if I have novice questions. I’m a graphic designer with a very limited (if any) programmer skills.
I hope you can help me to find the solution for this Acrobat Javascript task. I have a pdf (this is the default one) and I need selected pages to link at the end of the this pdf. I mean there are about 10 checkboxes and the selected ones should link to the pdf (and also if it unselected should be dissapear again).
The show/hide pages would be nice, but as I know it doesn’t exist in Acrobat.
So my first questions are should I use
– Page Templates,
– Attachments (if it’s possible to link it to the same pdf) or
– Layers?
I tried the first one, so I made the Page Templates. It would be nice if we can have multiple pages in one Page Templates, but I suspect it doesn’t work.
So I have these lines to add my two pages and it works fine:
this.spawnPageFromTemplate(“Plan-A1”);
this.spawnPageFromTemplate(“Plan-A2”);
Is it possible to delete these spawned pages (with Radio Button, unselected Checkbox) if we don”t need them.
I mean can we specify to delete this and that Page Templates or we can use only page numbers to specify a page to delete?
Thank you for any help.
Cheers,
Peter
Copy link to clipboard
Copied
You can use Templates or Attachments for that. Yes, you can use a link to point to an attached file. If that serves your purpose I would recommend you do that, as it's much easier than using Templates.
Regarding that: You have a couple of errors in your code. One, you're using the wrong kind of quotes. You must only use straight quotes, like this " " or ' ', not curly ones, like this “ ”. Two, you're using a deprecated method to spawn the pages.
spawnPageFromTemplate has been replaced by the spawn method of the Template object itself. You should use that instead.
Deleting spawned pages can be done using the deletePages command. And not, you can't tell it something like "delete all the spawned page from Template "Plan-A1". You have to specify the actual page numbers.
There are a lot more possible issues with spawned pages, especially if they contain form fields.
Copy link to clipboard
Copied
Thank you very much for your answer and sorry for my late reply.
My first ideas with "layers" and "attachments" don't work for me this time, because we have different page numbers for different links and also the "attachments" open as a new file, not as the part of the basic pdf. So I skipped these.
With "page templates" works fine, but it would be great if I can specify the page templates what I wanted to delete. Delete to specify the page number also doesn't work, because I don't know what order the user attached the links (some of them is 2, 3 or 4 pages). So I should delete all the spawned pages, but it'll be fine for me.
Because I want that the user can attach the links only once, I'm looking for a (better) solution too. Mine is this (after spawned the pages):
this.getField("button").display = display.hidden;
As I know there is also a possibility to disable a button after the first click or just use some "once" command, but I'm not clever enough. Is there any command line for these?
“There are a lot more possible issues with spawned pages, especially if they contain form fields.”
What do you mean by that?
Thank you.
Copy link to clipboard
Copied
I use to work with spawned pages, the main tip is: don't care about the number of the page to delete, delete all spawned pages and re-spawn those who must not be deleted.
It doesn't take longer to execute, even in a doc containing 174 template pages, and it's really easier to manage.
Beware that Acrobat Reader can delete spawned pages only, not "real" pages (unlike Acrobat Pro and Standard).
"The show/hide pages would be nice, but as I know it doesn’t exist in Acrobat."
Acrobat Pro and Acrobat Standard can show/hide template pages.
Copy link to clipboard
Copied
That means you will lose all the data on those pages, though...