本文整理汇总了C#中DocumentBuilder.InsertCheckBox方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.InsertCheckBox方法的具体用法?C# DocumentBuilder.InsertCheckBox怎么用?C# DocumentBuilder.InsertCheckBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentBuilder
的用法示例。
在下文中一共展示了DocumentBuilder.InsertCheckBox方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertCheckBoxFormField
public static void InsertCheckBoxFormField(string dataDir)
{
// ExStart:DocumentBuilderInsertCheckBoxFormField
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertCheckBox("CheckBox", true, true, 0);
dataDir = dataDir + "DocumentBuilderInsertCheckBoxFormField_out.doc";
doc.Save(dataDir);
// ExEnd:DocumentBuilderInsertCheckBoxFormField
Console.WriteLine("\nCheckbox form field using DocumentBuilder inserted successfully into a document.\nFile saved at " + dataDir);
}
示例2: DocumentBuilder
/// <summary>
/// This is called for each merge field in the document
/// when Document.MailMerge.ExecuteWithRegions is called.
/// </summary>
void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
{
if (e.DocumentFieldName.Equals("CourseName"))
{
// Insert the checkbox for this merge field, using DocumentBuilder.
DocumentBuilder builder = new DocumentBuilder(e.Document);
builder.MoveToMergeField(e.FieldName);
builder.InsertCheckBox(e.DocumentFieldName + this.mCheckBoxCount.ToString(), false, 0);
builder.Write((string)e.FieldValue);
this.mCheckBoxCount++;
}
}
示例3: CreateForm
public void CreateForm()
{
//ExStart
//ExFor:TextFormFieldType
//ExFor:DocumentBuilder.InsertTextInput
//ExFor:DocumentBuilder.InsertComboBox
//ExFor:DocumentBuilder.InsertCheckBox
//ExSummary:Builds a sample form to fill.
DocumentBuilder builder = new DocumentBuilder();
// Insert a text form field for input a name.
builder.InsertTextInput("", TextFormFieldType.Regular, "", "Enter your name here", 30);
// Insert two blank lines.
builder.Writeln("");
builder.Writeln("");
string[] items = new string[]
{
"-- Select your favorite footwear --",
"Sneakers",
"Oxfords",
"Flip-flops",
"Other",
"I prefer to be barefoot"
};
// Insert a combo box to select a footwear type.
builder.InsertComboBox("", items, 0);
// Insert 2 blank lines.
builder.Writeln("");
builder.Writeln("");
// Insert a check box to ensure the form filler does look after his/her footwear.
builder.InsertCheckBox("", true, 0);
builder.Writeln("My boots are always polished and nice-looking.");
builder.Document.Save(ExDir + "DocumentBuilder.CreateForm Out.doc");
//ExEnd
}
示例4: DocumentBuilderInsertCheckBoxFormField
public void DocumentBuilderInsertCheckBoxFormField()
{
//ExStart
//ExFor:DocumentBuilder.InsertCheckBox
//ExId:DocumentBuilderInsertCheckBoxFormField
//ExSummary:Shows how to insert a checkbox form field into a document.
Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertCheckBox("CheckBox", true, 0);
//ExEnd
}
示例5: InsertCheckBoxEx
public void InsertCheckBoxEx()
{
//ExStart
//ExFor:DocumentBuilder.InsertCheckBox(String, Boolean, Int32)
//ExFor:DocumentBuilder.InsertCheckBox(String, Boolean, Boolean, Int32)
//ExSummary:Shows how to insert a check box into a document.
Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a checkbox with no default value and let MS Word apply the default size.
builder.Writeln("Check box 1");
builder.InsertCheckBox("CheckBox1", false, 0);
builder.Writeln();
// Insert a checked checkbox with a specified value.
builder.Writeln("Check box 2");
builder.InsertCheckBox("CheckBox2", false, true, 50);
doc.Save(MyDir + @"Document.InsertedCheckBoxes.doc");
//ExEnd
}
示例6: ExportFormFields
public void ExportFormFields(bool exportFormFields)
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertCheckBox("CheckBox", false, 15);
HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
{
SaveFormat = SaveFormat.HtmlFixed,
ExportEmbeddedCss = true,
ExportEmbeddedFonts = true,
ExportEmbeddedImages = true,
ExportEmbeddedSvg = true,
ExportFormFields = exportFormFields
};
//For assert test result you need to open documents and check that checkbox are clickable in "ExportFormFiels.html" file and are not clickable in "WithoutExportFormFiels.html" file
if (exportFormFields == true)
{
doc.Save(MyDir + "ExportFormFiels.html", htmlFixedSaveOptions);
}
else
{
doc.Save(MyDir + "WithoutExportFormFiels.html", htmlFixedSaveOptions);
}
}
示例7: InsertCheckBox
/// <summary>
/// Insert CheckBox into a Word cell
/// </summary>
/// <param name="excelCheckbox">Excel CheckBox</param>
/// <param name="parentCell">Parent Word cell</param>
private void InsertCheckBox(Aspose.Cells.Drawing.CheckBox excelCheckbox, Aspose.Words.Tables.Cell parentCell)
{
//Create new temporary document
Document doc = new Document();
//Create instance of DocumentBuilder
DocumentBuilder builder = new DocumentBuilder(doc);
//Calculate size of CheckBox
int size = (int)(ConvertUtil.PixelToPoint(excelCheckbox.Height));
switch (excelCheckbox.CheckedValue)
{
case CheckValueType.Checked:
{
builder.InsertCheckBox(excelCheckbox.Name, true, size);
break;
}
case CheckValueType.UnChecked:
{
builder.InsertCheckBox(excelCheckbox.Name, false, size);
break;
}
default:
{
builder.InsertCheckBox(excelCheckbox.Name, false, size);
break;
}
}
//Write text of Excel CheckBox
builder.Write(excelCheckbox.Text);
//Import all content of temporary document into a destination cell
foreach (Node node in builder.CurrentParagraph.ChildNodes)
{
parentCell.LastParagraph.AppendChild(parentCell.Document.ImportNode(node, true));
}
}
示例8: InsertCheckBoxEmptyName
public void InsertCheckBoxEmptyName()
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
//Assert that empty string name working correctly
builder.InsertCheckBox("", true, false, 1);
builder.InsertCheckBox(string.Empty, false, 1);
}
示例9: InsertCheckBox
public void InsertCheckBox()
{
//ExStart
//ExFor:DocumentBuilder.InsertCheckBox(string, bool, bool, int)
//ExFor:DocumentBuilder.InsertCheckBox(string, bool, int)
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
//Insert checkboxes
//With Default value
builder.InsertCheckBox("CheckBox_DefaultAndCheckedValue", false, true, 0);
//Without Default value
builder.InsertCheckBox("CheckBox_OnlyCheckedValue", true, 100);
//ExEnd
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, SaveFormat.Docx);
//Get checkboxes from the document
FormFieldCollection formFields = doc.Range.FormFields;
//Check that is the right checkbox
Assert.AreEqual("CheckBox_DefaultAndCheckedValue", formFields[0].Name);
//Assert that parameters sets correctly
Assert.AreEqual(true, formFields[0].Checked);
Assert.AreEqual(false, formFields[0].Default);
Assert.AreEqual(10, formFields[0].CheckBoxSize);
//Check that is the right checkbox
Assert.AreEqual("CheckBox_OnlyCheckedValue", formFields[1].Name);
//Assert that parameters sets correctly
Assert.AreEqual(false, formFields[1].Checked);
Assert.AreEqual(false, formFields[1].Default);
Assert.AreEqual(100, formFields[1].CheckBoxSize);
}