Adding the Annotation Show Hide Action to a PDF
Adding the Annotation Show Hide Action to a PDF using DynamicPDF Core Suite is straight forward.
How to Add the Annotation Show Hide Action to PDF in C#
The following steps and code illustrates adding an Annotation Show Hide Action to a PDF document using DynamicPDF Core Suite. Use these actions to perform tasks in many places such as in outlines, links, buttons or in any Document, Page or Form Field Reader Events. You can also use these actions to show/hide a specific form field.
Steps for Adding Annotation Show Hide Action to a PDF Document
- Create a
Document
object. - Create a
Page
object and add it to the Document instance. - Create a
Button
object. - Create a
TextField
object. - Create a
AnnotationShowHideAction
object. - Associate the action to the button by setting the
Button
instance'sReaderEvents.MouseDown
event. - Add the
Button
to thePage
instance. - Save the PDF document.
Sample Code - C#
Document document = new Document();
Page page = new Page();
document.Pages.Add( page );
Button button = new Button("btn", 50, 150, 100, 30);
button.Label = "Click Here";
ceTe.DynamicPDF.PageElements.Forms.TextField field = new ceTe.DynamicPDF.PageElements.Forms.TextField("Text1", 330, 100, 100, 30);
field.DefaultValue = "Text Field Value";
AnnotationShowHideAction action = new AnnotationShowHideAction("Text1");
button.ReaderEvents.MouseDown = action;
page.Elements.Add( button );
document.Draw(@"Output.pdf");
GitHub Project
Clone or view the example project at GitHub. This example code is contained in the Examples/AnnotationsExample.cs file.
Getting Started
NuGet Package
DynamicPDF Core Suite is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET
package. The easiest way to install the package is by using the Visual Studio Package Manger. You can also download the package directly from NuGet.
DynamicPDF Core Suite Information
DynamicPDF Generator contains over 75 page elements you can use to add add rich content to the PDFs you create. DynamicPDF Core Suite includes elements to add:
- Text Objects (TextArea and Label),
- HTML,
- Barcodes (47 types),
- Form Fields,
- and Charts.
Refer to the DynamicPDF Core Suite website for more information.
Available on Other platforms
DynamicPDF Core Suite is also available for the following platforms. Refer to the respective product pages for more details.
- Java - DynamicPDF Generator for Java
- COM/ActiveX - DynamicPDF Generator for COM/ActiveX