Need Help urgently


#1

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...........


#2

Please attach the template document. I need it to be able to reproduce the problem.


#3

Hello,

thanks for quick reply.

i am sending you the tmeplate to you.Please send me the result ASAP.


#4

For MailMerge to work you need to insert the merge fields where you want your data to be filled in. This process is described in details in Performing MailMerge section of our documentation.

The text strings «Customer», «Address», «City», etc. only look like merge fields but are not suitable for MailMerge. The only real merge field in this template is «Salutation». Use ALT-F9 to toggle field code view and see the difference.

Best regards,


#5

Hello,

thank you very much.

Please send me the related code for this.

Thanks in advance...

vamsee


#6

Your current code is ok. To solve the issue you should prepare your template document for mailmerge correctly. The following article describes how you can do this:

http://www.aspose.com/Wiki/default.aspx/Aspose.Words/PreparingDocument.html


#7

Thanks alot.......