I am trying to print a RichType letter saved as a variable cRtf ... I know I can use the Print and Preview methods, however, I am adding a stored custom masthead to my RichText. I am struggling to be able to insert richtext after the image .. I can print the image, but trying to adapt The RichText Print method is not working ..
What I am trying to do is print the Custom MastHead then print the RichText after the image .. here is my code ..
Code: Select all | Expand
//--------------------------------Static Func _LetterPrint( cRtf, oRsLetter )Local oPrint,nRowStep,nColStep,nMargin,Line,nPageLocal cPicFileName,cDefa,lPicFileName,oImgLocal nTopR,nTopL,nBotR,nBotLLocal nLinCnt,x,cTextLocal oFontB,aMargins,nPrintaMargins := PageGetMargins()cDefa := set(7)lPicFileName := .t.If empty( oRsLetter:Fields("PicFileName"):Value) .or.; oRsLetter:Fields("PicFileName"):Value = " " lPicFileName := .f.Else cPicFileName := oRsLetter:Fields("PicFileName"):ValueEndifPRINTER oPRINT FROM USER ;PREVIEW MODAL ;NAME "Print Routine for TEST LETTER"IF EMPTY( oPRINT:hDC ) MsgInfo ( "Report Cancelled" ) Return(.f.)ENDIFnRowStep := oPrint:nVertRes() / 55 // pixel per line = 57.65 @ 55nColStep := oPrint:nHorzRes() /130 // columnsoPRINT:StartPage()nMargin := Int(oPrint:nLogPixelX()*0.2)LINE := nMarginnPage := 1oFontB := TFont():New("Ms Sans Serif",,-6,.F.,.T. ,,,,.F. ) // just used for spacingIf lPicFileName = .t. cPicFileName := cDefa+"\MastHead\"+alltrim(cPicFileName) DEFINE IMAGE oImg FILENAME cPicFileName nTopR := 0 nTopL := 100 nBotR := oPrint:nHorzRes()*.9375 // 4500 nBotL := oPrint:nVertRes()*.1563 // 1000 oPrint:SayImage( nTopR, nTopL, oImg, nBotR,nBotL ) oImg:End() // calc for cRtf text to start Line := (oPrint:nVertRes()*.1570) // 5331 msginfo( Line )Endif/* ... this is rem'd out and does not work properly // Print letter text 123 - 100*nLinCnt := MlCount( cRtf, 110 )*msginfo( "nLinCnt" )*msginfo( nLinCnt )*IF nLinCnt > 0* FOR x := 1 to nLinCnt* cText := MemoLine( cRtf, 110, x )* oPrint:Say( LINE,(oPrint:nHorzRes()*.07), cText ) //, oFont10b ) // 200* Line += oFontb:nHeight* Line += oFontb:nHeight* Line += oFontb:nHeight* Line += oFontb:nHeight* Line += oFontb:nHeight* NEXTEndif*/aMargins := PageGetMargins()nPrint := 0*nLen := ::Len()*msginfo( nLen )nLen := 1AEval( aMargins, { | x, y | aMargins[ y ] := x * 1440 / 2540 } )* do while nPrint < nLen* PAGE nPrint := REPreview5( ::hWnd, oPrint:hDC, oPrint:hDCOut, aMargins, nPrint ) // obvious self error* ENDPAGE* enddooPRINT:EndPage()RELEASE FONT oFontBoPRINT:Preview()Return(nil)
Any Ideas ... I get the Image to print ( a masthead logo ) but I cannot figure out how to print cRtf out and preserve the formatting and text. Any help would be appreciated.
Rick Lipkin