PDF CONVERTIR

HMG en Español

Moderator: Rathinagiri

User avatar
SALINETAS24
Posts: 308
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Has thanked: 13 times
Been thanked: 16 times

PDF CONVERTIR

Post by SALINETAS24 » Mon Apr 22, 2019 11:49 am

Hola a todos, hay alguna manera de convertir un formato .RTF a formato .PDF..?
Muchas gracias y vamos con la cervecita...

User avatar
serge_girard
Posts: 2250
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 530 times
Been thanked: 111 times
Contact:

Post by serge_girard » Mon Apr 22, 2019 2:26 pm

I use 'Doxillion Document Converter'. It can be called by your HMG program.
Just create a batch file which will do the conversion, execute it, then comes in the trick: wait until conversion job is done (successfull - error - ..), read the logging to see the result.

Serge

User avatar
SALINETAS24
Posts: 308
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Has thanked: 13 times
Been thanked: 16 times

Post by SALINETAS24 » Mon Apr 22, 2019 4:32 pm

Muchas gracias Serge.
Lo tengo en cuenta y veré de implementarlo.
Para ti una copa de buen vino... :lol:

User avatar
andyglezl
Posts: 1123
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 32 times
Been thanked: 68 times
Contact:

Post by andyglezl » Mon Apr 22, 2019 6:09 pm

Quizá de esta forma... (No lo he probado)
*----------------------------------
Maybe in this way ... (I have not tried it)

Code: Select all

@ 010, 010 RICHEDITBOX EDB_01 WIDTH 580 HEIGHT 400 VALUE "" 
...............
Form_1.EDB_01.RTFLoadFile( "MiRTF.rtf", 4, .F.)
...............
SELECT PRINTER PDF 'MiPDF.pdf' TO lSuccess 
	IF lSuccess
		START PRINTDOC
			START PRINTPAGE
				Form_1.EDB_01
			END PRINTPAGE
		END PRINTDOC
		EXECUTE FILE 'MiPDF.PDF'
	ENDIF
Andrés González López
Desde Guadalajara, Jalisco. México.

EduardoLuis
Posts: 633
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Has thanked: 1 time
Been thanked: 49 times

Post by EduardoLuis » Tue Apr 23, 2019 9:44 pm

Hi Salinetas:

Take a look at procedure "V_PRINT" on Miniwriter sample, you'll get a preview of rtf and if you press "save button", you'll get the chance to generate a PDF file with the content you are previsualizing.
Hope this helps you.
Regards
Eduardo

Hola Salinetas:

Hechale una vista al procedure "V_PRINT" que tienes en el sample MINIWRITER, allí obtendras el acceso al preview del rtf y si presiona el boton "SAVE", tendrás la opción de generar un archivo pdf.
Espero te sirva de ayuda.
Cordialmente
Eduardo

User avatar
SALINETAS24
Posts: 308
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Has thanked: 13 times
Been thanked: 16 times

Post by SALINETAS24 » Fri Apr 26, 2019 6:32 am

Hola y gracias por responder.
Es más o menos lo que busco, pero el problema es que en los procesos que indicáis "V_PRINT" tiene que intervenir el usuario, seleccionando y grabando, y lo que me gustaría es que se obviase esa intervención.., que se generase en PDF sin necesidad de seleccionar la impresora y grabar, evitando que estos dos pasos.
Agradecido de antemano.., vamos con una cervecita

PeteWG
Posts: 139
Joined: Sun Mar 21, 2010 5:45 pm
Has thanked: 11 times
Been thanked: 41 times

Post by PeteWG » Fri Apr 26, 2019 11:56 am

In case you have LibreOffice or OpenOffice installed (if not, install it, it's the best for the (no)money it costs! ;) )
you can convert (export) quite easily any supported file to a PDF, by just calling soffice.exe from command line.

here is the generic syntax:
%LibreOfficeInstallationPath%\soffice.exe --headless --convert-to pdf[:calc/writer/draw/_pdf_Export] <sourceFile> [--outdir x:\destinationDir]

- example (xls convert/export):
"C:\Program Files\LibreOffice\program\soffice.exe" --headless --convert-to pdf:calc_pdf_Export mySheet.xls --outdir x:\temp
this will create <mySheet.pdf> and put it into x:\temp

- example (rtf convert/export):
"C:\Program Files\LibreOffice\program\soffice.exe" --headless --convert-to pdf:writer_pdf_Export myRTF.rtf --outdir x:\temp
this will create <myRTF.pdf> inside x:\temp

And of course, you can always execute this command line from your application (hb_Run() etc.)

PS: alternatively you can use win_Ole***() but that's another more complicated
(but more flexible in terms of output configuration etc) story.

regards,
Pete



User avatar
andyglezl
Posts: 1123
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 32 times
Been thanked: 68 times
Contact:

Post by andyglezl » Tue Apr 30, 2019 2:07 am

Hola

No he tenido tiempo de revisar a fondo esta prueba,
les dejo el ejemplo por si alguien le quiere seguir.
*---------------------------------------------------------------------
Hello

I have not had time to thoroughly review this test,
I leave the example in case someone wants to follow him.

RTF2PDF.rar
(2.3 KiB) Downloaded 28 times

De esta otra forma, habría que ver como evitar el dialogo de PREVIEW
*-----------------------------------------------------------------------------------------
In this other way, we should see how to avoid the PREVIEW dialogue

Code: Select all

/*_______________________________________________________________________________________________________*/
/*[•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•]*/
/*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*/
#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 "Covertir RTF a PDF"  WIDTH 250 HEIGHT 22 FONT "Consolas" SIZE 12  ;
					  ACTION PrintREB(  ) 
	
			@ 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(  )
	LOCAL lSuccess, nRow := 55, nCol := 70, nPag := 0, PrintPageCodeBlock := { || @ nRow , nCol PRINT "Pag. " + HB_NTOS( nPag++ ) CENTER }

	*SELECT PRINTER PDF 'MiPDF.pdf' TO lSuccess
	SELECT PRINTER DEFAULT TO lSuccess SAVEAS "MiPDF.PDF"
	IF lSuccess
		xForm.EDB_x.RTFLoadFile( "Lorem Ipsum.rtf", 4, .F.)
		*START PRINTDOC
		*	START PRINTPAGE
		*		@ 0,0 PRINT xForm.EDB_x.Value
		*	END PRINTPAGE
		*END PRINTDOC
		xForm.EDB_x.RTFPrint( { 0, -1 } , 20 , 20 , 20 , 20 , PrintPageCodeBlock )
		
		HMG_PressKey( VK_CONTROL+VK_S, VK_ALT+VK_G, VK_CONTROL+VK_C, VK_ALT+VK_F4 )
		
		
		EXECUTE FILE 'MiPDF.PDF'
	ENDIF
RETURN nil
Andrés González López
Desde Guadalajara, Jalisco. México.

Post Reply