Page 1 of 1

FWH Application generates PDF with image from MS SQL table

PostPosted: Tue Sep 06, 2022 10:37 pm
by cdmmaui
Hello Everyone,

Does anyone have a FWH example that creates a PDF with an image blob located in MS SQL and image as a file? I am looking to recreate the attached PDF.

https://s-c-technology.com/temp/SBMA05070.pdf

Thank you in advance for your help.

Re: FWH Application generates PDF with image from MS SQL table

PostPosted: Tue Sep 06, 2022 11:57 pm
by cmsoft
Puedes usar la potencia de la clase print.
Puedes imprimir imagenes, graficos, codigos de barra, texto en diferentes colores y fuentes, etc.
Code: Select all  Expand view

#include "FiveWin.ch"
#include "print.ch"


FUNCTION Main()

   local oPrn, i, oFont1, oFont2, nRow,;
    aLines :=  {"ESTA ES LA LINEA 1","ESTA ES LA LINEA 2","ESTA ES LA LINEA 3","ESTA ES LA LINEA 4",;
                "ESTA ES LA LINEA 5","ESTA ES LA LINEA 6","ESTA ES LA LINEA 7","ESTA ES LA LINEA 8"}
   DEFINE FONT oFont1  NAME "ARIAL"       SIZE 60,80 BOLD
   DEFINE FONT oFont2  NAME "CALIBRI"     SIZE 24,36
   PRINT oPrn NAME "Prueba" PREVIEW
      oPrn:SetPortrait()
      oPrn:SetPage(9)
      PAGE
          @ 1.6,.6 PRINT TO oPrn IMAGE "..\BITMAPS\Fw.bmp" SIZE 3, 1 CM
          @ 5  , 1 PRINT TO oPrn TEXT "TITULO DEL DOCUMENTO" SIZE 18,1 CM FONT oFont1 ALIGN "C"
          @ 6  , 1 PRINT TO oPrn TEXT "SUBTITULO DEL DOCUMENTO" SIZE 18,1 CM FONT oFont1 ALIGN "C" OUTLINE nRgb(170,150,12) SIZE .01
          nRow := 7
          FOR i := 1 TO LEN(aLines)
              @ nRow,1 PRINT TO oPrn TEXT aLines[i] SIZE 10,1 CM FONT oFont2 LASTROW nRow
          NEXT i
          @ 13, 2  PRINT TO oPrn  BAR CHART { { 14280, 20420, 12870, 25347, 7640 },;
                     { 8350, 10315, 15870, 5347, 12340 },;
                     { 12345, -8945, 10560, 15600, 17610 } } ;
                  SIZE 8,3 TITLE "Titulo De Grafico" CM
          @ 13, 10.2  PRINT TO oPrn  LINE CHART { { 14280, 20420, 12870, 25347, 7640 },;
                     { 8350, 10315, 15870, 5347, 12340 },;
                     { 12345, -8945, 10560, 15600, 17610 } } ;
                  SIZE 8,3 TITLE "Titulo De Grafico" CM

          @ 18, 2  PRINT TO oPrn IMAGE "..\BITMAPS\OLGA1.jpg" SIZE 6, 9 CM
          @ 18 ,16 PRINT TO oPrn TEXT "https://www.google.com" AS BARCODE  SIZE 3, 1 CM
      ENDPAGE
   ENDPRINT
   
RETURN NIL
 


Mira los ejemplos pdfharu2.prg pdfharu.prg en samples

Re: FWH Application generates PDF with image from MS SQL table

PostPosted: Wed Sep 07, 2022 12:11 am
by cdmmaui
Gracias Cesar!

Re: FWH Application generates PDF with image from MS SQL table

PostPosted: Wed Sep 07, 2022 2:31 am
by nageswaragunupudi
Code: Select all  Expand view
#include "fivewin.ch"

REQUEST FWHARU // Optional

function Main()

   local oCn, oRs
   local oPrn

   TPrinter():lUseHaruPDF := .t. // optional

   oCn   := FW_MSSQLDB()
   oRs   := FW_OpenRecordSet( oCn, "wwonders" )

   PRINT oPrn PREVIEW FILE "msimage.pdf"

   PAGE
      @ 1,1 PRINT TO oPrn IMAGE oRs:Fields( "Image" ):Value SIZE 4,4 INCHES
   ENDPAGE

   ENDPRINT

   oRs:Close()
   oCn:Close()

return nil
 

Re: FWH Application generates PDF with image from MS SQL table

PostPosted: Wed Sep 07, 2022 2:36 am
by cdmmaui
Hi Rao,

Thank you! Can I create lines as well and add an image from local hard drive? If so, can you provide a simple example?

Thank you!

Re: FWH Application generates PDF with image from MS SQL table

PostPosted: Wed Sep 07, 2022 4:53 am
by nageswaragunupudi
From a file on local hard drive:
Code: Select all  Expand view
    @ 1,1 PRINT TO oPrn IMAGE "c:\fwh\bitmaps\olga1.jpg" SIZE 3,4 INCHES
 


Lines:
Code: Select all  Expand view
oPrn:Line( nTop, nLeft, nBottom, nRight, oPen, cUnits )
// cUnits can be "INCHES", "CM", "MM". If omitted, pixels