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

Script to "save as" certain pages or print as PDF in a form

New Here ,
May 31, 2022 May 31, 2022

Hello

 

I've created a 4 pages form with acrobat pro DC and this form has two different users.

 

The "first-level" user will fill some fields and after that (with many readonly fields enabled and some other hidden), that user will send the edited form to a "second-level" user. This second and last user only has to fill the page number 2 using Acrobat Reader.

 

Once he clicks on a "submit" button, we would like to generate a readonly pdf file with all the pages except the page number 2 (the page number 1 if counting zero-based)

 

As the extraction is not an option, I have tried to make a script using app.execMenuItem("SaveAs") and also tried printing as pdf but I have issues in both cases:

 

- Is there a way to use the "save as" method which saves all pages except page 2?

If so is possible to only flatten that copy? I want the original form as it was.

Is there a way to edit that new copy before generate it? I would like to hide some fields on that new copy.

 

- The second option I tried only works if the virtual pdf printer isis set as default, otherwhise will be printed with the OS default printer. It would be awesome if there was an option that detects the a virtual PDF printer of the computer.

 

Thanks

TOPICS
Create PDFs , JavaScript , PDF forms , Print and prepress
1.7K
Translate
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 Expert ,
May 31, 2022 May 31, 2022

Your questions were already answered in another thread. It's not possible to do that. To summarize:

- Save As only saves the entire file, not part of it.

- If the user has the "Adobe PDF" virtual printer it means they have Acrobat, in which case all of the above is not necessary, as you can just extract the pages directly.

You can check which printers the user has installed by looking at the contents of the app.printerNames array, but  you can't know which one of them is the default one, or a virtual one. And even if you could, you can't specify a file-name when printing to it. The user would have to do that manually.

Translate
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 ,
May 31, 2022 May 31, 2022

Yes I asked the same already but the post was mixed with an old one so I decided to create a new one.

 

Ok is there by any chance a printParam() for choosing which printer I want to use before setting the name of the printer without the other parameters like pages, margins, etc?

 

I really need a solution...

Translate
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 Expert ,
May 31, 2022 May 31, 2022

I don't understand what you mean... You can set the printerName property of a PrintParams object, yes. It has to be one of the values from the printerNames array. You don't have to set any other property in it, if you don't want to, but then the default values will be used.

Translate
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 ,
May 31, 2022 May 31, 2022

When I click on "submit" it prints as PDF but when I open the new file, it's printed vertically, how can I rotare it horizontally before printing it?

 

I attached two scrennshots:

- "editing.png" the form when I'm working on it, horizontal (as I want it)

- "printed.png" screenshot once it has been printed (but vertically)

 

I've cheked the Acrobat SDK documentation but no info about it. I've tried with nUpAutoRotate = true;

pp.nUpNumPagesV = 3;

pp.nUpNumPagesH = 3;

 

But none worked.

 

Here is the code:

 

this.getField("Finalitzar_B").display = display.hidden;
this.getField("Reset_B").display = display.hidden;
this.getField("Calcular_B").display = display.hidden;

 

var pp = this.getPrintParams();

pp.printRange = [[0,0],[2,3]]; // print pages
pp.interactive = pp.constants.interactionLevel.silent;
pp.nUpNumPagesV = 3;
pp.nUpAutoRotate = true;

this.print(pp);

 

this.getField("Finalitzar_B").display = display.visible;
this.getField("Reset_B").display = display.visible;
this.getField("Calcular_B").display = display.visible;

 

Thank you again

(the first and last three lines are for hidding submit button and other buttons).

Translate
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 Expert ,
May 31, 2022 May 31, 2022

Don't turn on the Auto Rotate option, perhaps...

Translate
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 ,
May 31, 2022 May 31, 2022
LATEST

I tried with pp.nUpAutoRotate = false; but no worked

Translate
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