Help: need to send only selected pages via email using java script
Copy link to clipboard
Copied
Hi all,
i need to send via email only selected pages of a 86 pages PDF form. How can I do it with Java?
I tried different approaches such as bulding a code for extracting and sending but I am able to exctract only a range of page and not selected pages.
I need to send page 0 and this.numpage in the form
thanks
Copy link to clipboard
Copied
The easier way would be to delete the pages you don't want to submit, submit the file, and then close it without saving.
Copy link to clipboard
Copied
I need a code to do it since the form will be used by different people in my organization.
Copy link to clipboard
Copied
A script has no way of knowing which pages you've selected, unless you select them by ticking a check-box that's on them, or entering the page numbers into an alert window, or something like that.
Copy link to clipboard
Copied
You might also need to know that everyone using this form must be using their own copy of Acrobat Pro.
Please don't say "I need a code" - we might understand that as meaning you want us to do your work for you. Better to say "I need help to learn how to write code to...".
Copy link to clipboard
Copied
I am sorry you felt this way. It was definitely not my intention. I meant "in order to automatize the form I need a code".
I am not asking anzìyone to work for me. I only ask if someone with more experience has solution to this problem. But probably is not possible
Copy link to clipboard
Copied
You need to better explain how you want it to work, and then we could let you know if it's possible or not. So far you haven't specified how the user is selecting the pages.
Copy link to clipboard
Copied
Try67 already provided the solution. Just delete the page not needed before the send. It's also possible to create a new document with the needed pages, using the "doc.insertPages()" function. So, what is needed now is a clear set of rules for selecting the pages. In your first post you indicated that there would only be 2, the first page and the current page. Is this correct? If so then the solution is fairly simple.
Also, deleting, creating new documents, and inserting pages are all operations that cannot be done from Reader. As TestScreen said, the users will need Acrobat Pro or Standard. The method I mentioned that creates a new document and inserts the needed pages will only work from a privileged context, so it can't be done from a button on a PDF.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thank you all for helping. I am using the below code :
var aEmailList = ["email address"];
for(var i=0,j=0; i<this.numPages; i+=4,j++) {
var oNewDoc = this.extractPages({nStart: i, nEnd: i + 3});
var cFlName = aEmailList
oNewDoc.mailDoc(false, aEmailList
oNewDoc.closeDoc(true);}
it extract only the first 4 pages and then it creates the email with attached those 4 pages.
How can I only extract page 0 and this.numpage and send this 2?
thanks
Copy link to clipboard
Copied
Extract all pages. Then use oNewDoc.deletePages.
Copy link to clipboard
Copied
how can I change the code and "Extract all pages. Then use oNewDoc.deletePages." ?
Copy link to clipboard
Copied
Pro tip: When deleting pages from a file in batch, do so from the last one to the first.
Copy link to clipboard
Copied
1. Look up document.deletePages in the JavaScript API to discover how it is used.
2. Work out the deletePages line you need
3. Add the line after the extractPages line.
4. Test.
5. Observe error messages.
6. Fix and retry.
If you get stuck on step 2, please show us what you have.
If you get stuck on step 6, please tell us any error messages and show us what you have.

