FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour APORTE. Exportar a PDF
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
APORTE. Exportar a PDF
Posted: Wed Jan 05, 2011 03:05 PM
Fivewinners.

Aqui una forma INDOLORA de exportar desde el PREVIEW de la TPrinter o de la TReport directamente a PDF sin modificar las clases

Pasos.
Al inicio de nuestro sistema ( ojala al inicio de la Function MAIN() )
Code (fw): Select all Collapse
RPrevUserBtns({|oPreview,oBar| ReportExtend(oPreview,oBar) })


Crear la funcion ReporExtend().. o cualquier otro nombre que le quieran poner
Code (fw): Select all Collapse
Function ReportExtend( oPreview, oBar )

  Define Button of oBar;
         Resource "SPDF";
         Tooltip "Exportar a PDF";
         Action REP2PDF(oPreview)

Return Nil


EL ICONO 'SPDF', es un icono propio, en mi caso una copia del icono del ADOBE ACROBAT READER, que deben agregar manualmente al PREV32.DLL

Y esta funcion hace la magia...

Code (fw): Select all Collapse
Function REP2PDF(oPreview)
Local cString
Local cDdestino
Local cFile:="PDF" + StrTran(TIME(),":","") + ".pdf"
Local cDir:=cGetdir32("Elija Directorio para PDF") + "\"
Local x:=0
Local cTexto:=""

cDestino:=cDir + cFile

If Len(oPreview:aMeta) = 1
   cString:="nConvert -o " + cDestino + " -quiet -out pdf -c 5 " + oPreview:aMeta[1]
Else
   If File("listaemf.txt")
      Delete File listaemf.txt
   Endif

   For x=1 To Len(oPreview:aMeta)
       cTexto:=cTexto + oPreview:aMeta[x] + CRLF
   Next
   MemoWrit("listaemf.txt",cTexto )

   cString:="nConvert -multi -o " + cDestino + " -quiet -out pdf -c 5 -l listaemf.txt"
Endif

MsgRun("Espere","Exportando a PDF", {|| WAITRUN(cString,0 ) } )

Return Nil


NO AGREGA EL BOTON A LA BARRA DEL PREVIEW SI APPISTHEMED() RETORNA .T.
EL RPREVIEW ACTUAL NO CONSIDERA LOS bUserBtns PARA AGREGARLOS A LA REBAR ( Antonio.. aqui un BUG )

Por lo tanto
Tambien en el Main.PRG agregar

Code (fw): Select all Collapse
Function IsAppThemed()
Return .F.


Solicita el lugar donde grabar el PDF
EL nombre del archivo creado es PDFHHMMSS ( Donde HHMMSS es lo devuelto por TIME() ), pueden modificarlo para crear sus propios nombres automaticamente.
Se requiere del archivo nConvert en el mismo directorio del ejecutable, que pueden descargar aqui

http://www.xnview.com/en/download_nc.html

Requiere de su compra o registro, pero lo pueden descargar sin problemas para "probar"
Funciona solamente con el TReport y TPrinter ORIGINALES, no las pude probar con ninguna de las clases modificadas por otros.

Esta rutina esta probada con FWH 905 en adelante, pero si tienen alguna anterior solo deben meterle mano al rPreview para agregar "manualmente" el boton al Preview, y llamar a la rutina de exportacion..

Espero les sea de utilidad.
Personalmente busque varias soluciones, pero esta solo requiere que copie el nConvert.exe junto con mi ejecutable y nada mas, sin instalar Impresoras virtuales ni nada, absolutamente transparente al usuario.

Saludos.
Desde Chile
Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: APORTE. Exportar a PDF
Posted: Thu Jan 06, 2011 04:06 PM
Very good example demonstrating the extend capability of rpreview.prg.

Only one suggestion:
EL ICONO 'SPDF', es un icono propio, en mi caso una copia del icono del ADOBE ACROBAT READER, que deben agregar manualmente al PREV32.DLL

It is not necessary to add the resource to PREV32.DLL. The resource can be in our own rc file or dll.
RPreview code is written to refer to our resources ( not prev32.dll ) to use the user defined buttons. The very intention of the code is not to modify any of the libraries or resources provided by FWH.
Regards



G. N. Rao.

Hyderabad, India
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: APORTE. Exportar a PDF
Posted: Thu Jan 06, 2011 06:45 PM
It is not necessary to add the resource to PREV32.DLL. The resource can be in our own rc file or dll.
RPreview code is written to refer to our resources ( not prev32.dll ) to use the user defined buttons. The very intention of the code is not to modify any of the libraries or resources provided by FWH.
Very good example demonstrating the extend capability of rpreview.prg.

Only one suggestion:
EL ICONO 'SPDF', es un icono propio, en mi caso una copia del icono del ADOBE ACROBAT READER, que deben agregar manualmente al PREV32.DLL

It is not necessary to add the resource to PREV32.DLL. The resource can be in our own rc file or dll.
RPreview code is written to refer to our resources ( not prev32.dll ) to use the user defined buttons. The very intention of the code is not to modify any of the libraries or resources provided by FWH.


Rao...
Good to know
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: APORTE. Exportar a PDF
Posted: Thu Jan 06, 2011 07:13 PM

muy buena aportacion Adolfo, gracias,

tengo abierto el PDF final con el acrobat reader, y quiero buscar un dato dentro del PDF,
y no funciona, es porque la conversion es desde una imagen ?

saludos..

Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: APORTE. Exportar a PDF
Posted: Thu Jan 06, 2011 08:01 PM

Yes .. es un pdf a partir del archivo emf, una imagen...

Saludos

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 27
Joined: Fri Apr 24, 2009 03:49 AM
Re: APORTE. Exportar a PDF
Posted: Sat Jan 08, 2011 04:07 AM

Excelente adolfo funciona perfecto cuando lo hago desde el programa principal, pero cuando quiero ponerlo en el rpreview no funciona; dime que varibles mandarle a la la funcion REP2PDF(.....).

Fivewin 1412

xharbour 1.2.3

harbour 3.2

bcc 7.00
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: APORTE. Exportar a PDF
Posted: Sat Jan 08, 2011 07:46 PM
Hola:

Añade esta función

Code (fw): Select all Collapse
Function PDFSAVE(aFiles)
Local cString
Local cDestino
Local cFile:="PDF" + StrTran(TIME(),":","") + ".pdf"

Local x:=0
Local cTexto:=""


cDestino := cGetFile("Exportar Informe (*.pdf) | *.pdf |","Guardar como...", NIL, nil, .T., .T. )



If Len(aFiles) = 1
   cString:="nConvert -o " + cDestino + " -quiet -out pdf -c 5 " + aFiles[1]
Else
   If File("listaemf.txt")
      Delete File listaemf.txt
   Endif

   For x=1 To Len(aFiles)
       cTexto:=cTexto + aFiles[x] + CRLF
   Next
   MemoWrit("listaemf.txt",cTexto )

   cString:="nConvert -multi -o " + cDestino + " -quiet -out pdf -c 5 -l listaemf.txt"
Endif

MsgRun("Espere","Exportando a PDF", {|| WAITRUN(cString,0 ) } )


MsgAlert("El fichero "+ AllTrim(cDestino) +".PDF ha sido creado correctamente.", " Exportar PDF ")

Return Nil



Y en rpreview.prg

En el MENU oMenu

//PDF
If oDevice:aMeta != NIl
MENUITEM "Exportar a PDF" ACTION PDFSave( oDevice:aMeta ) RESOURCE "SAVE"
SEPARATOR
EndIf
//
Saludos,



Eduardo
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: APORTE. Exportar a PDF
Posted: Sat Jan 08, 2011 11:52 PM

Persi..

Si tienes un rPreview modificado. la opcion que te dio MgSoft es la correcta.

Saludos

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
Re: APORTE. Exportar a PDF
Posted: Mon Jan 17, 2011 11:23 AM
Adolfo wrote:Fivewinners.

Al inicio de nuestro sistema ( ojala al inicio de la Function MAIN() )
Code (fw): Select all Collapse
RPrevUserBtns({|oPreview,oBar| ReportExtend(oPreview,oBar) })


Crear la funcion ReporExtend().. o cualquier otro nombre que le quieran poner


¿RPrevUserBtns es un método nuevo de la clase Preview?
Un saludo



Manuel
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: APORTE. Exportar a PDF
Posted: Mon Jan 17, 2011 11:42 AM

Manuel...

Esta presente desde FWH9.05 (Mayo 2009)

Saludos

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
Re: APORTE. Exportar a PDF
Posted: Mon Jan 17, 2011 04:25 PM
Adolfo wrote:Manuel...

Esta presente desde FWH9.05 (Mayo 2009)

Saludos



Gracias Adolfo.
Un saludo



Manuel

Continue the discussion