We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to Add a button dynmaically to pdf but this button should not print

Hi ,

We have a requirement where we need to add the button dynamically on pdf. But we dont want to see this button when somebody takes a printout. Here is the Code

Aspose.Pdf.Facades.FormEditor frm = new Aspose.Pdf.Facades.FormEditor(d);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

float lft = (float)d.PageInfo.Width / 2;

frm.AddSubmitBtn("btnSubmit", d.Pages.Count, "Save", "url for page", lft, 730, (lft + 50), 750);

Please find the attached document with button.<o:p></o:p>

So can some one guide how to make the button invisible during print.

Hi Vinay,

Thanks for contacting support.

Please try using the following code snippet to accomplish your requirements. For your reference, I have also attached the resultant PDF generated over my end.


Document doc = new Document();<o:p></o:p>

// add page to pages collection of PDF document


// create Button Field instance

Aspose.Pdf.InteractiveFeatures.Forms.ButtonField button = new ButtonField(doc.Pages[1], new Aspose.Pdf.Rectangle(50, 600, 250, 650));

// display Button over PDF file but do not print it

button.Flags = AnnotationFlags.Default;

button.Name = "Button 1";

// caption of button

button.Value = "Button 1";

// add button to forms collection of PDF file


// save PDF document