• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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 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.

 

 

 

TOPICS
Acrobat SDK and JavaScript

Views

12.9K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 18, 2020 Sep 18, 2020

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

Votes

Translate

Translate
Community Expert ,
Sep 18, 2020 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

Votes

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
community guidelines
Community Beginner ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

UCK! But thanks a lot nonetheless.

Votes

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
community guidelines
New Here ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

LATEST

Well, I ran into the same issue and I am not about to try and add a script (totaly out of my capabilities on the computer).  So, had to print to PDF each page and save them as individual files.  It may not be the best solution, but it worked for me.  Adobe needs to remidy this problem.

Votes

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
community guidelines