FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Preview a PDF con imagen de fondo
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: Preview a PDF con imagen de fondo
Posted: Wed Jun 19, 2024 11:43 PM
tampoco funciona directo:
PRINTER oPrn FILE cFilePdf
Code (fw): Select all Collapse
#include "FiveWin.ch"
FUNCTION Main()
   //                1  2       3     4      5   6   7     8       9
   Local aDatos := {;
      {"Juan 1","Pago 1","Juan","Pedro","1000","Algo 1"},;
      {"Juan 2","Pago 2","Juan","Pedro","2000","Algo 2"},;
      {"Juan 3","Pago 3","Juan","Pedro","3000","Algo 3"},;
      {"Juan 4","Pago 4","Juan","Pedro","4000","Algo 4"},;
      {"Juan 5","Pago 5","Juan","Pedro","5000","Algo 5"},;
      {"Juan 6","Pago 6","Juan","Pedro","6000","Algo 6"},;
      {"Juan 7","Pago 7","Juan","Pedro","7000","Algo 7"};
      }
   ImprimoRecibos(aDatos)

RETURN nil

STATIC FUNCTION ImprimoRecibos( aDatos )

   LOCAL oPrn, oFont,n := 0, nRow, i := 1, aSizes
   LOCAL cFilePdf := cTempFile( ".\", ".pdf" )
   LOCAL cMsg := "Exportando a PDF: Aguarda un momento"

   DEFINE FONT oFont NAME "Arial" SIZE 36, 70

   //PRINT oPrn DOC "recibos"  PREVIEW
   PRINTER oPrn FILE cFilePdf // NAME 'SysCtrl CFDI Report'

   //aSizes := oPrn:Units2Pix(0,0,7.2,327.0,'CM')
   //xbrowse (aSizes)

   //oPrn:SetSize( aSizes[3], aSizes[4] )
   nRow := 4
   PAGE
   @ 0,0 PRINT TO oPrn IMAGE "logo.jpg" SIZE oPrn:nHorzRes(), oPrn:nVertRes() PIXEL GRAY
   @ nRow ,  1 PRINT TO oPrn TEXT aDatos[i,1] SIZE 7,.5 CM FONT oFont LASTROW nRow ALIGN "C"
   @ nRow ,  1 PRINT TO oPrn TEXT aDatos[i,2] SIZE 7,.5 CM FONT oFont LASTROW nRow ALIGN "C"
   @ nRow ,  1 PRINT TO oPrn TEXT aDatos[i,3] SIZE 7,.5 CM FONT oFont LASTROW nRow ALIGN "C"
   @ nRow ,  1 PRINT TO oPrn TEXT aDatos[i,4] SIZE 7,.5 CM FONT oFont LASTROW nRow ALIGN "C"
   @ nRow ,  1 PRINT TO oPrn TEXT aDatos[i,5] SIZE 7,.5 CM FONT oFont LASTROW nRow ALIGN "C"
   @ nRow ,  1 PRINT TO oPrn TEXT aDatos[i,6] SIZE 7,.5 CM FONT oFont LASTROW nRow ALIGN "C"
   @ nRow ,  1 PRINT TO oPrn IMAGE "..\bitmaps\olga1.jpg" SIZE 4, 4 CM LASTROW nRow
   ENDPAGE

   ENDPRINT

   MSGRUN( cMsg, "Usuario", {|| Shellexecute( 0,"open", cFilePdf )  } )

RETURN nil
Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Preview a PDF con imagen de fondo
Posted: Fri Jun 21, 2024 11:14 AM

Efectivamente tampoco funciona directo.

Alguna idea de como solucionar esto?

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Preview a PDF con imagen de fondo
Posted: Fri Jun 21, 2024 12:08 PM

Lo intenté de todas las formas posibles, pero no funciona porque el comando GRIS(GRAY) pinta toda la hoja INFORME. Si entiendo. jajajaja.

Quizás el Maestro RAO tenga una solución. Vamos esperar.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Preview a PDF con imagen de fondo
Posted: Fri Jun 21, 2024 12:11 PM

Muchas gracias por las pruebas Jao!

Esperemos a ver que dice Mr. Rao

Saludos

Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Preview a PDF con imagen de fondo
Posted: Mon Jun 24, 2024 11:57 AM

+1

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Preview a PDF con imagen de fondo
Posted: Thu Jul 04, 2024 04:46 AM
Asi se ve el PDF generado desde el preview
Entire page is filled with gray color.

It appears that MSWord is not installed on the target PC. In that case, fwh's own pdf function is used and this function is causing this problem.

You can avoid this by setting
Code (fw): Select all Collapse
TPrinter():lUseHaruPDF := .t.
at the top of your program.

Please try this change and let us know.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Preview a PDF con imagen de fondo
Posted: Thu Jul 04, 2024 04:53 AM

Next important issue.

You like to display the "fondo.jpg" in the background like a watermark.

For this purpose you can use GRAY or even better ALPHALEVEL <n>.

In this case, both preview and printing on printer works as expected, but the PDF still does not show the image as watermark.

This still remains a problem. I am unable to provide an immediate solution.

Note: I am unable to write Gray or Alpha levels to PDF using harupdf now.

We also have a function FWWATERMARK( hbmp ) but this does not seem to help either.

We will keep searching to a solution. We keep this in our TODO list.

However you can generate PDF using fondo.jpg without the entire page painted with Gray color.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Preview a PDF con imagen de fondo
Posted: Thu Jul 04, 2024 10:50 AM

Muchas gracias Mr. Rao.

Aguardaré la solucion

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Preview a PDF con imagen de fondo
Posted: Thu Jul 04, 2024 11:33 AM
Please try this change and let us know.
Please also provide your feedback on this issue.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Preview a PDF con imagen de fondo
Posted: Thu Jul 04, 2024 01:52 PM
test-1
Note: DO NOT use harupdf.
Code (fw): Select all Collapse
function test()

   local oPrn, oFont, nRow
   local hBmp, n

   hBmp := GrayFondo()

   PRINT oPrn PREVIEW
   oPrn:SetPage( 9 ) // A4 size

   DEFINE FONT oFont NAME "ARIAL" SIZE 0,-22  OF oPrn

   PAGE
   @ 1,0 PRINT TO oPrn IMAGE hBmp SIZE 7,nil INCHES

   nRow := 4
   for n := 1 to 12
      @ nRow, 2 PRINT TO oPrn TEXT NTOCMONTH( n ) INCHES FONT oFont LASTROW nRow
   next
   @ 4, 5.2 PRINT TO oPrn IMAGE "..\bitmaps\olga1.jpg" SIZE 2.5,3 INCHES ALIGN "" LASTROW nRow

   ENDPAGE

   ENDPRINT
   RELEASE FONT oFont
   DeleteObject( hBmp )

return nil

function GrayFondo()

   local hBmp, hGray

   hBmp  := FW_ReadImage( , "..\bitmaps\fondo.jpg" )[1]
   hGray := bmp2gray( hbmp )
   DeleteObject( hBmp )

return hGray


We need to still lighten the water mark.
We will keep improving.
Please provide your feedback
Regards



G. N. Rao.

Hyderabad, India
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Preview a PDF con imagen de fondo
Posted: Fri Jul 05, 2024 03:16 PM

Hice las pruebas. El resultado de la marca de agua es muy similar al enviado por Ud.

Lo que noto que el proceso de la previsualización tarda aproximadamente 25 segundos.

El PDF obtenido tiene la marca de agua ya sin el fondo gris.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Preview a PDF con imagen de fondo
Posted: Fri Jul 05, 2024 05:04 PM
cmsoft wrote:Hice las pruebas. El resultado de la marca de agua es muy similar al enviado por Ud.
Lo que noto que el proceso de la previsualización tarda aproximadamente 25 segundos.
El PDF obtenido tiene la marca de agua ya sin el fondo gris.
1) Does this serve your purpose for the time being?

2) We will keep working on it. Objectives: (a) Make the water-mark even lighter and (b) test with alpha too and (c) make it work with harupdf also.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Preview a PDF con imagen de fondo
Posted: Sat Jul 06, 2024 08:04 AM


Is this pdf okay now?
Regards



G. N. Rao.

Hyderabad, India
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Preview a PDF con imagen de fondo
Posted: Sat Jul 06, 2024 12:40 PM

Este ultimo, se ver perfecto!

Como lo lograste?

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Preview a PDF con imagen de fondo
Posted: Sat Jul 06, 2024 02:48 PM
You can easily do it for print-preview as well as printing on paper using the clause ALPHALEVEL <nAlpha> with the command PRINT IMAGE.
But till now, we have problems in saving this image as PDF.
FWH uses FWPDF class for saving to PDF using PdfHaru library.
FWH uses its FWPDF class to save PDF using HaruPDF. We did not handle alphalevel in the method printimage() of this class. Now we enhanced this class to handle alphalevel.
With this enhancement:
Code (fw): Select all Collapse
function PdfAlpha()

   local oPrn, oFont, nRow
   local hBmp, n

   TPrinter():lUseHaruPdf := .t.

   PRINT oPrn PREVIEW

   oPrn:SetPage( 9 ) // A4 size
   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-22  OF oPrn

   PAGE
      @ 0,1 PRINT TO oPrn IMAGE "..\bitmaps\fondo.jpg" SIZE 7,10 INCHES ALIGN "" ALPHALEVEL 80
      nRow := 4
      for n := 1 to 12
         @ nRow, 2 PRINT TO oPrn TEXT NTOCMONTH( n ) SIZE 7,0.37 INCHES FONT oFont LASTROW nRow
      next
      @ 4.7, 5 PRINT TO oPrn IMAGE "..\bitmaps\pngs\2.png" SIZE 2.5,5 INCHES ALIGN "" ALPHALEVEL 150
   ENDPAGE

   ENDPRINT

   RELEASE FONT oFont

return nil


Notes:
Works with enhanced FWPDF class only using lUseHaruPDF := .t.
Does not work with default pdf generator or even with the commercial image2pdf.

We will let you know the changes you need to make to FWPDF class in the next post
Regards



G. N. Rao.

Hyderabad, India