This bugreport consists of 3 issues:
1. The CheckBoxField does not create correct borders.
2.When modifying an existing checkbox in a document, and setting border, the 'checkmark' gets wrong size. When clicking the checkbox on/off, the 'checkmark' has alternating size
2.When modifying an existing checkbox in a document, and setting border, the 'checkmark' gets wrong size. When clicking the checkbox on/off, the 'checkmark' has alternating size
3. Setting Style of Checkbox does not work.
I.E: Make the checkbox have a cross instead of a checkmark
Demo-code :
Aspose.Pdf.Document doc=new Aspose.Pdf.Document();
Page p1=doc.Pages.Add();
//tbl to keep the checkboxes in
Table tbl=new Table();
tbl.ColumnWidths = "100";
var r1 = tbl.Rows.Add();
var cell1 = r1.Cells.Add();
var cell2 = r1.Cells.Add();
p1.Paragraphs.Add(tbl);
//1. Create checkbox, set style & border, set it checked
CheckboxField cbf1=new CheckboxField(p1,new Aspose.Pdf.Rectangle(0,0,0,0));
//does not work to make the checkbox have a cross instead of a checkmark
cbf1.Style = BoxStyle.Square;
cbf1.Style = BoxStyle.Cross;
cbf1.PartialName = "cbf_1";
cbf1.Width = 20;
cbf1.Height = 20;
cbf1.Border=new Border(cbf1);
cbf1.Border.Width = 2;
cbf1.Border.Style= BorderStyle.Solid;
cbf1.Checked = true;
cell1.Paragraphs.Add(cbf1);
//1.Create checkbox, set style & border, set it checked
//2.Emulate a save
//3.Modify border
CheckboxField cbf2 = new CheckboxField(p1, new Aspose.Pdf.Rectangle(0, 0, 0, 0));
cbf2.Style = BoxStyle.Square;
cbf2.Style = BoxStyle.Cross;
cbf2.PartialName = "cbf_2";
cbf2.Width = 20;
cbf2.Height = 20;
cbf2.Border = new Border(cbf2);
cbf2.Border.Width = 2;
cbf2.Border.Style = BorderStyle.Solid;
cbf2.Checked = true;
cell2.Paragraphs.Add(cbf2);
//Emulate save
using (MemoryStream ms = new MemoryStream())
{
doc.Save(ms);
}
//Change border width
doc.Form["cbf_2"].Border.Width = 4;
//Does not work correctly, causes checkbox to alternate between cross and checkmark
cbf2.Style = BoxStyle.Square;
cbf2.Style = BoxStyle.Cross;
doc.Save(@"..\..\output\demo.pdf");
System.Diagnostics.Process.Start(@"..\..\output\demo.pdf");
See attached image in order to see the appearance of the checkboxes in different states