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 ..
//--------------------------------
Static Func _LetterPrint( cRtf, oRsLetter )
Local oPrint,nRowStep,nColStep,nMargin,Line,nPage
Local cPicFileName,cDefa,lPicFileName,oImg
Local nTopR,nTopL,nBotR,nBotL
Local nLinCnt,x,cText
Local oFontB,aMargins,nPrint
aMargins := PageGetMargins()
cDefa := set(7)
lPicFileName := .t.
If empty( oRsLetter:Fields("PicFileName"):Value) .or.;
聽 聽oRsLetter:Fields("PicFileName"):Value = " "
聽 聽lPicFileName := .f.
Else
聽 聽cPicFileName := oRsLetter:Fields("PicFileName"):Value
Endif
PRINTER oPRINT FROM USER 聽 聽 聽 聽 聽 聽 聽 聽;
PREVIEW MODAL 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ;
NAME "Print Routine for TEST LETTER"
IF EMPTY( oPRINT:hDC )
聽 聽MsgInfo ( "Report Cancelled" )
聽 聽Return(.f.)
ENDIF
nRowStep := oPrint:nVertRes() / 55 聽 聽 聽// pixel per line = 57.65 @ 55
nColStep := oPrint:nHorzRes() /130 聽 聽 聽// columns
oPRINT:StartPage()
nMargin := Int(oPrint:nLogPixelX()*0.2)
LINE 聽 聽:= nMargin
nPage 聽 := 1
oFontB 聽:= TFont():New("Ms Sans Serif",,-6,.F.,.T. ,,,,.F. ) // just used for spacing
If 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
* 聽 NEXT
Endif
*/
aMargins := PageGetMargins()
nPrint := 0
*nLen 聽 := ::Len()
*msginfo( nLen )
nLen := 1
AEval( 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
* 聽 聽 聽enddo
oPRINT:EndPage()
RELEASE FONT oFontB
oPRINT: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



