Guys,
Do you know some way to convert RTF files to PDF files without open them ?
Rick Lipkin wrote:Vilian
Have a look at TRichEdit5 class ( triched5.prg in \samples\classes ) METHOD SaveToPDF( cName, cFile, lView ).
Rick Lipkin
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 87 guests