Hi,
I’m trying to use Aspose.Words for automation of a mail merge fax job.
The problem is as follows: For the fax programm to understand what to do with the document, I insert a control string at the very beginning of the document, which contains the fax number and name of the sender and the fax number of the receiver. This String needs to be formatted with a Font name ActiveFax for the Fax Printer to understand that these are control characters. After having inserted the string and done mail merging I print to the fax printer.
Unfortunately for some unknown reason the Font formatting doesn't work. The characters get printed as if they were normal characters.
Now the funny bit:
If I programmatically save the produced document from within my program and then manually open and print it from MS Word, everything is okay.
Here the two methods I use:
public void PrepareForActiveFax(DateTime ScheduledDate, int FaxResolution) {
DocumentBuilder builder = new DocumentBuilder(wordDoc);
builder.MoveToDocumentStart();
builder.PushFont();
builder.Font.Name = "ActiveFax";
builder.Font.Size = 2.0;
builder.Font.Color = System.Drawing.Color.Black;
builder.Write(this.NewFax);
builder.Write(" ");
builder.Write(this.InitStringWord);
//FaxNumber
builder.Write(" @F211 ");
if(cnf.Services.FaxMakerService.IsDemo)
builder.Write(cnf.Services.FaxMakerService.DemoFaxNumber);
else
builder.InsertField("MERGEFIELD FaxNr \\* MERGEFORMAT", "");
builder.Write("@ ");
//FaxReference
builder.Write("@F307 ");
builder.InsertField("MERGEFIELD REF \\* MERGEFORMAT", "");
builder.Write("@ ");
//FaxBundleItemID (Kostenstelle)
builder.Write("@F315 ");
builder.InsertField("MERGEFIELD BundleId \\* MERGEFORMAT", "");
builder.Write("/");
builder.InsertField("MERGEFIELD ItemId \\* MERGEFORMAT", "");
builder.Write("@ ");
builder.PopFont();
}
public void Fax() {
Document curDoc;
DocumentRenderer rdr = new DocumentRenderer();
int firstRecord = 1;
int lastRecord = 0;
string curDocPath =
cnf.Services.FaxMakerService.DocFolder + "\\Current.doc";
wordDoc.Save(curDocPath);
int maxItems = cnf.Services.FaxMakerService.MaxFaxItemsPerPrintFile;
if(maxItems == 0)
maxItems = this.FaxItemsCount;
if(this.FaxItemsCount > maxItems)
lastRecord = maxItems;
else
lastRecord = this.FaxItemsCount;
while(firstRecord <= this.FaxItemsCount) {
this.GetFaxItems(firstRecord, lastRecord);
curDoc = new Document(curDocPath);
curDoc.MailMerge.RemoveEmptyParagraphs = true;
curDoc.MailMerge.Execute(tblFaxReceivers);
curDoc.Save(cnf.Services.FaxMakerService.DocFolder + "\\Merged.doc");
rdr = new DocumentRenderer();
rdr.PrinterSettings.PrinterName = "ActiveFax";
rdr.Document = new Document(cnf.Services.FaxMakerService.DocFolder + "\\Merged.doc");
rdr.Print();
firstRecord += maxItems;
lastRecord += maxItems;
if(lastRecord > this.FaxItemsCount)
lastRecord = this.FaxItemsCount;
}
}