I'm unable to send over checkbox data to a new file. I can start with a blank pdf, save a form style checkbox that is checked. Save it as a doc or xps and neither will bring over the value. If I use adobe reader and check the box and print to xps, it works fine. I'm in an evaluation of this product, and without the ability to check a box on a form and print it to an xps format, I will not be able to go any farther.
PdfDocument doc = new PdfDocument("Blank.pdf");
PdfPageBase page = doc.Pages[0];
doc.AllowCreateForm = (doc.Form == null);
{
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 13f);
PdfBrush brush = PdfBrushes.Black;
float x = 10;
float y = 10;
float tempX = 0;
float tempY = 0;
string text = "Textbox: ";
page.Canvas.DrawString(text, font, brush, x, y);
tempX = font.MeasureString(text).Width + 15;
tempY = font.MeasureString(text).Height + 15;
PdfTextBoxField textbox = new PdfTextBoxField(page, "TextBox");
textbox.Bounds = new RectangleF(tempX, y, tempX * 2, 15);
textbox.BorderWidth = 0.75f;
textbox.BorderStyle = PdfBorderStyle.Solid;
textbox.Text = "Hello";
doc.Form.Fields.Add(textbox);
text = "Checkbox: ";
y += tempY;
page.Canvas.DrawString(text, font, brush, x, y);
tempX = font.MeasureString(text).Width + 15;
tempY = font.MeasureString(text).Height + 15;
PdfCheckBoxField checkbox = new PdfCheckBoxField(page, "CheckBox");
checkbox.Bounds = new RectangleF(tempX, y, 15, 15);
checkbox.BorderWidth = 0.75f;
checkbox.Style = PdfCheckBoxStyle.Star;
checkbox.Checked = true;
checkbox.Flatten = true;
doc.Form.Fields.Add(checkbox);
}
string fileName;
fileName = "blanktest.pdf";
doc.SaveToFile(fileName,FileFormat.PDF);
doc.Close();
doc = new PdfDocument(fileName);
fileName = "3310.4_test.xps";
doc.SaveToFile(fileName, FileFormat.XPS);
doc.Close();
System.Diagnostics.Process.Start(fileName);