hello,
I am a little old user. I had used the Aspose.pdf.dll.You people really helped me very well.
Now i am getting one more problem i am writing some code to generate the PDF.I have one template for my document for which i want to generate PDF.I have placeholders in my Template document.In the code part i am replaceing the placeholders with the database data.At the end of the execution i am getting the PDF file But it was not replaced by the database data.
I am sending you the code and the PDF for you.Please let me know ASAP.
CODE:
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Pdf.lic");
//Aspose.Words.License WordsLicense = new Aspose.Words.License();
//WordsLicense.SetLicense("Aspose.Words.lic");
string pdfurl = System.Configuration.ConfigurationSettings.AppSettings["PDFURL"];
string pdfpath = System.Configuration.ConfigurationSettings.AppSettings["PDFPATH"];
Document sourceDoc;
sourceDoc = new Document(pdfpath + @"\Support_Letter_Templates\CustomerLetter1.doc");
DataTable table = new DataTable();
table.Columns.Add("Date");
table.Columns.Add("Customer");
table.Columns.Add("Address");
table.Columns.Add("City");
table.Columns.Add("Salutation");
table.Columns.Add("ToWhomItMayConcern");
table.Columns.Add("TELECOM");
lblDate.Text = System.DateTime.Now.ToLongDateString();
int c = lblDate.Text.ToString().IndexOf(",");
c = c + 1;
lblDate.Text = lblDate.Text.ToString().Substring(c);
table.Rows.Add(new object[]{
lblDate.Text.ToString(),
Dt.Rows[0]["CustomerName"].ToString(),
Dt.Rows[0]["Cm_Address1"].ToString()+ " " + Dt.Rows[0]["Cm_Address2"].ToString(),
Dt.Rows[0]["Cm_City"].ToString().Trim()+", "+Dt.Rows[0]["CM_StateCode"].ToString().Trim()+" "+Dt.Rows[0]["CM_Zip"].ToString().Trim(),
Dt.Rows[0]["Salutation"].ToString().Trim(),
Dt.Rows[0]["First_Name"].ToString().Trim()+" "+ Dt.Rows[0]["Last_Name"].ToString().Trim(),
Dt.Rows[0]["DealerName"].ToString()
});
sourceDoc.MailMerge.Execute(table);
MemoryStream ms = new MemoryStream();
XmlDocument xml = new XmlDocument();
sourceDoc.Save(ms, Aspose.Words.SaveFormat.FormatAsposePdf);
ms.Position = 0;
xml.Load(ms);
Pdf pdf = new Pdf();
pdf.IsImagesInXmlDeleteNeeded = true;
pdf.BindXML(xml, null);
ms.Close();
pdf.Save(pdfpath + "\\" + ContractId + "_Customerletter1.pdf");
Thanks in advance…