Skip to main content
Participant
April 24, 2019
Question

Help: need to send only selected pages via email using java script

  • April 24, 2019
  • 4 replies
  • 2783 views

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

This topic has been closed for replies.

4 replies

Legend
April 25, 2019

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.

Participant
April 25, 2019

how can I change the code and "Extract all pages. Then use oNewDoc.deletePages." ?

try67
Community Expert
Community Expert
April 25, 2019

Pro tip: When deleting pages from a file in batch, do so from the last one to the first.

Participant
April 25, 2019

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.split("@").shift() + "_1040.pdf";

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

Legend
April 25, 2019

Extract all pages. Then use oNewDoc.deletePages.

try67
Community Expert
Community Expert
April 24, 2019

The easier way would be to delete the pages you don't want to submit, submit the file, and then close it without saving.

Participant
April 24, 2019

I need a code to do it since the form will be used by different people in my organization.

try67
Community Expert
Community Expert
April 24, 2019

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.