Free Support Forum -

Question about PDF Form File

Hi all,

I have a desire to design a checkbox in PDF Form. Following subscription:

- When I click on this checkbox, I want hide/unhide a richtext which designed on my form.
- This richtext consist of the paragraphs, images,…
- After my PDF Form make hide this richtext, I want the parts which designed below this richtext move up to the above blank position.

Please recommend me a way to do this.

Many thanks for your support.

Tri Dung

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for using our product.

This can be achieved using the script on a form field to hide / unhide a textbox field but currently Aspose.Pdf for .NET does not support to add script to a checkbox field. I have created a new feature request in our issue tracking system with issue id: PDFNEWNET-34248. Our development team will further look into the details of this feature and we will keep you undated regarding any progress.

However, Aspose.Pdf for .NET does support adding the script to Push Buttons. Please see the following documentation link and see if you can utilize this feature to acquire your desired results.

Set JavaScript for Push Button (Facades)

Also, you may check the following code with script to hide / unhide using button field:

//create FormEditor object

FormEditor formEditor = new FormEditor();

formEditor.BindPdf(@"D:\AP Data\September2012\HelloWorld.pdf");

//set JavaScript

formEditor.SetFieldScript("Button1", "var field = this.getField('Text2');

if(field.display == display.visible) field.display = display.hidden;else field.display = display.visible;");

//save update document

formEditor.Save(@"D:\AP Data\September2012\HelloWorld_out.pdf");

Sorry for the inconvenience,

Hi Tri Dung,

Thanks for your patience.

We have further investigated the requirement to add JavaScript to checkbox field and have modified the SetFieldScript(…) method to support any field type. In order to fulfill your requirement, please try using following code snippet. This feature will become available from Aspose.Pdf for .NET 7.5.0.


FormEditor formEditor = new

formEditor.BindPdf("d:/pdftest/HelloWorld (1).pdf");

//set JavaScript

formEditor.SetFieldScript("CB1", "this.getField('CB1').display = display.hidden;");

//set JavaScript

formEditor.SetFieldScript("bt1", "this.getField('bt1').display = display.hidden;");

//save update document