Highlighted

Use a button to extract pages from a pdf and give the new file a name based on a blank in the pdf

Community Beginner ,
Sep 18, 2020

Copy link to clipboard

Copied

I have a multiple forms combined into  one large PDF.  The forms are related, but each  relates to a different situation/case.

I would like to bave a button on each form so that I could, if needed,  extract it from the larger pdf.

I am just getting started and have used this JS---- 

this.extractPages(0,5);  or  this.extractPages({nStart:5});

This  opens a file containing the extracted pages in a new window. The  file name is Acr( followed by numberical gibberish).temp. I can  then   save and rename that file.

Is it possible to have the temp file be automatically given a specified name that is compposed of the names from two blanks in the form?  For example, if the extraced portion dealt with Mr. Jones's 6th case,  the extracted file would be named --Jones6.pdf. or Jones6.temp, or whatever. Then I oculd just save and it would be over. I have Adobe acrobat Pro DC. I think that someone using the form with Acrobat REader would not be able to do this. For what it's worth this JS produces an acceptable file name when run in the console.

this.getField("Global.Def.Name.Company").valueAsString+"_"+this.getField("P1.Case.CaseNum").valueAsString+".pdf"

Thank you in adavance.

 

ONE QUESTION MORE, OR MAYBE ONE TOO MANY--

 

I have gotten a JS that, using the console, will extract the desired pages, create a PDF, give it a predetermined fixed name(TestExtract1.pdf),  and place that PDF in the same folder as the larger PDF.----

this.extractPages({nStart:0, cPath: "TestExtract1.pdf"});

or

this.extractPages(0, 0, "TestExtract1.pdf");

(see: https://acrobatusers.com/tutorials/extracting-pages-pdf-acrobat-javascript/

 

 

However, I have not been able to get this script to work from a button in the PDF. I get this message:

RangeError: Invalid argument value. Doc.extractPages:1:Field Save a Page(s):Mouse Up

If it helps the  line of JS was the top line in action blank, the name of the button was"Save a Page(s)", and the  trigger was Mouse Up.

 

It would be great if I could not only use a button to save the extraction to the same folder as the main PDF, but have it be named Jones6.pdf.

 

Again,  thank you, thnk you in advance for your help.

 

 

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Doing so requires installing a script on the local machine of each computer that will use this file, and of course none of it is going to work in Reader, only Acrobat. See these tutorials for more information:

https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts

https://acrobatusers.com/tutorials/using_trusted_functions

TOPICS
Acrobat SDK and JavaScript

Views

87

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Use a button to extract pages from a pdf and give the new file a name based on a blank in the pdf

Community Beginner ,
Sep 18, 2020

Copy link to clipboard

Copied

I have a multiple forms combined into  one large PDF.  The forms are related, but each  relates to a different situation/case.

I would like to bave a button on each form so that I could, if needed,  extract it from the larger pdf.

I am just getting started and have used this JS---- 

this.extractPages(0,5);  or  this.extractPages({nStart:5});

This  opens a file containing the extracted pages in a new window. The  file name is Acr( followed by numberical gibberish).temp. I can  then   save and rename that file.

Is it possible to have the temp file be automatically given a specified name that is compposed of the names from two blanks in the form?  For example, if the extraced portion dealt with Mr. Jones's 6th case,  the extracted file would be named --Jones6.pdf. or Jones6.temp, or whatever. Then I oculd just save and it would be over. I have Adobe acrobat Pro DC. I think that someone using the form with Acrobat REader would not be able to do this. For what it's worth this JS produces an acceptable file name when run in the console.

this.getField("Global.Def.Name.Company").valueAsString+"_"+this.getField("P1.Case.CaseNum").valueAsString+".pdf"

Thank you in adavance.

 

ONE QUESTION MORE, OR MAYBE ONE TOO MANY--

 

I have gotten a JS that, using the console, will extract the desired pages, create a PDF, give it a predetermined fixed name(TestExtract1.pdf),  and place that PDF in the same folder as the larger PDF.----

this.extractPages({nStart:0, cPath: "TestExtract1.pdf"});

or

this.extractPages(0, 0, "TestExtract1.pdf");

(see: https://acrobatusers.com/tutorials/extracting-pages-pdf-acrobat-javascript/

 

 

However, I have not been able to get this script to work from a button in the PDF. I get this message:

RangeError: Invalid argument value. Doc.extractPages:1:Field Save a Page(s):Mouse Up

If it helps the  line of JS was the top line in action blank, the name of the button was"Save a Page(s)", and the  trigger was Mouse Up.

 

It would be great if I could not only use a button to save the extraction to the same folder as the main PDF, but have it be named Jones6.pdf.

 

Again,  thank you, thnk you in advance for your help.

 

 

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Doing so requires installing a script on the local machine of each computer that will use this file, and of course none of it is going to work in Reader, only Acrobat. See these tutorials for more information:

https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts

https://acrobatusers.com/tutorials/using_trusted_functions

TOPICS
Acrobat SDK and JavaScript

Views

88

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 18, 2020 0
Most Valuable Participant ,
Sep 18, 2020

Copy link to clipboard

Copied

Doing so requires installing a script on the local machine of each computer that will use this file, and of course none of it is going to work in Reader, only Acrobat. See these tutorials for more information:

https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts

https://acrobatusers.com/tutorials/using_trusted_functions

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 18, 2020 0
KYJud LATEST
Community Beginner ,
Sep 18, 2020

Copy link to clipboard

Copied

UCK! But thanks a lot nonetheless.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 18, 2020 0