Hello Support,
///
/// My Aspose document.
///
public class MyDocument : Aspose.Words.Document
{
public MyDocument(string fileName) : base(fileName) { }
public bool TryToSave(string fileName, int timeout)
{
InterruptionToken token = new InterruptionToken();
bool finished = SaveWithTimeout(token,
() =>
{
token.BindToCurrentThread();
try
{
Save(fileName);
}
catch (Exception ex)
{
Console.WriteLine(“Interrupted”);
}
}, timeout);
return finished;
}
private bool SaveWithTimeout(InterruptionToken token, ThreadStart threadStart, int timeout)
{
Thread workerThread = new Thread(threadStart);
workerThread.Start();
bool finished = workerThread.Join(timeout);
if (!finished)
{
token.Interrupt();
}
return finished;
}
}
MyDocument myDoc = new MyDocument(MyDir + “in.docx”);
bool done = myDoc.TryToSave(MyDir + “Out.pdf”, 1000);
Console.WriteLine(done ? “Converted” : “Interrupted by timeout.”);
But before the calling the “Save” method we have use two lines of code to replace Mail Merge Fields:
MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveUnusedFields | MailMergeCleanupOptions.RemoveContainingFields | MailMergeCleanupOptions.RemoveUnusedRegions;
MailMerge.Execute(fieldNames, fieldValues);
The PDF file is generated but mail merge fields are not replaced. We are calling “TryToSave” method from web page. In this method we have also passed two additional parameters for merge fields.
Please let me know what is the solution.