Compsoft Flexible Specialists

Compsoft plc

Compsoft Weblog Compsoft Website News Archive Privacy Policy Contact Us  

Tuesday, October 06, 2009

Mail merging with PDF documents

We tend to find that mail merge with word documents is a flexible mechanism for customers to control the output of their applications. Be that invoices, emails or reports. Using simple merge merge documents allows the customers to modify the output of the system without having to contact us. We find that the word mail merge solution provided by ASPOSE Words is simple and reliable.

We recently had a customer that required pre made PDF forms to be source of the outputs from their system. After a quick search of the ASPOSE solutions, we found that the ASPOSE PDF Kit had exactly what we needed.

10 lines of code later, we could as easily mail merge against PDF documents as we could against word documents.

MemoryStream outputStream = new MemoryStream();
MemoryStream pdfForm = new MemoryStream(this.Binary.Data);
Form form = new Form(pdfForm, outputStream);

foreach (string fieldName in form.FieldsNames)
{
object fieldValue = "";
if (mailMergeDataSource.GetValue(fieldName, out fieldValue))
form.FillField(fieldName, fieldValue.ToString());
}

form.FlattenAllFields();
form.Save();

return outputStream;



Thank you ASPOSE!

0 Comments:

Post a Comment

<< Home