I have a VSTO Word addin that perform a mail merge, into a pdf, It must generate one pdf for each record each one of them with it's own name.
My code Works fine but it takes a lot of time generating each one PDF and it show some undesired visual efects.
There is another approach to perform this task ?
Here is my Code:
public void Mezclar(Word.Document Doc)
{
decimal nRecords = Doc.MailMerge.DataSource.RecordCount;
for (int i = 1; i <= nRecords; i++)
{
Doc.MailMerge.DataSource.FirstRecord = i;
Doc.MailMerge.DataSource.LastRecord = i;
Doc.MailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
Doc.MailMerge.Execute();
Word.Document DocMezcla = this.Application.ActiveDocument;
DocMezcla.SaveAs("d:\\clientes\\Pruebas" + i.ToString().Trim() + ".pdf", Word.WdSaveFormat.wdFormatPDF);
DocMezcla.Close(Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges, null, null);
}
}
relying on vsto to do pdf conversion can be painful, and you cant do anything for visual. I would suggest to check out third party tool like Easy pdf sdk or ASPOSE