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 view
//--------------------------------
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