Free Support Forum -

Adding checkbox to table using

hi i am trying to add check box to the table cell. I am able to added succesfully, but i am facing problem on changing border color and and other properties. below is my sample code.

       Aspose.Pdf.Forms.CheckboxField ch = new Aspose.Pdf.Forms.CheckboxField();
        Aspose.Pdf.Forms.TextBoxField txtBox = new TextBoxField();
        txtBox.Height = 20;
        txtBox.Width = 80;
        ch.Height = 20;
        ch.Width = 20;

Now how can i change the border and color of checkbox field and textbox filed both. Please reply ASAP.


Thank you for contacting support.

Would you please share complete code snippet that you are using to add a CheckBox in Table Cell, along with a PDF file to elaborate expected results, so that we may investigate it in our environment to help you out. Please ensure using Aspose.PDF for .NET 18.7 in your environment.

Moreover, please also visit Adding TextBoxField to check how border and color can be set as per your requirements.

Hi i have followed ur code,like below
Border border = new Border(textBoxField);

but while cursor comes to the above line of code its throwing error in catch block as “Holder area not set”.
Note: My requeiremnt is i have one pdf document, in that document i have table, and in table row cell, i am trying to add check box. Also today i faced one more issue like book mark is not aligned properly, some times its loading and some times i can see missing book mark title.


Thank you for elaborating it further.

Please share source PDF file along with narrowed down code snippet in its compilable and self-contained form that reproduces Holder area error and adds the checkbox in a table cell, so that we may proceed to help you out.

Regarding bookmark issue, kindly create separate topic for each issue you face while working with Aspose.PDF for .NET API because this lets us help you efficiently.

TextFragment TabHeder = new TextFragment(“Check List”);
TabHeder.IsInNewPage = true;
TabHeder.TextState.FontSize = 20;
TabHeder.TextState.FontStyle = FontStyles.Bold;
TabHeder.TextState.Underline = true;
TabHeder.HorizontalAlignment = HorizontalAlignment.Center;
TextFragment tabHeaderSpaceAfter = new TextFragment(string.Empty);

        Aspose.Pdf.Text.TextFragment fragmentLocation = new TextFragment("Inspection CheckList");
        fragmentLocation.TextState.FontSize = 24;
        fragmentLocation.TextState.FontStyle = FontStyles.Bold;

        //Creating table and adding rows

        Aspose.Pdf.Table tableCheckList = new Aspose.Pdf.Table();
        tableCheckList.DefaultCellBorder = new BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
        tableCheckList.DefaultCellPadding = new MarginInfo() { Top = 5f, Left = 5f, Bottom = 5f, Right = 3f };
        tableCheckList.DefaultCellTextState = new TextState(8);
        string completionWidth = (tablesWidth / 3).ToString();
        tableCheckList.ColumnWidths = completionWidth;
        tableCheckList.Rows[0].Cells.Add("MyItem \r\n \r\n");
        tableCheckList.Rows[0].Cells.Add("MyStatus \r\n \r\n");
        tableCheckList.Rows[0].Cells.Add("MyComments \r\n \r\n");

        Aspose.Pdf.Table tablesecondCheckList = new Aspose.Pdf.Table();
        tablesecondCheckList.DefaultCellBorder = new BorderInfo(BorderSide.All, 1F);
        tablesecondCheckList.DefaultCellPadding = new MarginInfo() { Top = 5f, Left = 5f, Bottom = 5f, Right = 3f };
        tablesecondCheckList.DefaultCellTextState = new TextState(8);
        tablesecondCheckList.ColumnWidths = (tablesWidth / 3).ToString();
        Aspose.Pdf.Forms.CheckboxField ch = new Aspose.Pdf.Forms.CheckboxField();
        Aspose.Pdf.Forms.TextBoxField txtBox = new TextBoxField();
        txtBox.Height = 15;
        txtBox.Width = 220;
        ch.Height = 20;
        ch.Width = 20;
        Cell cells = new Cell();
        Cell cells1 = new Cell();
        for (int i = 0; i < obj.Count; i++)

Question1: For the above code i am trying to add checkbox to second cell which i highlighted bold and trying to set border color of the checkbox. Please help me in that.

questioin2 : And also how can i read the data of the chexkbox and textbox field using aspose.pdf??


Your code snippet included some undefined objects and can not be compiled independently. Therefore, we have made some modifications and noticed that changing Border properties of TextBoxField or CheckBoxField results in NullReferenceException. A ticket with ID PDFNET-45142 has been logged in our issue management system for further investigation and resolution. Moreover, while devising a workaround to avoid NullReferenceException, we have saved the PDF file after adding respective form fields on a PDF document and then setting borders for the saved document. This is not working as expected and Border is only displayed on Mouse Hover in Adobe Acrobat. Therefore, another ticket with ID PDFNET-45143 has been logged for further investigation and resolution.

The ticket IDs have been linked with this thread so that you will receive notifications as soon as the tickets are resolved.

Moreover, you can read data from form fields as explained in Get Values from all the Fields of PDF Document.

We are sorry for the inconvenience.

1 Like

and also adding to that why i am not getting Aspose.Pdf.InteractiveFeatures. name space.

  1. while trying to check the checkbox value based on bool its throwing error as objectnullreferenceexception. Please find checkboxfield some properties which are showing as red cross mark. Please explain me why its showing as red cross mark. this is default behaviour checkbox property setting check and uncheck, but its not working. Very surprised.checkbox.PNG (90.9 KB)


We have been able to reproduce the issue in our environment and a ticket with ID PDFNET-45148 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

1 Like

HI today i tried to add image instead of checkbox to table cell with the below code.

Aspose.Pdf.Image ticktMark = new Aspose.Pdf.Image();

        ticktMark.File = HostingEnvironment.MapPath(@"~/Content/Images/tickmark.png"); 
        ticktMark.FixHeight = 30;
        ticktMark.FixWidth = 40;

the above line of code is executing fine but when the cursor comes to processparagrapth mehtod its throwing error as nullreference exception, can u pls let me know which object throwing null error.



We have replied to your query in another thread created by you, please follow up in respective thread. Moreover, please always share SSCCE code snippet with us so that we may reproduce your scenario exactly as it occurs in your environment.