Hi Team,
I am using free spire for my pdf conversion from dotx.i am facing some issue while converting dotx to pdf.The issue is i am inserting a field content in between of two field. while converting following field getting disaappered when i am giving more character conntent. Please find the code sample i have
private void btnMerge_Click(object sender, EventArgs e)
{
Document document = new Document();
var path = String.IsNullOrEmpty (this.txtPath.Text) ? "C:\\temp\\commentfield.dotx" : this.txtPath.Text;
var mergefield = this.txtMergeField.Text;
string htmlstring = this.rTxtContext.Text;
document.LoadFromFile(path);
//htmlstring = "<html><b><u>HTML string<u></b><html>";
var fild = document.Fields;
string code = string.Empty;
for (int i = 0; i <= fild.Count - 1; i++)
{
if (fild[i].Code.Contains(mergefield))
{
var o = fild[i];
int para = ((Spire.Doc.BodyRegion)o.Owner).OwnerTextBody.ChildObjects.IndexOf(o.OwnerParagraph);
for (int x = 0; x < o.OwnerParagraph.Items.Count; x++)
{
if (o.OwnerParagraph.Items[x].GetType() == typeof(Spire.Doc.Fields.Field))
{
var ab = (Spire.Doc.Fields.Field)o.OwnerParagraph.Items[x];
if (ab.Value.Equals(o.Value))
{
((Spire.Doc.BodyRegion)o.Owner).OwnerTextBody.InsertXHTML(htmlstring, para, x - 1);
ab.Code = string.Empty;
ab.Text= string.Empty;
ab.FieldText = string.Empty;
break;
}
}
}
}
}
document.SaveToFile("C:\\temp\\output.doc");
MessageBox.Show("Its completed");
}