- Code: Select all
var selections = document.FindAllString(key, true, true);
foreach (var selection in selections)
{
var sdt = new StructureDocumentTagInline(document)
{
CharacterFormat = { FontSize = sizeCheckBox, TextColor = Color.FromArgb(argb) }
};
var range = selection.GetAsOneRange();
var index = range.OwnerParagraph.ChildObjects.IndexOf(range);
range.OwnerParagraph.ChildObjects.Insert(index, sdt);
sdt.SDTProperties.SDTType = SdtType.CheckBox;
var scb = new SdtCheckBox();
sdt.SDTProperties.ControlProperties = scb;
var tr = new TextRange(document)
{
CharacterFormat =
{
FontName = "MS Gothic",
FontSize = sizeCheckBox,
TextColor = Color.FromArgb(argb)
}
};
sdt.ChildObjects.Add(tr);
scb.Checked = true;
sdt.SDTProperties.Alias = "CheckoBox";
sdt.SDTProperties.Tag = "Checkbox";
range.OwnerParagraph.ChildObjects.Remove(range);
}
//Embed private font from font file into the document
document.PrivateFontList. Add(new PrivateFontPath("MS Gothic", @"..\fontFiles\MS Gothic.ttc"));
// PS method
ToPdfParameterList ps = new ToPdfParameterList();
ps.UsePSCoversion = true;
MemoryStream outStream = new MemoryStream();
document.SaveToStream(outStream, ps);
buffer = outStream.ToArray();