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

Acrobat Form Print original and copy on button

New Here ,
Jan 24, 2020 Jan 24, 2020

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

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;

 

 

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

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

 

 

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

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.

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

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?

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

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

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

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. 

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

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?

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

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

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

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

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

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

That works perfectly. Thank you once again. 

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