Guys,
Do you know some way to convert RTF files to PDF files without open them ?
Do you know some way to convert RTF files to PDF files without open them ?
Vilian
Have a look at TRichEdit5 class ( triched5.prg in \samples\classes ) METHOD SaveToPDF( cName, cFile, lView ).
Rick Lipkin
Rick Lipkin wrote:Vilian
Have a look at TRichEdit5 class ( triched5.prg in \samples\classes ) METHOD SaveToPDF( cName, cFile, lView ).
Rick Lipkin
Thank You guys, I will try.
Create and hide control ?
Yes, I will try using something like this ![]()

Dear Ramesh
The image is not visible.
Please put your image or send me your file pdf
Dear Cristobal,
The image I have posted above is the exact PDF generated
using the "TESTRTF5.PRG" under FWH\Samples.
The Menu Path used to generated the PDF is "File -> To RTF".
And the RTF file is "TESTRTF.RTF"
You can try it yourself.
Regards,
-Ramesh Babu P

cnavarro wrote:Create and hide control ?
#include "fivewin.ch"
function Main()
聽 聽local oWnd, oBar
聽 聽DEFINE WINDOW oWnd TITLE "MY APPLICATION"
聽 聽DEFINE BUTTONBAR oBar OF oWnd SIZE 100,32 2010
聽 聽DEFINE BUTTON OF oBar PROMPT "RTFTOPDF" ;
聽 聽 聽 ACTION RTFTOPDF( "c:\fwh\samples\fiveodbc.rtf" )
聽 聽ACTIVATE WINDOW oWnd CENTERED
return nil
static function RTFTOPDF( cRTF, cPDF, lOpen )
聽 聽local oWnd, oRtf, cTxt := ""
聽 聽if Empty( cRtf ) .or. !File( cRTF ) .or. Lower( cFileExt( cRtf ) ) != "rtf"
聽 聽 聽 return .f.
聽 聽endif
聽 聽DEFAULT cPDF := cRTF, lOpen := .t.
聽 聽cPDF 聽:= cFileSetExt( cPDF, "pdf" )
聽 聽FErase( cPDF )
聽 聽DEFINE WINDOW oWnd
聽 聽@ 0,0 RICHEDIT5 oRtf VAR cTxt OF oWnd FILE cRTF
聽 聽oWnd:oClient := oRtf
聽 聽ACTIVATE WINDOW oWnd HIDDEN ON INIT ;
聽 聽 聽 ( oRtf:SaveToPDF( cFileNoExt( cPdf ), cPDF, lOpen ), oWnd:End() )
return File( cPDF )RtfToPdf(cNovo)
FUNCTION RtfToPdf( cRTF, cPDF, lOpen )
LOCAL oWnd, oRtf, cTxt := ""
聽 聽IF Empty( cRtf ) .or. !File( cRTF ) .or. Lower( cFileExt( cRtf ) ) != "rtf"
聽 聽 聽 return .f.
聽 聽ENDIF
聽 聽DEFAULT cPDF := cRTF, lOpen := .t.
聽 聽cPDF 聽:= cFileSetExt( cPDF, "pdf" )
聽 聽FErase( cPDF )
聽 聽DEFINE WINDOW oWnd
聽 聽@ 0,0 RICHEDIT5 oRtf VAR cTxt OF oWnd FILE cRTF
聽 聽oWnd:oClient := oRtf
聽 聽ACTIVATE WINDOW oWnd HIDDEN ON INIT ;
聽 聽 聽 ( oRtf:SaveToPDF( cFileNoExt( cPdf ), cPDF, lOpen ), oWnd:End() )
RETURN File( cPDF )
METHOD SaveToPDF( cName, cFile, lView ) CLASS TRichEdit5
聽 聽local aMargins := PageGetMargins()
聽 聽local nLen 聽 聽 := ::Len()
聽 聽local nPrint 聽 := 0
聽 聽local oPrn
聽 聽//local aPrinters := aGetPrinters()
聽 聽?::cFileName,cFileNoExt( ::cFileName ) + ".pdf", cName, cFile
聽 聽DEFAULT cName := cFileNoExt( ::cFileName ) + " Report" //"FWH RichEdit Report"
聽 聽DEFAULT cFile := cFileNoExt( ::cFileName ) + ".pdf"
聽 聽DEFAULT lView := .F.
聽 聽if ::IsSelection()
聽 聽 聽 nPrint 聽 := ::GetPos()
聽 聽 聽 nLen 聽 聽 := ::GetSelection()[ 2 ] - nPrint
聽 聽 聽 //? nPrint, ::GetSelection()[ 2 ], nLen
聽 聽endif
聽 聽if !Empty( cFile )
聽 聽 聽 if lView
聽 聽 聽 聽 聽PRINT oPrn NAME cName PREVIEW FILE cFile
聽 聽 聽 else
聽 聽 聽 聽 聽PRINT oPrn NAME cName FILE cFile
聽 聽 聽 endif
聽 聽 聽 if Empty( oPrn:hDC )
聽 聽 聽 聽 聽MsgStop( "Printer not ready!" )
聽 聽 聽 聽 聽return nil
聽 聽 聽 endif
聽 聽 聽 CursorWait()
聽 聽 聽 AEval( aMargins, { | x, y | aMargins[ y ] := x * 1440 / 2540 } )
聽 聽 聽 do while nPrint < nLen
聽 聽 聽 聽 聽PAGE
聽 聽 聽 聽 聽 聽 nPrint := REPreview5( ::hWnd, oPrn:hDC, oPrn:hDCOut, aMargins, nPrint )
聽 聽 聽 聽 聽ENDPAGE
聽 聽 聽 enddo
聽 聽 聽 CursorArrow()
聽 聽 聽 ENDPRINT
聽 聽else
聽 聽 聽 MsgStop( "Not file name is implemented", "Error" )
聽 聽endif
return nil