CheckBoxFormField cb = new CheckBoxFormField(doc);
cb.Checked = true;
cb.Name = "Chk1";
para.Items.Insert(0, cb);
Gary.zhang wrote:Hello,
Please use the following method to insert checkbox in fixed position.
- Code: Select all
CheckBoxFormField cb = new CheckBoxFormField(doc);
cb.Checked = true;
cb.Name = "Chk1";
para.Items.Insert(0, cb);
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
Document doc = new Document();
Section section = doc.AddSection();
Paragraph para1 = section.AddParagraph();
para1.AppendText("paragraph1");
Paragraph para2 = section.AddParagraph();
para2.AppendText("paragraph2");
CheckBoxFormField cb = new CheckBoxFormField(doc);
cb.Checked = true;
cb.Name = "Chk1";
para2.Items.Insert(1, cb);
doc.SaveToFile("test.docx", FileFormat.Docx);
Gary.zhang wrote:Hello,
Have you tried the code? Does it fulfill your needs? Could you please give us some feedback if convenience?
Please let us know if there are any questions or needs.
Thanks,
Gary
E-iceblue support team
Gary.zhang wrote:Hello,
Have you tried the code? Does it fulfill your needs? Could you please give us some feedback if convenience?
Please let us know if there are any questions or needs.
Thanks,
Gary
E-iceblue support team
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Aspose.Words;
namespace WordDemo
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document(".//test.doc");
doc.Range.Replace("{#username}", "zhang", false, false);//{#username} template character
Regex reg = new Regex("{#userphoto}");//fix position
doc.Range.Replace(reg, new ReplaceAndInsertImage(".//1.jpg"), false);
doc.Save("res.doc")
}
}
public class ReplaceAndInsertImage : IReplacingCallback
{
public string url { get; set; }
public ReplaceAndInsertImage(string url)
{
this.url = url;
}
public ReplaceAction Replacing(ReplacingArgs e)
{
var node = e.MatchNode;
Document doc = node.Document as Document;
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveTo(node);
builder.InsertImage(url);
return ReplaceAction.Replace;
}
}
}
Document doc = new Document();
doc.LoadFromFile("test.doc");
doc.Replace("{#username}", "zhang", false, false);
DocPicture picture=new DocPicture(doc);
picture.LoadImage(Image.FromFile("1.jpg"));
TextSelection[] texts = doc.FindAllString("{#userphoto}", true, true);
foreach(TextSelection ts in texts)
{
TextRange range= ts.GetAsOneRange();
Paragraph paragraph=range.OwnerParagraph;
int index=paragraph.ChildObjects.IndexOf(range);
paragraph.ChildObjects.Insert(index,picture);
paragraph.ChildObjects.RemoveAt(index+1);
}
doc.SaveToFile("result.doc");
Gary.zhang wrote:Hello,
Have you tried the method in Spire? Does it fulfill your needs? Could you please give us some feedback if convenience?
Thanks,
Gary
E-iceblue support team
string filepath = Server.MapPath("mb/");
Document document = new Document();
document.LoadFromFile(filepath + "Apply_1.doc",FileFormat.Auto);
DocPicture picture = new DocPicture(document);
System.Drawing.Image img = System.Drawing.Image.FromFile(filepath+"11.jpg");
picture.LoadImage(img);
TextSelection[] texts = document.FindAllString("{$110936}", false, false);
foreach (TextSelection ts in texts)
{
TextRange range = ts.GetAsOneRange();
Paragraph paragraph = range.OwnerParagraph;
int index = paragraph.ChildObjects.IndexOf(range);
paragraph.ChildObjects.Insert(index, picture);
paragraph.ChildObjects.RemoveAt(index + 1);
}
document.SaveToFile(filepath + "Apply_Zs.doc", FileFormat.Doc);
Gary.zhang wrote:Hello,
Thanks for your response. Please attach your document here for our testing, if it is inconvenient to attach here, you can send it to Support@e-iceblue.com via email.
Thanks,
Gary
E-iceblue support team