QR-CODE

Re: QR-CODE

Postby karinha » Sat May 06, 2023 2:14 pm

Horácio, mandame:

kapiabafwh@gmail.com

asi, pongo en el Mega Upload, puede ser?

Gracias, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7315
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: QR-CODE

Postby horacio » Mon May 08, 2023 1:02 pm

Hola , te envié un enlace a mi drive para que puedas bajar las librerías. Avisame si te llegó y te dejo aquí el código de ejemplo

Code: Select all  Expand view

#include "fivewin.ch"
#include "harupdf.ch"
#include "hbzebra.ch"
#define rLEFT    1
#define rTOP     2
#define rRIGHT   3
#define rBOTTOM  4
Static Pdf
Static oRsR
Static oRsF
Static cFile
Static cBarras

//----------------------------------------------------------------------------//
Function Recibo_Pdf_2()

    Local i
    Local n
    Local tw
   Local nFor
   Local font
   Local page  
    Local nWidth
    Local cFecha
    Local nHeight
    Local cAlumno
    Local oRsTran
    Local aRecibos
    Local cTipoIva
    Local def_font
    Local samp_text
    Local aFacturas
    Local oProgreso
    Local cTipoDocumento
    Local aRect          := Array( 4 )
    Local nTotal       := 0
    Local nTotalA      := 0
    Local cCarpeta     := "C:\crono\pdf"
    Local nTCheques    := 0
    Local lSelected    := .f.
    Local cNomArchivo  := "prueba.pdf"
    Local cCarpeta_pdf := Memvar -> o : cFolderPdf
    Local font_list    := { ;
                         "Courier",                 ;
                         "Courier-Bold",             ;
                         "Courier-Oblique",          ;
                         "Courier-BoldOblique",      ;
                         "Helvetica",                ;
                         "Helvetica-Bold",           ;
                         "Helvetica-Oblique",        ;
                         "Helvetica-BoldOblique",    ;
                         "Times-Roman",              ;
                         "Times-Bold",               ;
                         "Times-Italic",             ;
                         "Times-BoldItalic",         ;
                         "Symbol",                   ;
                         "ZapfDingbats"              }
    Memvar o
    /*
    cBarras := StrTran( o : cCuit, '-', '' ) + '015' + StrZero( Val( o : nPtoVta ), 5 ) + Alltrim( o : oRs : Cae ) +;
                  DToS( o : oRs : fecha_vencimiento )
    cBarras += Alltrim( DigitoVerificador( cBarras ) )
    oRsR := o : oRs : Clone()
    */

   
    oRsR := o : oRs : Clone()
    If( oRsR : es_credito == 1 .or. oRsR : aplica_credito == 1 )
        Return 0
    End
    cBarras := '{"ver":1,"fecha":"' + TransformaFecha( oRsR : fecha ) + '","cuit": ' + StrTran( o : cCuit, '-', '' ) + ',"ptoVta":' + Alltrim( o : nPtoVta ) + ',"tipoCmp":15,"nroCmp":' +;
                     Alltrim( Str( oRsR : nro_recibo ) ) + ',"importe":' + Alltrim( Str( oRsR : contado + oRsR : cheques + oRsR : transferencia + oRsR : tarjeta ) ) +;
                     ',"moneda":"PES","ctz":1,"tipoDocRec":' + If( !Empty( oRsR : cuit ), '80', '96' ) + ',"nroDocRec":' + If( !Empty( oRsR : cuit ), StrTran( oRsR : cuit, "-", "" ),;
                     StrTran( oRsR : num_doc, ".", "" ) ) + ',"tipoCodAut":"E","codAut":' + Alltrim( oRsR : Cae ) + '}'

    If( !Empty( o : oBrwR : aSelected    ) )
        aRecibos := AClone( o : oBrwR : aSelected )
        oProgreso := TTProgreso() : New()      
        oProgreso : oMeter : nTotal :=  Len( o : oBrwR : aSelected  )      
        lSelected := .t.
    Else
        aRecibos := { oRsR : Recno() }
    End 
                 
    For nFor := 1 To Len( aRecibos )
        oRsR : GoTo( aRecibos[ nFor ] )
        If( lSelected )
            oProgreso : oMeter : Set( nFor )
        End
        If( nFor % 5 == 0 )
            SysRefresh()
        End 
        If( oRsR : transferencia # 0 )
            oRsTran := o : oCon : RowSet( "select banco, f_acredita from cheques where id_recibo = ?", { oRsR : nro_recibo } )
        End 
        cFile   := "R" + StrZero( Val( o : nPtoVta ), 4 ) + "-" + StrZero( oRsR : nro_recibo, 6 ) + ".pdf"
        If( File( cCarpeta_pdf + "\" + cFile ) )
            Ferase(  cCarpeta_pdf + "
\" + cFile )
        End
        cFecha  := "
Fecha: " + DToC( Date() )
        pdf     := HPDF_New()
        page    := HPDF_AddPage( pdf )
        nHeight := HPDF_Page_GetHeight( page )
    nWidth  := HPDF_Page_GetWidth( page )
   
       HPDF_SetCompressionMode( pdf, HPDF_COMP_ALL )
   
       HPDF_Page_SetLineWidth( page, 1 )
       HPDF_Page_Rectangle( page, 20, 20, nWidth - 40, nHeight - 40 )
       HPDF_Page_Stroke( page )
       HPDF_Page_SetSize( page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT )
       HPDF_GetEncoder( pdf, "
CP1257" )
   
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 6 )
        cAlumno := Alltrim( oRsR : alumno ) + "
- Curso: " + Alltrim( oRsR : cur ) + " - Sección: " + oRsR : sec
        HPDF_Page_TextOut( page, 20, nHeight - 18, cAlumno )

        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 18 )

        tw := HPDF_Page_TextWidth( page, "
Colegio Nuestra Sra." )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 50, "
Colegio Nuestra Sra." )
        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 24 )

        tw := HPDF_Page_TextWidth( page, "
Del Rosario" )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 70, "
Del Rosario" )
       
        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 12 )

        tw := HPDF_Page_TextWidth( page, Alltrim( o : oRec : domicilio ) )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 100, Alltrim( o : oRec : domicilio ) )
        tw := HPDF_Page_TextWidth( page, "
( " + Alltrim( o : oRec : c_postal ) + " ) " + Alltrim( o : oRec : localidad ) )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 115, "
( " + Alltrim( o : oRec : c_postal ) + " ) " + Alltrim( o : oRec : localidad ) )
        tw := HPDF_Page_TextWidth( page, "
Tel: " + Alltrim( o : oRec : Telefono ) )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 130, "
Tel: " + Alltrim( o : oRec : Telefono ) )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica-Bold", NIL ), 12 )
        tw := HPDF_Page_TextWidth( page, "
I.V.A EXENTO" )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 160, "
I.V.A EXENTO" )
       HPDF_Page_EndText( page )
        cTipoDocumento := "
RECIBO"
       
        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_BeginText( page )
       HPDF_Page_SetFontAndSize( page, def_font, 24 )
        tw := HPDF_Page_TextWidth( page, cTipoDocumento )
        HPDF_Page_TextOut( page, ( nWidth + ( nWidth / 2 ) - tw - 20 ) / 2, nHeight - 50, cTipoDocumento )
       
       
        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 14 )
        tw := HPDF_Page_TextWidth( page, "
Nro. " + StrZero( 1, 4 ) + "-" + StrZero( oRsR : nro_recibo, 8 ) )
        HPDF_Page_TextOut( page, ( nWidth + ( nWidth / 2 ) - tw - 20 ) / 2, nHeight - 90, "
Nro. " + StrZero( 1, 4 ) + "-" + StrZero( oRsR : nro_recibo, 8 ) )
        tw := HPDF_Page_TextWidth( page, cFecha )
        HPDF_Page_TextOut( page, ( nWidth + ( nWidth / 2 ) - tw - 20 ) / 2, nHeight - 105, cFecha )
        def_font := HPDF_GetFont( pdf, "
Helvetica", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 6 )
        HPDF_Page_TextOut( page, ( nWidth / 2 ) + 40, nHeight - 150, "
C.U.I.T: " + o : oRec : cuit )
        HPDF_Page_TextOut( page, ( nWidth / 2 ) + 40, nHeight - 160, "
FECHA DE INICIO DE ACTIVIDADES " + DToC( o : oRec : f_inicio ) )
        HPDF_Page_EndText( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, 20, 675)
       HPDF_Page_LineTo( page, nWidth - 20 , 675)
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, nWidth / 2, nHeight - 20 )
       HPDF_Page_LineTo( page, nWidth / 2, nHeight - 25 )
        HPDF_Page_Stroke( page )
       
       HPDF_Page_SetLineWidth( page, 0 )
       HPDF_Page_Rectangle( page, nWidth / 2 - 18, 776, 36, 40 )
       HPDF_Page_Stroke( page )
       
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica-Bold", NIL ), 36 )
        tw := HPDF_Page_TextWidth( page, "
C" )
        HPDF_Page_TextOut( page, ( nWidth - tw ) / 2 , nHeight - 58, "
C" )
       HPDF_Page_EndText( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, nWidth / 2, nHeight - 65 )
       HPDF_Page_LineTo( page, nWidth / 2, nHeight - 166 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 8 )
        HPDF_Page_TextOut( page, 50, nHeight - 180, "
SRES.:" )
        HPDF_Page_TextOut( page, nWidth - 160 , nHeight - 180, "
C.U.I.T.:" )
        HPDF_Page_TextOut( page, 31, nHeight - 195, "
DOMICILIO:" )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica-Bold", NIL ), 09 )
        HPDF_Page_TextOut( page, 80, nHeight - 180, Alltrim( oRsR : facturar_a ) )
        HPDF_Page_TextOut( page, nWidth - 120, nHeight - 180, oRsR : cuit )
            cTipoIva := Alltrim( oRsR : domicilio ) + "
 " + Alltrim( oRsR : numero ) + If( !Empty( oRsR : dpto ), " Dpto " + Alltrim( oRsR : dpto ), "" ) + If( !Empty( oRsR : localidad ), " - " + Alltrim( oRsR : localidad ), "" )
        HPDF_Page_TextOut( page, 80, nHeight - 195, cTipoIva )
       HPDF_Page_EndText( page )
            
        HPDF_Page_SetLineWidth( page, 0 )
        HPDF_Page_MoveTo( page, 20, 640 )
       HPDF_Page_LineTo( page, nWidth - 20 , 640 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetRGBFill( page, 0.75, 0.75, 0.75 )
        HPDF_Page_Rectangle( page, 21, 614, nWidth - 42, 25 )
        HPDF_Page_Fill(page)
        HPDF_Page_SetRGBFill( page, 0.0, 0.0, 0.0 )
       
        HPDF_Page_SetLineWidth( page, 0 )
        HPDF_Page_MoveTo( page, 20, 613 )
       HPDF_Page_LineTo( page, nWidth - 20 , 613 )
        HPDF_Page_Stroke( page )
   
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Times-Bold", NIL ), 10 )
        HPDF_Page_TextOut( page, 27, nHeight - 218, "
CANT." )
        HPDF_Page_TextOut( page, 160, nHeight - 218, "
DESCRIPCION" )
        HPDF_Page_TextOut( page, 330, nHeight - 218, "
IMPORTE" )
        HPDF_Page_TextOut( page, 410, nHeight - 218, "
DESC." )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica-Bold", NIL ), 10 )
        HPDF_Page_TextOut( page, 488, nHeight - 218, "
TOTAL" )
       HPDF_Page_EndText( page )
       
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 10 )
        n := -20
        aFacturas := BuscaLasFacturas( oRsR : facturas, oRsR )
        If( Len( aFacturas ) == 1 )
            oRsF := o : oCon : RowSet( "
select * from carga_m where id_factura = ? order by rubro", { aFacturas[ 1 ][ 1 ] } )
            While( !oRsF : Eof() )
                HPDF_Page_TextOut( page,  30, nHeight - ( 288 + n ), StrZero( 1, 3 ) )
                HPDF_Page_TextOut( page,  75, nHeight - ( 288 + n ), oRsF : descrip )
                //HPDF_Page_TextOut( page, 120, nHeight - ( 288 + n ), aFacturas[ i ][ 3 ] )
                aRect[ rTOP    ] := 575 - n
            //aRect[ rRIGHT  ] := 200 - n
            aRect[ rLEFT  ] := 330
            aRect[ rRIGHT ] := 370
                HPDF_Page_TextRect( page, aRect[ rLEFT ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                    Transform( oRsF : importe, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
                aRect[ rLEFT  ] := 390
            aRect[ rRIGHT ] := 430
                HPDF_Page_TextRect( page, aRect[ rLEFT ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                    Transform( oRsF : descuento, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
                n += 15
                oRsF : Skip()
            Enddo
        End
        HPDF_Page_EndText( page )
        n += 45
   
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
        HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
FORMA DE PAGO" )
        HPDF_Page_EndText( page )
   
        HPDF_Page_SetLineWidth( page, 0 )
        HPDF_Page_MoveTo( page, 30, 580 - n )
       HPDF_Page_LineTo( page, nWidth - 170, 580 - n )
        HPDF_Page_Stroke( page )
   
        n += 25
       
        aRect[ rTOP    ] := 592 - n
       aRect[ rBOTTOM ] := 200 - n
        aRect[ rLEFT  ]  := 280
       aRect[ rRIGHT ]  := 420
       
        *Contado
        If( oRsR : contado # 0 )
            HPDF_Page_BeginText( page )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
            HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
CONTADO" )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 10 )
            HPDF_Page_TextRect( page, aRect[ rLEFT ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( oRsR : contado, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
          HPDF_Page_EndText( page )        
          n += 20
        End
        *Cheques

        If( Len( o : aCheques ) # 0 )
            aRect[ rLEFT  ]  := 350
        aRect[ rRIGHT ]  := 390
            HPDF_Page_BeginText( page )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
            HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
CHEQUES" )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 06 )
            n += 20
            For i := 1 To Len( o : aCheques )
                aRect[ rTOP    ] := 589 - n
            aRect[ rBOTTOM ] := 200 - n
                HPDF_Page_TextOut( page, 30, nHeight - 258 - n, o : aCheques[ i ][ 2 ] )
                HPDF_Page_TextOut( page, 150, nHeight - 258 - n, o : aCheques[ i ][ 3 ] )
                HPDF_Page_TextOut( page, 220, nHeight - 258 - n, DToC( o : aCheques[ i ][ 1 ] ) )
                HPDF_Page_TextRect( page, aRect[ rLEFT  ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( o : aCheques[ i ][ 4 ], "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
                nTCheques += o : aCheques[ i ][ 4 ]
                n += 15
            Next i
            n += 10
            aRect[ rLEFT  ]  := 480
            aRect[ rRIGHT ]  := 540
            aRect[ rTOP    ] := 600 - n
        aRect[ rBOTTOM ] := 200 - n
   
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
            HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
Total"  )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 12 )
            HPDF_Page_TextRect( page, aRect[ rLEFT ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( nTCheques, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
            HPDF_Page_EndText( page )          
            n += 20
        End
   
        *Transferencias
        If( oRsR : transferencia # 0 )
            aRect[ rLEFT  ]  := 350
        aRect[ rRIGHT ]  := 390
            HPDF_Page_BeginText( page )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
            HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
TRANSFERENCIA" )
            n += 20
            aRect[ rTOP    ] := 589 - n
        aRect[ rBOTTOM ] := 200 - n
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 06 )
            HPDF_Page_TextOut( page,  30, nHeight - 258 - n, oRsTran : banco )
            HPDF_Page_TextOut( page, 150, nHeight - 258 - n, DToC( oRsTran : f_acredita )  )
            HPDF_Page_TextRect( page, aRect[ rLEFT  ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( oRsR : transferencia, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
            aRect[ rLEFT  ]  := 480
            aRect[ rRIGHT ]  := 540
            aRect[ rTOP    ] := 600 - n
        aRect[ rBOTTOM ] := 200 - n
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 12 )
            HPDF_Page_TextRect( page, aRect[ rLEFT  ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( oRsR : transferencia, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
            HPDF_Page_EndText( page )              
        End    
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 8 )
        HPDF_Page_TextOut( page, 30, nHeight - 753, "
Son : " + NumTole( oRsR : contado + nTCheques + oRsR : transferencia ) )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 12 )
       
        HPDF_Page_TextRect( page, 80, 100, 540, 170, ;
                Transform( oRsR : contado + nTCheques + oRsR : transferencia, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
       
        HPDF_Page_EndText( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, 450, nHeight - 201 )
       HPDF_Page_LineTo( page, 450, nHeight - 761 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, nWidth - 145, 115 )
       HPDF_Page_LineTo( page, nWidth - 20, 115 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, 20, 85 )
       HPDF_Page_LineTo( page, nWidth - 20, 85 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, 350, 80 )
       HPDF_Page_LineTo( page, 350, 20 )
        HPDF_Page_Stroke( page )
       

       DrawBarcode( page, 620, 1,"
", cBarras )
       /*
        HPDF_Page_BeginText( page )    
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 6 )
        HPDF_Page_TextOut( page, 120, 32, cBarras )
        HPDF_Page_EndText( page )
        */
        HPDF_Page_BeginText( page )    
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 8 )
        HPDF_Page_TextOut( page, 390, 60, "
C.A.E.:" )
        HPDF_Page_TextOut( page, 450, 60, o : oRs : Cae )
        HPDF_Page_TextOut( page, 390, 40, "
F. V. :" )
        HPDF_Page_TextOut( page, 450, 40, DToC( o : oRs : fecha_vencimiento ) )
        HPDF_Page_EndText( page )
               
        hb_vfErase( cCarpeta_pdf + "
\" + cFile )
        HPDF_SaveToFile( pdf, cCarpeta_pdf + "
\" + cFile )
    Next nFor
    If( lSelected )
        oProgreso : Finaliza()
        o : oBrwR : aSelected := {}
        o : oBrwR : Refresh()
        MsgWait( "
     Hecho ...      ",, 0.8 )              
    End
    If( Len( aRecibos ) == 1 )
        ShellExecute( 0,, cCarpeta_pdf + "
\" + cFile,,, 3 )
    End
    Return 0

//----------------------------------------------------------------------------//
 Static Function BuscaLasFacturas( cFacturas, oRs )
 
    Local i
    Local oRec
    Local aDatos    := {}
    Local cCadena   := "
"
    Local aFacturas := &( cFacturas )
    Memvar o
 
        For i := 1 To Len( aFacturas )
            cCadena += "
id_factura = " + Alltrim( Str( aFacturas[ i ][ 1 ] ) ) + " or "
        Next i
        aFacturas := ASort( aFacturas,,, { | x, y | x[ 1 ] < y[ 1 ] } )
        cCadena := SubStr( cCadena, 1, Len( cCadena ) - 4 ) 
        oRec := o : oCon : RowSet( "
select id_factura, fecha, concepto, importe, pagado from factura where " + cCadena + " and es_factura = 1 and es_debito = 0 order by id_factura" )
        i := 1
        If( oRec : KeyCount() # 0 )
            While( !oRec : Eof() )
                Try
                    Aadd( aDatos, { oRec : id_factura, DToC( oRec : fecha ), oRec : concepto, oRec : importe, aFacturas[ i ][ 2 ] } )
                Catch
                End
                oRec : Skip()
                i++
            Enddo   
        End   
        oRec : End()

    Return aDatos
   
//----------------------------------------------------------------------------//
Function DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )

   Local hZebra
    Local nLineHeight
    Local cTxt

   nY := HPDF_Page_GetHeight( page ) - nY
    //hZebra := hb_zebra_create_code128( cCode, nFlags )
    cCode := "
https://www.afip.gob.ar/fe/qr/?p=" + hb_base64Encode( cCode )
    hZebra := hb_zebra_create_qrcode( cCode, nFlags )
   If( hZebra != NIL )
        If( hb_zebra_geterror( hZebra ) == 0 )
         If( Empty( nLineHeight ) )
            nLineHeight := 30
         End
            HPDF_Page_BeginText( page )
         HPDF_Page_TextOut( page,  40, nY - 13, cType )
         cTxt := hb_zebra_getcode( hZebra )
            If( Len( cTxt ) < 20 )
            HPDF_Page_TextOut( page, 150, nY - 13, cTxt )
         End
            HPDF_Page_EndText( page )
         //hb_zebra_draw_hpdf( hZebra, page, 50, 70, nLineWidth, -nLineHeight )
         hb_zebra_draw_hpdf( hZebra, page, 30, 22, 1.0, 1.0 )
        Else
         ? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
      End
      hb_zebra_destroy( hZebra )
    Else
      ? "Código de barras inválido", cType
   End
   Return 0
*/
//----------------------------------------------------------------------------//  

Static Function hb_zebra_draw_hpdf( hZebra, page, ... )

   If( hb_zebra_geterror( hZebra ) != 0 )
      Return HB_ZEBRA_ERROR_INVALIDZEBRA
   End
   hb_zebra_draw( hZebra, {| x, y, w, h | HPDF_Page_Rectangle( page, x, y, w, h ) }, ... )
   HPDF_Page_Fill( page )
   Return 0  
*/ 
//----------------------------------------------------------------------------//
Function TransformaFecha( dDate )

    Return SubStr( DTos( dDate ), 1, 4 ) + "-" + SubStr( DTos( dDate ), 5, 2 ) + "-" + SubStr( DTos( dDate ), 7, 2 )
 


Saludos
horacio
 
Posts: 1358
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: QR-CODE

Postby karinha » Mon May 08, 2023 1:44 pm

horacio wrote:Hola , te envié un enlace a mi drive para que puedas bajar las librerías. Avisame si te llegó y te dejo aquí el código de ejemplo

Code: Select all  Expand view

#include "fivewin.ch"
#include "harupdf.ch"
#include "hbzebra.ch"
#define rLEFT    1
#define rTOP     2
#define rRIGHT   3
#define rBOTTOM  4
Static Pdf
Static oRsR
Static oRsF
Static cFile
Static cBarras

//----------------------------------------------------------------------------//
Function Recibo_Pdf_2()

    Local i
    Local n
    Local tw
   Local nFor
   Local font
   Local page  
    Local nWidth
    Local cFecha
    Local nHeight
    Local cAlumno
    Local oRsTran
    Local aRecibos
    Local cTipoIva
    Local def_font
    Local samp_text
    Local aFacturas
    Local oProgreso
    Local cTipoDocumento
    Local aRect          := Array( 4 )
    Local nTotal       := 0
    Local nTotalA      := 0
    Local cCarpeta     := "C:\crono\pdf"
    Local nTCheques    := 0
    Local lSelected    := .f.
    Local cNomArchivo  := "prueba.pdf"
    Local cCarpeta_pdf := Memvar -> o : cFolderPdf
    Local font_list    := { ;
                         "Courier",                 ;
                         "Courier-Bold",             ;
                         "Courier-Oblique",          ;
                         "Courier-BoldOblique",      ;
                         "Helvetica",                ;
                         "Helvetica-Bold",           ;
                         "Helvetica-Oblique",        ;
                         "Helvetica-BoldOblique",    ;
                         "Times-Roman",              ;
                         "Times-Bold",               ;
                         "Times-Italic",             ;
                         "Times-BoldItalic",         ;
                         "Symbol",                   ;
                         "ZapfDingbats"              }
    Memvar o
    /*
    cBarras := StrTran( o : cCuit, '-', '' ) + '015' + StrZero( Val( o : nPtoVta ), 5 ) + Alltrim( o : oRs : Cae ) +;
                  DToS( o : oRs : fecha_vencimiento )
    cBarras += Alltrim( DigitoVerificador( cBarras ) )
    oRsR := o : oRs : Clone()
    */

   
    oRsR := o : oRs : Clone()
    If( oRsR : es_credito == 1 .or. oRsR : aplica_credito == 1 )
        Return 0
    End
    cBarras := '{"ver":1,"fecha":"' + TransformaFecha( oRsR : fecha ) + '","cuit": ' + StrTran( o : cCuit, '-', '' ) + ',"ptoVta":' + Alltrim( o : nPtoVta ) + ',"tipoCmp":15,"nroCmp":' +;
                     Alltrim( Str( oRsR : nro_recibo ) ) + ',"importe":' + Alltrim( Str( oRsR : contado + oRsR : cheques + oRsR : transferencia + oRsR : tarjeta ) ) +;
                     ',"moneda":"PES","ctz":1,"tipoDocRec":' + If( !Empty( oRsR : cuit ), '80', '96' ) + ',"nroDocRec":' + If( !Empty( oRsR : cuit ), StrTran( oRsR : cuit, "-", "" ),;
                     StrTran( oRsR : num_doc, ".", "" ) ) + ',"tipoCodAut":"E","codAut":' + Alltrim( oRsR : Cae ) + '}'

    If( !Empty( o : oBrwR : aSelected    ) )
        aRecibos := AClone( o : oBrwR : aSelected )
        oProgreso := TTProgreso() : New()      
        oProgreso : oMeter : nTotal :=  Len( o : oBrwR : aSelected  )      
        lSelected := .t.
    Else
        aRecibos := { oRsR : Recno() }
    End 
                 
    For nFor := 1 To Len( aRecibos )
        oRsR : GoTo( aRecibos[ nFor ] )
        If( lSelected )
            oProgreso : oMeter : Set( nFor )
        End
        If( nFor % 5 == 0 )
            SysRefresh()
        End 
        If( oRsR : transferencia # 0 )
            oRsTran := o : oCon : RowSet( "select banco, f_acredita from cheques where id_recibo = ?", { oRsR : nro_recibo } )
        End 
        cFile   := "R" + StrZero( Val( o : nPtoVta ), 4 ) + "-" + StrZero( oRsR : nro_recibo, 6 ) + ".pdf"
        If( File( cCarpeta_pdf + "\" + cFile ) )
            Ferase(  cCarpeta_pdf + "
\" + cFile )
        End
        cFecha  := "
Fecha: " + DToC( Date() )
        pdf     := HPDF_New()
        page    := HPDF_AddPage( pdf )
        nHeight := HPDF_Page_GetHeight( page )
    nWidth  := HPDF_Page_GetWidth( page )
   
       HPDF_SetCompressionMode( pdf, HPDF_COMP_ALL )
   
       HPDF_Page_SetLineWidth( page, 1 )
       HPDF_Page_Rectangle( page, 20, 20, nWidth - 40, nHeight - 40 )
       HPDF_Page_Stroke( page )
       HPDF_Page_SetSize( page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT )
       HPDF_GetEncoder( pdf, "
CP1257" )
   
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 6 )
        cAlumno := Alltrim( oRsR : alumno ) + "
- Curso: " + Alltrim( oRsR : cur ) + " - Sección: " + oRsR : sec
        HPDF_Page_TextOut( page, 20, nHeight - 18, cAlumno )

        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 18 )

        tw := HPDF_Page_TextWidth( page, "
Colegio Nuestra Sra." )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 50, "
Colegio Nuestra Sra." )
        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 24 )

        tw := HPDF_Page_TextWidth( page, "
Del Rosario" )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 70, "
Del Rosario" )
       
        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 12 )

        tw := HPDF_Page_TextWidth( page, Alltrim( o : oRec : domicilio ) )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 100, Alltrim( o : oRec : domicilio ) )
        tw := HPDF_Page_TextWidth( page, "
( " + Alltrim( o : oRec : c_postal ) + " ) " + Alltrim( o : oRec : localidad ) )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 115, "
( " + Alltrim( o : oRec : c_postal ) + " ) " + Alltrim( o : oRec : localidad ) )
        tw := HPDF_Page_TextWidth( page, "
Tel: " + Alltrim( o : oRec : Telefono ) )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 130, "
Tel: " + Alltrim( o : oRec : Telefono ) )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica-Bold", NIL ), 12 )
        tw := HPDF_Page_TextWidth( page, "
I.V.A EXENTO" )
        HPDF_Page_TextOut( page, ( ( nWidth / 2 ) - tw ) / 2, nHeight - 160, "
I.V.A EXENTO" )
       HPDF_Page_EndText( page )
        cTipoDocumento := "
RECIBO"
       
        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_BeginText( page )
       HPDF_Page_SetFontAndSize( page, def_font, 24 )
        tw := HPDF_Page_TextWidth( page, cTipoDocumento )
        HPDF_Page_TextOut( page, ( nWidth + ( nWidth / 2 ) - tw - 20 ) / 2, nHeight - 50, cTipoDocumento )
       
       
        def_font := HPDF_GetFont( pdf, "
Helvetica-Bold", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 14 )
        tw := HPDF_Page_TextWidth( page, "
Nro. " + StrZero( 1, 4 ) + "-" + StrZero( oRsR : nro_recibo, 8 ) )
        HPDF_Page_TextOut( page, ( nWidth + ( nWidth / 2 ) - tw - 20 ) / 2, nHeight - 90, "
Nro. " + StrZero( 1, 4 ) + "-" + StrZero( oRsR : nro_recibo, 8 ) )
        tw := HPDF_Page_TextWidth( page, cFecha )
        HPDF_Page_TextOut( page, ( nWidth + ( nWidth / 2 ) - tw - 20 ) / 2, nHeight - 105, cFecha )
        def_font := HPDF_GetFont( pdf, "
Helvetica", NIL )
        HPDF_Page_SetFontAndSize( page, def_font, 6 )
        HPDF_Page_TextOut( page, ( nWidth / 2 ) + 40, nHeight - 150, "
C.U.I.T: " + o : oRec : cuit )
        HPDF_Page_TextOut( page, ( nWidth / 2 ) + 40, nHeight - 160, "
FECHA DE INICIO DE ACTIVIDADES " + DToC( o : oRec : f_inicio ) )
        HPDF_Page_EndText( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, 20, 675)
       HPDF_Page_LineTo( page, nWidth - 20 , 675)
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, nWidth / 2, nHeight - 20 )
       HPDF_Page_LineTo( page, nWidth / 2, nHeight - 25 )
        HPDF_Page_Stroke( page )
       
       HPDF_Page_SetLineWidth( page, 0 )
       HPDF_Page_Rectangle( page, nWidth / 2 - 18, 776, 36, 40 )
       HPDF_Page_Stroke( page )
       
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica-Bold", NIL ), 36 )
        tw := HPDF_Page_TextWidth( page, "
C" )
        HPDF_Page_TextOut( page, ( nWidth - tw ) / 2 , nHeight - 58, "
C" )
       HPDF_Page_EndText( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, nWidth / 2, nHeight - 65 )
       HPDF_Page_LineTo( page, nWidth / 2, nHeight - 166 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 8 )
        HPDF_Page_TextOut( page, 50, nHeight - 180, "
SRES.:" )
        HPDF_Page_TextOut( page, nWidth - 160 , nHeight - 180, "
C.U.I.T.:" )
        HPDF_Page_TextOut( page, 31, nHeight - 195, "
DOMICILIO:" )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica-Bold", NIL ), 09 )
        HPDF_Page_TextOut( page, 80, nHeight - 180, Alltrim( oRsR : facturar_a ) )
        HPDF_Page_TextOut( page, nWidth - 120, nHeight - 180, oRsR : cuit )
            cTipoIva := Alltrim( oRsR : domicilio ) + "
 " + Alltrim( oRsR : numero ) + If( !Empty( oRsR : dpto ), " Dpto " + Alltrim( oRsR : dpto ), "" ) + If( !Empty( oRsR : localidad ), " - " + Alltrim( oRsR : localidad ), "" )
        HPDF_Page_TextOut( page, 80, nHeight - 195, cTipoIva )
       HPDF_Page_EndText( page )
            
        HPDF_Page_SetLineWidth( page, 0 )
        HPDF_Page_MoveTo( page, 20, 640 )
       HPDF_Page_LineTo( page, nWidth - 20 , 640 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetRGBFill( page, 0.75, 0.75, 0.75 )
        HPDF_Page_Rectangle( page, 21, 614, nWidth - 42, 25 )
        HPDF_Page_Fill(page)
        HPDF_Page_SetRGBFill( page, 0.0, 0.0, 0.0 )
       
        HPDF_Page_SetLineWidth( page, 0 )
        HPDF_Page_MoveTo( page, 20, 613 )
       HPDF_Page_LineTo( page, nWidth - 20 , 613 )
        HPDF_Page_Stroke( page )
   
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Times-Bold", NIL ), 10 )
        HPDF_Page_TextOut( page, 27, nHeight - 218, "
CANT." )
        HPDF_Page_TextOut( page, 160, nHeight - 218, "
DESCRIPCION" )
        HPDF_Page_TextOut( page, 330, nHeight - 218, "
IMPORTE" )
        HPDF_Page_TextOut( page, 410, nHeight - 218, "
DESC." )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica-Bold", NIL ), 10 )
        HPDF_Page_TextOut( page, 488, nHeight - 218, "
TOTAL" )
       HPDF_Page_EndText( page )
       
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 10 )
        n := -20
        aFacturas := BuscaLasFacturas( oRsR : facturas, oRsR )
        If( Len( aFacturas ) == 1 )
            oRsF := o : oCon : RowSet( "
select * from carga_m where id_factura = ? order by rubro", { aFacturas[ 1 ][ 1 ] } )
            While( !oRsF : Eof() )
                HPDF_Page_TextOut( page,  30, nHeight - ( 288 + n ), StrZero( 1, 3 ) )
                HPDF_Page_TextOut( page,  75, nHeight - ( 288 + n ), oRsF : descrip )
                //HPDF_Page_TextOut( page, 120, nHeight - ( 288 + n ), aFacturas[ i ][ 3 ] )
                aRect[ rTOP    ] := 575 - n
            //aRect[ rRIGHT  ] := 200 - n
            aRect[ rLEFT  ] := 330
            aRect[ rRIGHT ] := 370
                HPDF_Page_TextRect( page, aRect[ rLEFT ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                    Transform( oRsF : importe, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
                aRect[ rLEFT  ] := 390
            aRect[ rRIGHT ] := 430
                HPDF_Page_TextRect( page, aRect[ rLEFT ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                    Transform( oRsF : descuento, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
                n += 15
                oRsF : Skip()
            Enddo
        End
        HPDF_Page_EndText( page )
        n += 45
   
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
        HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
FORMA DE PAGO" )
        HPDF_Page_EndText( page )
   
        HPDF_Page_SetLineWidth( page, 0 )
        HPDF_Page_MoveTo( page, 30, 580 - n )
       HPDF_Page_LineTo( page, nWidth - 170, 580 - n )
        HPDF_Page_Stroke( page )
   
        n += 25
       
        aRect[ rTOP    ] := 592 - n
       aRect[ rBOTTOM ] := 200 - n
        aRect[ rLEFT  ]  := 280
       aRect[ rRIGHT ]  := 420
       
        *Contado
        If( oRsR : contado # 0 )
            HPDF_Page_BeginText( page )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
            HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
CONTADO" )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 10 )
            HPDF_Page_TextRect( page, aRect[ rLEFT ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( oRsR : contado, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
          HPDF_Page_EndText( page )        
          n += 20
        End
        *Cheques

        If( Len( o : aCheques ) # 0 )
            aRect[ rLEFT  ]  := 350
        aRect[ rRIGHT ]  := 390
            HPDF_Page_BeginText( page )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
            HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
CHEQUES" )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 06 )
            n += 20
            For i := 1 To Len( o : aCheques )
                aRect[ rTOP    ] := 589 - n
            aRect[ rBOTTOM ] := 200 - n
                HPDF_Page_TextOut( page, 30, nHeight - 258 - n, o : aCheques[ i ][ 2 ] )
                HPDF_Page_TextOut( page, 150, nHeight - 258 - n, o : aCheques[ i ][ 3 ] )
                HPDF_Page_TextOut( page, 220, nHeight - 258 - n, DToC( o : aCheques[ i ][ 1 ] ) )
                HPDF_Page_TextRect( page, aRect[ rLEFT  ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( o : aCheques[ i ][ 4 ], "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
                nTCheques += o : aCheques[ i ][ 4 ]
                n += 15
            Next i
            n += 10
            aRect[ rLEFT  ]  := 480
            aRect[ rRIGHT ]  := 540
            aRect[ rTOP    ] := 600 - n
        aRect[ rBOTTOM ] := 200 - n
   
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
            HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
Total"  )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 12 )
            HPDF_Page_TextRect( page, aRect[ rLEFT ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( nTCheques, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
            HPDF_Page_EndText( page )          
            n += 20
        End
   
        *Transferencias
        If( oRsR : transferencia # 0 )
            aRect[ rLEFT  ]  := 350
        aRect[ rRIGHT ]  := 390
            HPDF_Page_BeginText( page )
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 08 )
            HPDF_Page_TextOut( page, 30, nHeight - 258 - n, "
TRANSFERENCIA" )
            n += 20
            aRect[ rTOP    ] := 589 - n
        aRect[ rBOTTOM ] := 200 - n
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 06 )
            HPDF_Page_TextOut( page,  30, nHeight - 258 - n, oRsTran : banco )
            HPDF_Page_TextOut( page, 150, nHeight - 258 - n, DToC( oRsTran : f_acredita )  )
            HPDF_Page_TextRect( page, aRect[ rLEFT  ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( oRsR : transferencia, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
            aRect[ rLEFT  ]  := 480
            aRect[ rRIGHT ]  := 540
            aRect[ rTOP    ] := 600 - n
        aRect[ rBOTTOM ] := 200 - n
            HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 12 )
            HPDF_Page_TextRect( page, aRect[ rLEFT  ], aRect[ rTOP ], aRect[ rRIGHT ], aRect[ rBOTTOM ], ;
                Transform( oRsR : transferencia, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
            HPDF_Page_EndText( page )              
        End    
        HPDF_Page_BeginText( page )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 8 )
        HPDF_Page_TextOut( page, 30, nHeight - 753, "
Son : " + NumTole( oRsR : contado + nTCheques + oRsR : transferencia ) )
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 12 )
       
        HPDF_Page_TextRect( page, 80, 100, 540, 170, ;
                Transform( oRsR : contado + nTCheques + oRsR : transferencia, "
@E 99,999,999.99" ), HPDF_TALIGN_RIGHT, Nil )
       
        HPDF_Page_EndText( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, 450, nHeight - 201 )
       HPDF_Page_LineTo( page, 450, nHeight - 761 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, nWidth - 145, 115 )
       HPDF_Page_LineTo( page, nWidth - 20, 115 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, 20, 85 )
       HPDF_Page_LineTo( page, nWidth - 20, 85 )
        HPDF_Page_Stroke( page )
       
        HPDF_Page_SetLineWidth( page, 0)
        HPDF_Page_MoveTo( page, 350, 80 )
       HPDF_Page_LineTo( page, 350, 20 )
        HPDF_Page_Stroke( page )
       

       DrawBarcode( page, 620, 1,"
", cBarras )
       /*
        HPDF_Page_BeginText( page )    
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 6 )
        HPDF_Page_TextOut( page, 120, 32, cBarras )
        HPDF_Page_EndText( page )
        */
        HPDF_Page_BeginText( page )    
        HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "
Helvetica", NIL ), 8 )
        HPDF_Page_TextOut( page, 390, 60, "
C.A.E.:" )
        HPDF_Page_TextOut( page, 450, 60, o : oRs : Cae )
        HPDF_Page_TextOut( page, 390, 40, "
F. V. :" )
        HPDF_Page_TextOut( page, 450, 40, DToC( o : oRs : fecha_vencimiento ) )
        HPDF_Page_EndText( page )
               
        hb_vfErase( cCarpeta_pdf + "
\" + cFile )
        HPDF_SaveToFile( pdf, cCarpeta_pdf + "
\" + cFile )
    Next nFor
    If( lSelected )
        oProgreso : Finaliza()
        o : oBrwR : aSelected := {}
        o : oBrwR : Refresh()
        MsgWait( "
     Hecho ...      ",, 0.8 )              
    End
    If( Len( aRecibos ) == 1 )
        ShellExecute( 0,, cCarpeta_pdf + "
\" + cFile,,, 3 )
    End
    Return 0

//----------------------------------------------------------------------------//
 Static Function BuscaLasFacturas( cFacturas, oRs )
 
    Local i
    Local oRec
    Local aDatos    := {}
    Local cCadena   := "
"
    Local aFacturas := &( cFacturas )
    Memvar o
 
        For i := 1 To Len( aFacturas )
            cCadena += "
id_factura = " + Alltrim( Str( aFacturas[ i ][ 1 ] ) ) + " or "
        Next i
        aFacturas := ASort( aFacturas,,, { | x, y | x[ 1 ] < y[ 1 ] } )
        cCadena := SubStr( cCadena, 1, Len( cCadena ) - 4 ) 
        oRec := o : oCon : RowSet( "
select id_factura, fecha, concepto, importe, pagado from factura where " + cCadena + " and es_factura = 1 and es_debito = 0 order by id_factura" )
        i := 1
        If( oRec : KeyCount() # 0 )
            While( !oRec : Eof() )
                Try
                    Aadd( aDatos, { oRec : id_factura, DToC( oRec : fecha ), oRec : concepto, oRec : importe, aFacturas[ i ][ 2 ] } )
                Catch
                End
                oRec : Skip()
                i++
            Enddo   
        End   
        oRec : End()

    Return aDatos
   
//----------------------------------------------------------------------------//
Function DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )

   Local hZebra
    Local nLineHeight
    Local cTxt

   nY := HPDF_Page_GetHeight( page ) - nY
    //hZebra := hb_zebra_create_code128( cCode, nFlags )
    cCode := "
https://www.afip.gob.ar/fe/qr/?p=" + hb_base64Encode( cCode )
    hZebra := hb_zebra_create_qrcode( cCode, nFlags )
   If( hZebra != NIL )
        If( hb_zebra_geterror( hZebra ) == 0 )
         If( Empty( nLineHeight ) )
            nLineHeight := 30
         End
            HPDF_Page_BeginText( page )
         HPDF_Page_TextOut( page,  40, nY - 13, cType )
         cTxt := hb_zebra_getcode( hZebra )
            If( Len( cTxt ) < 20 )
            HPDF_Page_TextOut( page, 150, nY - 13, cTxt )
         End
            HPDF_Page_EndText( page )
         //hb_zebra_draw_hpdf( hZebra, page, 50, 70, nLineWidth, -nLineHeight )
         hb_zebra_draw_hpdf( hZebra, page, 30, 22, 1.0, 1.0 )
        Else
         ? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
      End
      hb_zebra_destroy( hZebra )
    Else
      ? "Código de barras inválido", cType
   End
   Return 0
*/
//----------------------------------------------------------------------------//  

Static Function hb_zebra_draw_hpdf( hZebra, page, ... )

   If( hb_zebra_geterror( hZebra ) != 0 )
      Return HB_ZEBRA_ERROR_INVALIDZEBRA
   End
   hb_zebra_draw( hZebra, {| x, y, w, h | HPDF_Page_Rectangle( page, x, y, w, h ) }, ... )
   HPDF_Page_Fill( page )
   Return 0  
*/ 
//----------------------------------------------------------------------------//
Function TransformaFecha( dDate )

    Return SubStr( DTos( dDate ), 1, 4 ) + "-" + SubStr( DTos( dDate ), 5, 2 ) + "-" + SubStr( DTos( dDate ), 7, 2 )
 


Saludos


Gracias Horácio. Voy hacer pruebas y comento.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7315
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: QR-CODE

Postby karinha » Mon May 08, 2023 4:41 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7315
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: QR-CODE

Postby karinha » Mon May 08, 2023 4:55 pm

Horácio, este código no és bueno. Mismo asi, gracias.

Code: Select all  Expand view

Error: Unresolved external '_HB_FUN_TTPROGRESO' referenced from C:\LIBPDF\LIBPDF
.OBJ
Error: Unresolved external '_HPDF_UseUTFEncodings' referenced from C:\XHBBCC74\L
IB\HBHPDF.LIB|harupdf
Error: Unresolved external '_HB_FUN_NUMTOLE' referenced from C:\LIBPDF\LIBPDF.OB
J
Error: Unresolved external '_HB_FUN_HB_VFERASE' referenced from C:\LIBPDF\LIBPDF
.OBJ
Error: Unable to perform link
 


Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7315
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: QR-CODE

Postby karinha » Mon May 08, 2023 6:56 pm

Este ejemplo funciona perfecto con Harbour y [x]Harbour:

Code: Select all  Expand view

/*
 * $Id$
 */


/*
 * Harbour Project source code:
 *
 * Copyright 2010 Viktor Szakats (harbour syenar.net)
 * www - http://harbour-project.org
 *
 */


// C:\LIBPDF\VICTOR.PRG - EN XHARBOUR, USAR LIBHARU.LIB
/*
C:\XHBBCC74\Lib\hbhpdf.lib           +
C:\XHBBCC74\Lib\hbzebra.lib          +
C:\XHBBCC74\Lib\libHaru.lib          +
C:\XHBBCC74\Lib\png.Lib              +
*/


#include "FiveWin.ch"
#include "hbzebra.ch"
#include "harupdf.ch"

FUNCTION Main()

   LOCAL pdf
   LOCAL page
   LOCAL vcomando

   REQUEST HB_CODEPAGE_PTISO

   REQUEST HB_CODEPAGE_PT850

   pdf  := HPDF_New()
   page := HPDF_AddPage( pdf )

   HPDF_Page_SetSize( page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT )
   HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "Helvetica", NIL ), 12 )

   DrawBarcode( page,  20,   1, "EAN13",      "477012345678" )
   DrawBarcode( page,  40,   1, "EAN8",       "1234567" )
   DrawBarcode( page,  60,   1, "UPCA",       "01234567891" )
   DrawBarcode( page,  80,   1, "UPCE",       "123456" )
   DrawBarcode( page, 100,   1, "CODE39",     "ABC123" )
   DrawBarcode( page, 120,   1, "CODE39",     "ABC123", HB_ZEBRA_FLAG_CHECKSUM )
   DrawBarcode( page, 140, 0.5, "CODE39",     "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE2_5 )
   DrawBarcode( page, 160,   1, "CODE39",     "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 180,   1, "ITF",        "1234", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 200,   1, "ITF",        "12345678901", HB_ZEBRA_FLAG_CHECKSUM )
   DrawBarcode( page, 220,   1, "MSI",        "1234" )
   DrawBarcode( page, 240,   1, "MSI",        "1234", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 260,   1, "MSI",        "1234567", HB_ZEBRA_FLAG_CHECKSUM )
   DrawBarcode( page, 280,   1, "CODABAR",    "40156", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 300,   1, "CODABAR",    "-1234", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 320,   1, "CODE93",     "ABC-123" )
   DrawBarcode( page, 340,   1, "CODE93",     "TEST93" )
   DrawBarcode( page, 360,   1, "CODE11",     "12", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 380,   1, "CODE11",     "1234567890", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 400,   1, "CODE128",    "Code 128")
   DrawBarcode( page, 420,   1, "CODE128",    "1234567890")
   DrawBarcode( page, 440,   1, "CODE128",    "Wikipedia")
   DrawBarcode( page, 460,   1, "PDF417",     "Hello, World of Harbour!!! It's 2D barcode PDF417 :)" )
   DrawBarcode( page, 540,   1, "DATAMATRIX", "Hello, World of Harbour!!! It's 2D barcode DataMatrix :)")
   DrawBarcode( page, 580,   1, "QRCODE",     "http://harbour-project.org/" )

   IF FILE( "testhpdf.pdf" )

      FErase( "testhpdf.pdf" )

   ENDIF

   HPDF_SaveToFile( pdf, "testhpdf.pdf" )

   IF FILE( "testhpdf.pdf" )

      MsgWait( "TESTHPDF.pdf GENERADO... Wait...", ;
               "TESTHPDF.pdf GENERADO... Wait...", 3.5 )

      HTMLVIEW( "C:\LIBPDF\testhpdf.pdf" )

   ENDIF

RETURN NIL

FUNCTION DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )

   LOCAL hZebra, nLineHeight, cTxt

   nY := HPDF_Page_GetHeight( page ) - nY

   DO CASE
   CASE cType == "EAN13"      ; hZebra := hb_zebra_create_ean13( cCode, nFlags )
   CASE cType == "EAN8"       ; hZebra := hb_zebra_create_ean8( cCode, nFlags )
   CASE cType == "UPCA"       ; hZebra := hb_zebra_create_upca( cCode, nFlags )
   CASE cType == "UPCE"       ; hZebra := hb_zebra_create_upce( cCode, nFlags )
   CASE cType == "CODE39"     ; hZebra := hb_zebra_create_code39( cCode, nFlags )
   CASE cType == "ITF"        ; hZebra := hb_zebra_create_itf( cCode, nFlags )
   CASE cType == "MSI"        ; hZebra := hb_zebra_create_msi( cCode, nFlags )
   CASE cType == "CODABAR"    ; hZebra := hb_zebra_create_codabar( cCode, nFlags )
   CASE cType == "CODE93"     ; hZebra := hb_zebra_create_code93( cCode, nFlags )
   CASE cType == "CODE11"     ; hZebra := hb_zebra_create_code11( cCode, nFlags )
   CASE cType == "CODE128"    ; hZebra := hb_zebra_create_code128( cCode, nFlags )
   CASE cType == "PDF417"     ; hZebra := hb_zebra_create_pdf417( cCode, nFlags ); nLineHeight := nLineWidth * 3
   CASE cType == "DATAMATRIX" ; hZebra := hb_zebra_create_datamatrix( cCode, nFlags ); nLineHeight := nLineWidth
   CASE cType == "QRCODE"     ; hZebra := hb_zebra_create_qrcode( cCode, nFlags ); nLineHeight := nLineWidth
   END

   IF hZebra != NIL

      IF hb_zebra_geterror( hZebra ) == 0

         IF Empty( nLineHeight )
            nLineHeight := 16
         ENDIF

         HPDF_Page_BeginText( page )
         HPDF_Page_TextOut( page,  40, nY - 13, cType )

         cTxt := hb_zebra_getcode( hZebra )

         IF Len( cTxt ) < 20
            HPDF_Page_TextOut( page, 150, nY - 13, cTxt )
         ENDIF

         HPDF_Page_EndText( page )
         hb_zebra_draw_hpdf( hZebra, page, 300, nY, nLineWidth, -nLineHeight )

      ELSE

         ? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )

      ENDIF

      hb_zebra_destroy( hZebra )

   ELSE

      ? "Invalid barcode type", cType

   ENDIF

RETURN NIL

STATIC FUNCTION hb_zebra_draw_hpdf( hZebra, page, v3, v4, v5, v6 )

   IF hb_zebra_GetError( hZebra ) != 0

      RETURN HB_ZEBRA_ERROR_INVALIDZEBRA

   ENDIF

   hb_zebra_draw( hZebra, {| x, y, w, h | HPDF_Page_Rectangle( page, x, y, w, h ) } , v3, v4, v5, v6 )

   HPDF_Page_Fill( page )

RETURN 0

// FIN / END - kapiabafwh@gmail.com
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7315
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: QR-CODE

Postby karinha » Mon May 08, 2023 7:04 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7315
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: QR-CODE

Postby postinelli » Tue May 09, 2023 6:19 pm

Estimado soy de argentina y ya hace tiempo tratamos este tema
lo tengo resuelto y es mas facil de lo que parece

viewtopic.php?f=6&t=39859&p=237857&hilit=postinelli&sid=0c399e08732d8cf7eafc01f7cd43f2ec#p237857

aqui tratamos el tema en su momento

cualquier cosa a tu disposición
postinelli
 
Posts: 147
Joined: Tue Jul 15, 2008 7:12 pm
Location: Argentina

Previous

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 38 guests