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

Acrobat Form Print original and copy on button

New Here ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

Hi, 

I have been struggeling with a way to get a form button to create two printouts. One as the form looks orginally and one with a COPY stamp/watermark on it. I have not gotten any script to work. 

 

Is this possible and if it is how do i do it?

 

Hope you guys can point me in the right direction

TOPICS
Acrobat SDK and JavaScript

Views

496

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 2 Correct answers

Community Expert , Jan 24, 2020 Jan 24, 2020

First, use the built-in Add Watemark command to create this watermark. Then, run this code to hide it from the JS Console:

this.getOCGs()[0].state=false;

 

Now, create your print button and use the following code as it's MouseUp action:

this.print();
this.getOCGs()[0].state=true;
this.print();
this.getOCGs()[0].state=false;

 

 

Votes

Translate

Translate
Community Expert , Jan 24, 2020 Jan 24, 2020

The same is happening to me... Maybe using this watermark is not the best option. It seems to be a bit problematic. You can remove it and use a button field, instead. Make the fill color transparent and set its label to "COPY". Then set its appearance to hidden and adjust the print code to the following (let's say the button is called "COPY"):

 

this.print();
this.getField("COPY").display = display.visible;
this.print();
this.getField("COPY").display = display.hidden;

 

That way you won't need to a

...

Votes

Translate

Translate
Community Expert ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

First, use the built-in Add Watemark command to create this watermark. Then, run this code to hide it from the JS Console:

this.getOCGs()[0].state=false;

 

Now, create your print button and use the following code as it's MouseUp action:

this.print();
this.getOCGs()[0].state=true;
this.print();
this.getOCGs()[0].state=false;

 

 

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 Expert ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

PS. You might also want to add the first line of code as a doc-level script, to prevent the watermark from appearing when the file is first opened, since you can't change its initState property because it's a special OCG.

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 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

You sir are a magician, thank you. 

 

Now i see it working it would be great if it could print directly instead of opening the print dialog. Is this possible?

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 Expert ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

To do that you would need to install a script on the local machine of each user.

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 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

Okay, that could be an option in the future to explore.  Thank you for the reply

 

It seems that when i re-open the this.getOCGs()[0].state=false; as a document level scipt but for some reason it will not activate when i re-open the form. 

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 Expert ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

What do you mean? Does it show the watermark when you open the file, even though you added the script? Where did you place it, exactly?

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 Expert ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

The same is happening to me... Maybe using this watermark is not the best option. It seems to be a bit problematic. You can remove it and use a button field, instead. Make the fill color transparent and set its label to "COPY". Then set its appearance to hidden and adjust the print code to the following (let's say the button is called "COPY"):

 

this.print();
this.getField("COPY").display = display.visible;
this.print();
this.getField("COPY").display = display.hidden;

 

That way you won't need to add any additional code to hide it when the file is opened.

Oh, and you can duplicate the button to all pages by right-clicking it (in Prepare Form mode) and selecting Duplicate Across Pages.

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 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

Yes exactly still showing on startup

 

Java tools - Document javascripts - New with the name hide and script this.getOCGs()[0].state=false;hide watermark.PNG

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 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

Didnt catch your post earlier, will give that a try.

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 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

LATEST

That works perfectly. Thank you once again. 

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