Preview a PDF con imagen de fondo

Re: Preview a PDF con imagen de fondo

Postby sysctrl2 » Wed Jun 19, 2024 11:43 pm

tampoco funciona directo:
PRINTER oPrn FILE cFilePdf

Code: Select all  Expand view  RUN

#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 "
User avatar
sysctrl2
 
Posts: 1021
Joined: Mon Feb 05, 2007 7:15 pm

Re: Preview a PDF con imagen de fondo

Postby cmsoft » Fri Jun 21, 2024 11:14 am

Efectivamente tampoco funciona directo.
Alguna idea de como solucionar esto?
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Preview a PDF con imagen de fondo

Postby karinha » 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
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Preview a PDF con imagen de fondo

Postby cmsoft » Fri Jun 21, 2024 12:11 pm

Muchas gracias por las pruebas Jao!
Esperemos a ver que dice Mr. Rao
Saludos
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Preview a PDF con imagen de fondo

Postby cmsoft » Mon Jun 24, 2024 11:57 am

+1
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Preview a PDF con imagen de fondo

Postby nageswaragunupudi » Thu Jul 04, 2024 4: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: Select all  Expand view  RUN
TPrinter():lUseHaruPDF := .t.

at the top of your program.

Please try this change and let us know.
Regards

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

Re: Preview a PDF con imagen de fondo

Postby nageswaragunupudi » Thu Jul 04, 2024 4: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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Preview a PDF con imagen de fondo

Postby cmsoft » Thu Jul 04, 2024 10:50 am

Muchas gracias Mr. Rao.
Aguardaré la solucion
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Preview a PDF con imagen de fondo

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Preview a PDF con imagen de fondo

Postby nageswaragunupudi » Thu Jul 04, 2024 1:52 pm

test-1
Note: DO NOT use harupdf.
Code: Select all  Expand view  RUN
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


Image

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

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

Re: Preview a PDF con imagen de fondo

Postby cmsoft » Fri Jul 05, 2024 3: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.
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Preview a PDF con imagen de fondo

Postby nageswaragunupudi » Fri Jul 05, 2024 5: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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Preview a PDF con imagen de fondo

Postby nageswaragunupudi » Sat Jul 06, 2024 8:04 am

Image

Is this pdf okay now?
Regards

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

Re: Preview a PDF con imagen de fondo

Postby cmsoft » Sat Jul 06, 2024 12:40 pm

Este ultimo, se ver perfecto!
Como lo lograste?
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Preview a PDF con imagen de fondo

Postby nageswaragunupudi » Sat Jul 06, 2024 2: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: Select all  Expand view  RUN
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


Image

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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

PreviousNext

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests