Como crear PDF que pueda ser leido creado con EASYREPORT

Post Reply
User avatar
Armando
Posts: 3382
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 13 times
Contact:

Como crear PDF que pueda ser leido creado con EASYREPORT

Post by Armando »

Saludos al foro:

En mi aplicación desde la vista previa creo el PDF con Img2pdf sin mayor problema.

El tema es que mi cliente quiere abrir el PDF y copiar ciertos datos para pegarlos en otra aplicación
y eso no es posible desde el PDF que creo.

Alguna sugerencia?

Muy agradecido

Last edited by Armando on Fri Sep 04, 2026 2:29 am, edited 1 time in total.
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
karinha
Posts: 8716
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Has thanked: 33 times
Been thanked: 51 times
Contact:

Re: Como crear PDF que pueda ser leido

Post by karinha »

Estimado Armando, Hazlo así:

https://fivewin.com.br/index.php?/topic ... f-fw-1903/

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Antonio Linares
Site Admin
Posts: 44508
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 717 times
Been thanked: 311 times
Contact:

Re: Como crear PDF que pueda ser leido

Post by Antonio Linares »

Estimado Armando,

Usa Haru con FWH:

REQUEST FWHARU // añadir arriba del todo

TPrinter():lUseHaruPDF := .T.

Haru genera texto en vez de imágenes y por lo tanto es copiable :idea:

Revisa samples/report/pdfharu1.prg

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Armando
Posts: 3382
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 13 times
Contact:

Re: Como crear PDF que pueda ser leido

Post by Armando »

Amigos:

Muchas gracias por sus respuestas.

Por ahora estoy creando el PDF desde la vista previa usando img2pdf

Master Antonio:

En FWH2307\Samples\Report no tengo PdfHaru.Prg y
¿ FWSavePreviewToPDF( ) no es funcional?

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Antonio Linares
Site Admin
Posts: 44508
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 717 times
Been thanked: 311 times
Contact:

Re: Como crear PDF que pueda ser leido

Post by Antonio Linares »

El soporte para Haru se implementó un año despues :?

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Armando
Posts: 3382
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 13 times
Contact:

Re: Como crear PDF que pueda ser leido

Post by Armando »

MAster:

Lo encontré en FWH2512, le tirare un ojo.

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
Posts: 3382
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Been thanked: 13 times
Contact:

Re: Como crear PDF que pueda ser leido

Post by Armando »

Amigos:

Estoy usando EasyReport para crear el reporte, de hecho es una factura, alguien que me tire un ejemplo?

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Antonio Linares
Site Admin
Posts: 44508
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 717 times
Been thanked: 311 times
Contact:

Re: Como crear PDF que pueda ser leido creado con EASYREPORT

Post by Antonio Linares »

en FWH ya hay una factura hecha con EasyReport.

El diseño está en samples\yinvoice\invoice.vrd y el código que la rellena en samples\misc\yunus.prg (ViewInvoiceER())

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 44508
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 717 times
Been thanked: 311 times
Contact:

Re: Como crear PDF que pueda ser leido creado con EASYREPORT

Post by Antonio Linares »

La idea es: el .vrd pinta la factura; el PRG solo inyecta valores por ID de ítem.

Cómo está montada la factura

El invoice.vrd tiene 6 áreas:

┌──────┬─────────────────────┬──────────────────────────────────────────────────────┐
│ Área │ Archivo │ Qué es │
├──────┼─────────────────────┼──────────────────────────────────────────────────────┤
│ 1 │ invoice.v01 │ Cabecera: empresa, cliente, nº, fecha, vencimiento │
├──────┼─────────────────────┼──────────────────────────────────────────────────────┤
│ 2 │ invoice.v02 │ Títulos de columnas (código, descripción, cantidad…) │
├──────┼─────────────────────┼──────────────────────────────────────────────────────┤
│ 3 │ invoice.v03 │ Línea de detalle (fila clara) │
├──────┼─────────────────────┼──────────────────────────────────────────────────────┤
│ 6 │ invoiceSchatten.v03 │ Línea de detalle (fila sombreada, cebra) │
├──────┼─────────────────────┼──────────────────────────────────────────────────────┤
│ 4 │ invoice.v04 │ Totales: base, IVA, total │
├──────┼─────────────────────┼──────────────────────────────────────────────────────┤
│ 5 │ Ganze Seite │ Fondo de página (se imprime primero) │
└──────┴─────────────────────┴──────────────────────────────────────────────────────┘

Cada texto del diseñador tiene un ID. Ese ID es el que usas en ITEMIDS.

Código mínimo para imprimirla

#include "FiveWin.ch"
#include "easyrep.ch"

FUNCTION PrintInvoice( lPreview, oWnd )

LOCAL oVRD, n, nPrintArea := 3
LOCAL nTotal := 0, nVAT := 0
LOCAL aLines

// Cabecera de la factura (puedes venir de un DBF)
LOCAL cCompany := "EasyReport Comp."
LOCAL cAddress := "Calle Mayor 12" + CRLF + "28013 Madrid"
LOCAL cCIF := "B-12345678"
LOCAL cInvNum := "2026-0042"
LOCAL dDate := Date()
LOCAL dPayDate := Date() + 30
LOCAL nTaxRate := 21

// Líneas: código, descripción, cantidad, precio, dto
aLines := { ;
{ "A001", "Monitor 27 pulgadas", 2, 189.00, 0 }, ;
{ "A002", "Teclado mecanico", 1, 79.50, 5 }, ;
{ "A003", "Cable HDMI 2m", 3, 12.00, 0 } }

EASYREPORT oVRD NAME "yinvoice\invoice.vrd" ;
PREVIEW lPreview OF oWnd MODAL

IF oVRD:lDialogCancel
RETURN .F.
ENDIF

// 5 = fondo de página
PRINTAREA 5 OF oVRD

// 1 = cabecera (IDs del invoice.v01)
PRINTAREA 1 OF oVRD ;
ITEMIDS { 201, 500, 501, 602, 502, 603 } ;
ITEMVALUES { cCompany, cAddress, cCIF, cInvNum, ;
DToC( dDate ), DToC( dPayDate ) }

// 2 = títulos de columnas
PRINTAREA 2 OF oVRD

// 3 / 6 = líneas (cebra)
FOR n := 1 TO Len( aLines )
nTotal += aLines[ n, 3 ] * aLines[ n, 4 ] - aLines[ n, 5 ]

Code: Select all | Expand

  PRINTAREA nPrintArea OF oVRD ;
     ITEMIDS    { 200, 201, 202, 203, 204, 205 } ;
     ITEMVALUES { aLines[ n, 1 ], ;
                  aLines[ n, 2 ], ;
                  AllTrim( Str( aLines[ n, 3 ] ) ), ;
                  AllTrim( Str( aLines[ n, 4 ], 10, 2 ) ), ;
                  AllTrim( Str( aLines[ n, 5 ] ) ), ;
                  AllTrim( Str( aLines[ n, 3 ] * aLines[ n, 4 ] - aLines[ n, 5 ], 12, 2 ) ) }

  nPrintArea := If( nPrintArea == 3, 6, 3 )   // fila clara / sombreada

NEXT

nVAT := nTotal * nTaxRate / 100

// 4 = pie de totales
PRINTAREA 4 OF oVRD ;
ITEMIDS { 310, 311, 312, 313 } ;
ITEMVALUES { AllTrim( Str( nTotal, 12, 2 ) ), ;
AllTrim( Str( nTaxRate, 5, 2 ) ), ;
AllTrim( Str( nVAT, 12, 2 ) ), ;
AllTrim( Str( nTotal + nVAT, 12, 2 ) ) }

END EASYREPORT oVRD

RETURN .T.

Los IDs tienen que coincidir con los del diseñador. En invoice.v01 / invoice.v03 / invoice.v04 están así:

┌─────────┬─────────────────────────────────────────────────────┐
│ ID │ Campo │
├─────────┼─────────────────────────────────────────────────────┤
│ 201 │ Empresa │
├─────────┼─────────────────────────────────────────────────────┤
│ 500 │ Dirección cliente │
├─────────┼─────────────────────────────────────────────────────┤
│ 501 │ CIF │
├─────────┼─────────────────────────────────────────────────────┤
│ 602 │ Nº factura │
├─────────┼─────────────────────────────────────────────────────┤
│ 502 │ Fecha │
├─────────┼─────────────────────────────────────────────────────┤
│ 603 │ Vencimiento │
├─────────┼─────────────────────────────────────────────────────┤
│ 200–205 │ Código, descripción, cantidad, precio, dto, importe │
├─────────┼─────────────────────────────────────────────────────┤
│ 310–313 │ Base, % IVA, cuota IVA, total │
└─────────┴─────────────────────────────────────────────────────┘

Si el texto no sale, casi siempre es que el ID del PRG no es el del .v01.

Cómo verlo y editarlo

  1. Diseñador:

cd C:\fwteam\samples\EasyReport
C:\fwteam\samples\build_new.bat erdsample hb32

Abre ..\yinvoice\invoice.vrd y mira cada área. En cada texto, el ID es el número que luego pasas en ITEMIDS.

  1. App de facturación completa (clientes, líneas, preview):

cd C:\fwteam\samples\misc
C:\fwteam\samples\build_new.bat yunus hb32

En Invoices hay un botón que llama a ViewInvoiceER().

Flujo típico de una factura

PRINTAREA 5 // fondo / membrete de página
PRINTAREA 1 // cabecera (datos fijos de esta factura)
PRINTAREA 2 // títulos de columnas
loop líneas:
PRINTAREA 3 o 6 // cada fila
si se acaba la página: PAGEBREAK + cabecera otra vez
PRINTAREA 4 // totales (reserva sitio: oVRD:nPageBreak - oVRD:aAreaHeight[4])
END EASYREPORT

Si hay muchas líneas, mira samples\EasyReport\examples\SourceExample2.prg: comprueba oVRD:nNextRow > oVRD:nPageBreak y hace PAGEBREAK oVRD antes de que los totales se corten.

PDF directo (sin diálogo):

EASYREPORT oVRD NAME "yinvoice\invoice.vrd" PREVIEW .T. FILE "factura.pdf"

Otra vía: expresiones (Cargo)

En SourceExample1.prg (albarán/pedido) no se pasan todos los IDs. El diseñador usa expresiones tipo oVRD:Cargo[1] y el PRG solo rellena el array:

oVRD:Cargo := { "Nr. 12345 Date: 5.9.2004", ; // 1
"Testclient", ; // 2
... }
PRINTAREA 5 OF oVRD // el .vrd ya sabe qué Cargo[n] pintar

Para una factura, ITEMIDS/ITEMVALUES (como yunus) suele ser más claro.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply