Al programa de Andrés, le he añadido 3 posibilidades de cambiar un fichero formato RTF a PDF (las tres que conozco y que solo funciona la última).
La primera, si pones más de una linea no funciona.
La segunda, no hace los saldos de linea ni tiene en cuenta los caracteres especial.
La tercera....., si que funciona pero porque hace un PREVIEW... osease que si el documento se "pre visualiza previavente" si que se puede guardar en PDF. He estado mirando la función en "c" HB_FUNC( _HMG_PRINTER_STARTPAGE_PREVIEW ), pero mis conocimientos son limitados y me pierdo, no obstante entiendo que es posible hacerlo ya que HMG lo hace.
Lo que pretendo es hacer lo que hace el PREVIEW y el SAVE a PDF sin intervención del usuario, osea convertir un fichero ".rtf" en ".pdf".
¿alguien sabe donde esta la función que previsualiza el documento...?, quizás utilizando esta se podría realizar el proceso.
Cualquier ayuda será bienvenida..., muchas gracias.
Code: Select all
* CONVERTIR RTF A PDF
/*_______________________________________________________________________________________________________*/
/*[•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•]*/
/*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*/
#include "hmg.ch"
FUNCTION Main()
DEFINE WINDOW xForm AT 000,000 WIDTH 800 HEIGHT 600 MAIN TITLE "GRABA a PDF" BACKCOLOR { 51, 156, 255 }
@ 005,010 BUTTON LB_Tx OF xForm CAPTION "RTF a PDF - Opc 1 " WIDTH 200 HEIGHT 22 FONT "Consolas" SIZE 12 ;
ACTION PrintREB(1 )
@ 005,310 BUTTON LB_Tx2 OF xForm CAPTION "RTF a PDF - Opc 2" WIDTH 200 HEIGHT 22 FONT "Consolas" SIZE 12 ;
ACTION PrintREB(2 )
@ 005,610 BUTTON LB_Tx3 OF xForm CAPTION "RTF a PDF - Opc 3" WIDTH 200 HEIGHT 22 FONT "Consolas" SIZE 12 ;
ACTION PrintREB(3 )
@ 030, 000 RICHEDITBOX EDB_x WIDTH 800 HEIGHT 570 VALUE ""
xForm.EDB_x.RTFTextMode := .T.
END WINDOW
CENTER WINDOW xForm
ACTIVATE WINDOW xForm
RETURN Nil
**********************************************************
FUNCTION PrintREB( nOpc )
LOCAL lSuccess, nRow := 55, nCol := 70, nPag := 0
LOCAL mspreh, msposth, cVar
LOCAL PrintPageCodeBlock := { || @ nRow , nCol PRINT "Pag. " + HB_NTOS( nPag++ ) CENTER }
xForm.EDB_x.RTFSaveFile ( "PROBA.rtf", 4, .F.)
xForm.EDB_x.RTFLoadFile ( "PROBA.rtf", 4, .F.)
DO CASE
CASE nOPc=1
SELECT HPDFDOC 'Opc1.pdf' TO lSuccess papersize HPDF_PAPER_A4
SET HPDFDOC COMPRESS ALL
SET HPDFDOC PAGEMODE TO OUTLINE
if lSuccess
START HPDFDOC
SET HPDFDOC ENCODING TO "WinAnsiEncoding"
START HPDFPAGE
Print_Content( xForm.EDB_x.Value )
END HPDFPAGE
END HPDFDOC
endif
CASE nOpc=2
SELECT PRINTER PDF 'Opc2.pdf' TO lSuccess
IF lSuccess
START PRINTDOC
START PRINTPAGE
@ 0,0 PRINT xForm.EDB_x.Value
END PRINTPAGE
END PRINTDOC
ENDIF
CASE nOpc=3
SELECT PRINTER DEFAULT TO lSuccess SAVEAS "Opc3.PDF"
IF lSuccess
xForm.EDB_x.RTFPrint( { 0, -1 } , 20 , 20 , 20 , 20 , PrintPageCodeBlock )
ENDIF
ENDCASE
RETURN nil
function Print_Content( cContent)
@ 50, 10 HPDFPRINT cContent TO 120, 200 JUSTIFY
return nil