Another duplex printing problem

  • I am working with the TWPRichEdit component in WPTools 4.11d and have encountered a problem when print spooling a large number of duplex letters. My code includes the following logic during the print process to ensure that each new document starts on its own page rather than the back of the previous document should it have an odd number of pages:


    LetterRichText.Print;
    iPageCnt := LetterRichText.CountPages;
    if (iPageCnt mod 2) = 1 then
    WPTPrinterWrapper.NewPage;

    Occasionally, however, this code seems to add an inappropriate page break – throwing the entire batch process off from there on. I believe the problem has to do with the fact that we are selecting and replacing text in the letter to generate dynamic content as well as printing or suppressing headers and footers based on custom codes embedded in the document. Is there a way I can repaginate the contents of the TWPRichText control before printing?

    Thanks,
    Dave Henrickson

    • Offizieller Beitrag

    Hi,

    It is possible that the reformat takes place inside the Print procedure.

    So I suggest to abuse the PrintHeader event to set a 'PrintAdditionalPage' boolean there, depending on PageCount.
    Append the page depending on this boolean after the printing.

    Julian