• I'm using WPTools 4.2 with C++ Builder 6 to load multiple rtf documents (also created using WPTools 4.2) 1 at a time, merge data fields, and then route them to different printers depending on certain data parameters.

    My problem is that about 90% of the documents print fine but about 10% don't. The files have all been created with the 'Courier New' font, but since this doesn't print dark enough, I'm changing to HP's 'Dark Courier' font after loading the document. Every now and then, one of the reports will print in Arial which really messes up the alignment.

    I've tried many different things, here is the code that I execute for each individual file as it sits now, what am I doing wrong?

    WPRichText1->LoadFromFile(RTFFname);
    WPRichText1->HideInsertpoints = false;
    WPRichText1->MergeText();
    WPRichText1->HideInsertpoints = true;

    Printer()->PrinterIndex = Printer()->Printers->IndexOf(PrinterName);
    WPPrinterOpen();
    WPRichText1->Memo->ReformatAll();

    WPRichText1->WorkOnText = wpFooter;
    WPRichText1->SelectAll();
    WPRichText1->Font->Name = "Dark Courier";
    WPRichText1->WorkOnText = wpHeader;
    WPRichText1->SelectAll();
    WPRichText1->Font->Name = "Dark Courier";
    WPRichText1->WorkOnText = wpBody;
    WPRichText1->SelectAll();
    WPRichText1->Font->Name = "Dark Courier";
    WPRichText1->Memo->ReformatAll();
    WPRichText1->Refresh();

    WPRichText1->Print();

    Thanks for your help!

    Gordon

    • Offizieller Beitrag

    For a quick replacement of all fonts in the text with one use this loop:

    Delphi:
    for i:=0 to FONTMAXANZ do
    WPRichText1.Header.FontName[i] := 'Courier Dark';
    WPRichText1.ReformatAll;

    C++Builder:
    for(int i=0; i<=FONTMAXANZ; i++)
    WPRichText1->Header->FontName[i] = "Courier Dark";
    WPRichText1->ReformatAll();

    The code with HideInsertpoints is not required. Simply switch on 'Hidden' in the property InsertpointTextAttr.

    I hope this helps,

    Julian Ziersch