Page 1 of 1

PRINT oPrn PDF

PostPosted: Sun Apr 21, 2013 8:20 am
by mag071
Saludos Desde Venezuela.

Como hago para enviar un reporte que tengo definido con
PRINT oPrn grabarlo a un archivo .PDF sin el boton del preview.

Se que el preview lo hace pero necesito hacerlo automaticamente.
sin mostrar el preview

he intentado colocando al principio del programa
TPreview():bSaveAsPDF := { |o| FWSavePreviewToPDF( o ) }

y luego al finalizar el ENDPRINT
FWSavePreviewToPDF( SELF )

me pide el nombre pero no me genera el archivo.
me dice
Error BASE/1004 Message not found: TLOGROS001:ODEVICE
Args:
[ 1] = O TLOGROS001

la idea es pasar un reporte a .pdf

Si lo hago con el boton de guardar , si lo hace correctamente.

Cuales son los pasos correctos para usar la funcion
FWSavePreviewToPDF( )

Agradecido de antemano por su colaboraciones.

Re: PRINT oPrn PDF

PostPosted: Sun Apr 21, 2013 2:12 pm
by Antonio Linares
Mario,

Una forma de hacerlo es la siguiente:

1. Hay que modificar la función function FWSavePreviewToPDF() que está en FWH/source/function/prv2pdf.prg
Code: Select all  Expand view
function FWSavePreviewToPDF( oPreview, cPDF, lOpen )

   local cOrient, oPDF
   local lPrinter := ! oPreview:IsKindOf( "TPREVIEW" )

   if LoadFreeImage() <= 32
      MsgAlert( "freeimage.dll not found" )
      return nil
   endif

   DEFAULT cPDF   := cGetFile( "PDF File (*.pdf)|*.pdf|", "Select PDF File to Save", ;
                               CurDir(), .t. )

   if ! Empty( cPDF )
      cPDF = cFileSetExt( cPDF, "pdf" )
      CursorWait()
      if ! lPrinter
         cOrient = If( oPreview:oDevice:nHorzSize() > oPreview:oDevice:nVertSize(), 'L', 'P' )
      else
         cOrient = If( oPreview:nHorzSize() > oPreview:nVertSize(), 'L', 'P' )
      endif
      oPdf = fwPdf():New( cPdf, cOrient )
      if ! lPrinter
         AEval( oPreview:oDevice:aMeta, { | cMeta | oPdf:AddMeta( cMeta ) } )
      else
         AEval( oPreview:aMeta, { | cMeta | oPdf:AddMeta( cMeta ) } )
      endif        
      oPdf:Close()
      CursorArrow()
     
      DEFAULT lOpen := MsgYesNo( "View " + cPDF + " (Y/N)?" )
     
      if lOpen
         if ! lPrinter
            ShellExecute( oPreview:oWnd:hWnd, "open", cPDF )
         else  
            ShellExecute( GetWndDefault(), "open", cPDF )
         endif  
      endif
   else
      cPDF  := nil
   endif

return cPDF
 


2. Y Ahora ya puedes generar el PDF de esta forma:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oPrn

   PRINT oPrn PREVIEW

      PAGE

      oPrn:CmSay( 2, 2, "Hello world" )

      ENDPAGE

      oPrn:lMeta = .F.

   ENDPRINT

   FWSavePreviewToPDF( oPrn )

return nil


Se puede mejorar, pero de momento creo que te servirá :-)

Re: PRINT oPrn PDF

PostPosted: Fri May 03, 2013 11:04 am
by pablovidal
Antonio y en un reporte como seria ???

Gracias

Re: PRINT oPrn PDF

PostPosted: Fri May 03, 2013 12:12 pm
by nageswaragunupudi
From FWH 13.04:

PRINT oPrn FILE "abc.pdf" --> Saves out put to abc.pdf silently
or
PRINT oPrn FILE 'PDF' --> prompts for a file name and saves to the file silently
or
PRINT oPrn PREVIEW FILE "abc.pdf" --> saves to 'abc.pdf' and displays abc.pdf

Re: PRINT oPrn PDF

PostPosted: Fri May 03, 2013 1:42 pm
by pablovidal
nageswaragunupudi, gracias por responder,

Pero No tengo esa versión, Tengo la 12.04

Re: PRINT oPrn PDF

PostPosted: Mon May 06, 2013 5:49 pm
by pablovidal
Me he actualizado a la 13.04 y esta opción no esta disponible

Re: PRINT oPrn PDF

PostPosted: Tue May 07, 2013 1:06 am
by nageswaragunupudi
This code is working for me with 13.04.
Please try
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oPrn, oFont

? 'start'

   PRINT oPrn FILE "yy.PDF" PREVIEW

      DEFINE FONT oFont NAME "VERDANA" SIZE 0,-20 OF oPrn

      PAGE

      oPrn:CmSay( 5, 5, "Hello world 3", oFont )

      ENDPAGE

   ENDPRINT

   ? 'done'

return nil