PRINT oPrn PDF

PRINT oPrn PDF

Postby mag071 » Sun Apr 21, 2013 8:20 am

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.
Mario Antonio González Osal
Venezuela
m a g 0 7 1 @ g m a i l. c o m
User avatar
mag071
 
Posts: 140
Joined: Thu Feb 02, 2006 12:09 pm
Location: Venezuela

Re: PRINT oPrn PDF

Postby Antonio Linares » Sun Apr 21, 2013 2:12 pm

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á :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: PRINT oPrn PDF

Postby pablovidal » Fri May 03, 2013 11:04 am

Antonio y en un reporte como seria ???

Gracias
Saludos,

Pablo Alberto Vidal
/*
------------------------------------------------------
Harbour 3.2.0, Fivewin 17.02, BCC7
------------------------------------------------------
*/
User avatar
pablovidal
 
Posts: 401
Joined: Thu Oct 06, 2005 10:15 pm
Location: Republica Dominicana

Re: PRINT oPrn PDF

Postby nageswaragunupudi » Fri May 03, 2013 12:12 pm

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10317
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: PRINT oPrn PDF

Postby pablovidal » Fri May 03, 2013 1:42 pm

nageswaragunupudi, gracias por responder,

Pero No tengo esa versión, Tengo la 12.04
Saludos,

Pablo Alberto Vidal
/*
------------------------------------------------------
Harbour 3.2.0, Fivewin 17.02, BCC7
------------------------------------------------------
*/
User avatar
pablovidal
 
Posts: 401
Joined: Thu Oct 06, 2005 10:15 pm
Location: Republica Dominicana

Re: PRINT oPrn PDF

Postby pablovidal » Mon May 06, 2013 5:49 pm

Me he actualizado a la 13.04 y esta opción no esta disponible
Saludos,

Pablo Alberto Vidal
/*
------------------------------------------------------
Harbour 3.2.0, Fivewin 17.02, BCC7
------------------------------------------------------
*/
User avatar
pablovidal
 
Posts: 401
Joined: Thu Oct 06, 2005 10:15 pm
Location: Republica Dominicana

Re: PRINT oPrn PDF

Postby nageswaragunupudi » Tue May 07, 2013 1:06 am

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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10317
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 146 guests

cron