Hello,
Thank you for contacting, below are my answers to your questions.
1. I reproduced that setting checkboxField.font didn't make the correct display effect. This issue has been logged into our bug tracking system with the ticket SPIREPDF-4736. Our Dev team will further investigate and fix it. Once there is any update, we will let you know. Sorry for the inconvenience caused.
2. Our Spire.PDF supports adding action. You can refer to the following sample code to have a try. If there is any question, please share us with your input PDF file as well as your desired output effect for a further investigation.
- Code: Select all
//Load your existing pdf
string input = @"input.pdf";
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(input);
pdf.AllowCreateForm = (pdf.Form == null) ? true : false;
//Get the first page
PdfPageBase page = pdf.Pages[0];
//Create a textbox field
float x = 100;
float y = 100;
PdfTextBoxField textbox = new PdfTextBoxField(page, "TextBox");
textbox.Bounds = new RectangleF(x, y, 100, 20);
textbox.BorderWidth = 0.75f;
pdf.Form.Fields.Add(textbox);
//Create a checkbox field
PdfCheckBoxField checkboxField = new PdfCheckBoxField(pdf.Pages[0], "checkbox1");
float checkboxWidth = 15;
float checkboxHeight = 15;
checkboxField.Bounds = new RectangleF(60, 100, checkboxWidth, checkboxHeight);
checkboxField.BorderWidth = 0.75f;
pdf.Form.Fields.Add(checkboxField);
//Add action
string script = "var time = Date.now();var d = new Date(time);this.getField(\"TextBox\").value=d;";
PdfJavaScriptAction action = new PdfJavaScriptAction(script);
checkboxField.Actions.KeyPressed = action;
pdf.SaveToFile(@"result.pdf", Spire.Pdf.FileFormat.PDF);
Sincerely,
Lisa
E-iceblue support team