Página 2 de 2

PIX

Enviado: 04 Jun 2023 11:16
por Fernando queiroz
COLOQUEI AS BOLINHAS PARA OS PAGAMENTOS PENDENTES, QUANDO FOR FEITO O QUITAMENTO DA FORMA DE PAGAMENTO A BOLINHA FICA VERDE PARA O OPERADOR
COLOQUEI AS BOLINHAS PARA OS PAGAMENTOS PENDENTES, QUANDO FOR FEITO O QUITAMENTO DA FORMA DE PAGAMENTO A BOLINHA FICA VERDE PARA O OPERADOR

PIX

Enviado: 04 Jun 2023 12:53
por Itamar M. Lins Jr.
Olá!
Como está fazendo para gerar o desenho do QrCode ?
Em PDF ? na Hwgui ?

Saudações,
Itamar M. Lins Jr.

PIX

Enviado: 04 Jun 2023 15:47
por Fernando queiroz
Itamar M. Lins Jr. escreveu:Olá!
Como está fazendo para gerar o desenho do QrCode ?
Em PDF ? na Hwgui ?

Saudações,
Itamar M. Lins Jr.

Código: Selecionar todos

************************************************************************************************************************************************************************************************************************
METHOD PIX_QRCODE(  ) CLASS PAGAMENTOCLASS  
************************************************************************************************************************************************************************************************************************
LOCAL cQuery1;
    , oSQL;
    , oPIX;
    , oPDF;
    , cQRCode;
    , oSQL_FLAG;
    , cFileName;
    , nMaxCol;
    , nLinha:=1;


    IF ! ::PIX_IMPRESSO
        cQuery1:="SELECT "
        cQuery1+="DATABASE() AS FILIAL, "
        cQuery1+="pedidospagamento.PEDIDOS_ID, "
        cQuery1+="pedidospagamento.VALOR "
        cQuery1+="FROM pedidospagamento "
        cQuery1+="WHERE pedidospagamento.PEDIDOS_ID = '" + STRZERO(::nPEDIDOS_ID,11,0)  + "' AND pedidospagamento.TIPPGTO_ID = '17' "
        oSQL:= CONECCOESCLASS():ExecuteSQL(::oServer, cQuery1)

        IF ! oSQL:eof( )
            cQuery1:="SELECT  "
            cQuery1+="flag.PIX_CHAVE, "
            cQuery1+="flag.PIX_RECEBEDOR, "
            cQuery1+="flag.PIX_CIDADE, "
            cQuery1+="flag.NOMEUSUARIO "
            cQuery1+="FROM flag WHERE flag.FLAG_Id = 1 "
            oSQL_FLAG := CONECCOESCLASS():ExecuteSQL(::oServer, cQuery1)

            IF ! EMPTY(oSQL_FLAG:Fields( "PIX_CHAVE" ):Value )
                oPDF := PDFClass()
                IF oPDF == NIL
                    hwg_msginfo("Falha da criação do objeto PDF","ATENÇÃO!!!")
                    RETURN .F.
                ENDIF
                cFileName 	:= "C:\filesold\report\PIX_" + STRZERO(::nPEDIDOS_ID,11,0) +'.PDF'

                oPDF:cFileName 	:= cFileName
                oPDF:SetType( PDFCLASS_ROLLS )
                oPDF:Begin()
                oPDF:AddPage()
                nMaxCol := oPDF:MaxCol()

                oPIX := PIXClass( ):New(::oServer)
                IF oPIX == NIL
                    hwg_msginfo("Falha da criação do objeto PIX","ATENÇÃO!!!")
                    RETURN .F.
                ENDIF

                oPIX:cPIX_KEY       := oSQL_FLAG:Fields( "PIX_CHAVE" ):Value
                oPIX:cPIX_RECEIVER  := oSQL_FLAG:Fields( "PIX_RECEBEDOR" ):Value
                oPIX:cPIX_CITY      := oSQL_FLAG:Fields( "PIX_CIDADE" ):Value

                oPIX:nPIX_AMOUNT         := oSQL:Fields( "VALOR" ):Value
                oPIX:cPIX_DESCRIPTION    := RTRIM(UPPER(oSQL:Fields( "FILIAL" ):Value)) 
                oPIX:cPIX_IDENTIFICATION := LTRIM(TRANSFORM(oSQL:Fields( "PEDIDOS_ID" ):Value,"99999999999" ))

                cQRCode := oPIX:StringPIX(  )
                HB_GTINFO( HB_GTI_CLIPBOARDDATA, cFileName)
                oPDF:DrawText( nLinha , 0, oSQL_FLAG:Fields( "NOMEUSUARIO" ):Value, Nil, 6, "Courier-Bold", Nil, Nil ) 
                oPDF:DrawBarcodeQRCode( nLinha + .5, 5, 0.25, cQRCode  )
                oPDF:DrawText( nLinha + 14.5, 0, "Pedido: " + LTRIM(TRANSFORM(oSQL:Fields( "PEDIDOS_ID" ):Value,"99999999999" )), Nil, 6, "Courier-Bold", Nil, Nil )
                oPDF:DrawText( nLinha + 15, 0, "Valor do PIX: " + LTRIM(TRANSFORM(oSQL:Fields( "VALOR" ):Value,"@E 999,999,999.99" ) ), Nil, 6, "Courier-Bold", Nil, Nil ) 
                oPDF:DrawLine( nLinha + 15.5, 0, nLinha + 15.5, nMaxCol, 3 )
                oPDF:End(  )
                oPDF:PrintPreview( )
                ::PIX_IMPRESSO := .T.
            ENDIF
        endif
    ENDIF

RETURN NIL
PDF CLASS QUE ESTOU USANDO ( TEM ALTERAÇOES PARA MEU USO )

Código: Selecionar todos

/*
ZE_PDFCLASS - GERACAO DE PDF
José Quintas
*/

// Calculo da folha: cm * 0.03937 * 72
// onde cm = medida em cm
// 0.03937 = fator de conversao de mm para polegadas
// 72 = resolucao DPI default do PDF
// HPDF_Page_SetWidth( oPage, nResultado )
// HPDF_Page_SetHeight( oPage, nResultado )
// TODO: As medidas da página só estão disponíveis após existir uma página

#require "hbhpdf.hbc"
#require "hbct.hbc"

#include "hbclass.ch"
#include "inkey.ch"
#include "hwgui.ch"

#define PDFCLASS_DRAWMODE_ROWCOL     1
#define PDFCLASS_DRAWMODE_CENTIMETER 2
#define PDFCLASS_DRAWMODE_PIXEL      3

#define PDFCLASS_PORTRAIT  1
#define PDFCLASS_LANDSCAPE 2
#define PDFCLASS_TXT       3
#define PDFCLASS_ROLLS     4

#define PDFCLASS_PENSIZE 0.5

CREATE CLASS PDFClass

   VAR    oPdf
   VAR    oPage
   VAR    nPageWidth        INIT 595.28  // A4
   VAR    nPageHeight       INIT 841.89  // A4
   VAR    cFileName         INIT ""
   VAR    nRow              INIT 999
   VAR    nCol              INIT 0
   VAR    nAngle            INIT 0
   VAR    cFontName         INIT "Courier"
   VAR    nFontSize         INIT 9
   VAR    nLineHeight       INIT 1.3
   VAR    nTopMargin        INIT 25
   VAR    nLeftMargin       INIT 25
   VAR    nBottomMargin     INIT 25
   VAR    nRightMargin      INIT 25
   VAR    nPrinterType      INIT PDFCLASS_PORTRAIT
   VAR    nPdfPage          INIT 0
   VAR    nPageNumber       INIT 0
   VAR    acHeader          INIT {}
   VAR    cCodePage         INIT "WinAnsiEncoding" // "CP1252"
   VAR    nDrawMode         INIT PDFCLASS_DRAWMODE_ROWCOL
   VAR    lDrawZebrado      INIT .F.
   VAR    cAppEmpresaNome   INIT ""
   VAR    cDefaultPrinter   INIT WIN_PRINTERGETDEFAULT()
   
   METHOD AddPage()
   METHOD RowToPDFRow( nValue )
   METHOD ColToPDFCol( nValue )
   METHOD MaxRow()
   METHOD MaxCol()
   METHOD Row( nAddRows )
   METHOD Col( nAddCols )
   METHOD DrawBoxTitleText( nTop, nLeft, nBottom, nRight, cTitle, cText, cPicture, nAlign, nFontSizeText, cFontNameText, nFontSizeTitle, cFontNameTitle )
   METHOD DrawText( nTop, nLeft, xValue, cPicture, nFontSize, cFontName, nAngle, anRGB )
   METHOD DrawLine( nTop, nLeft, nBottom, nRight, nPenSize )
   METHOD DrawBox( nTop, nLeft, nBottom, nRight, nPenSize, nFillType, anRGB )
   METHOD DrawBoxSize( nTop, nLeft, nHeight, nWidth, nPenSize, nFillType, anRGB )
   METHOD DrawImageBox( nTop, nLeft, nBottom, nRight, cJPEGFile )
   METHOD DrawImageSize( nRow, nCol, nHeight, nWidth, cJPEGFile )
   METHOD DrawMemImageBox( nTop, nLeft, nBottom, nRight, cJPEGMem )
   METHOD DrawMemImageSize( nRow, nCol, nHeight, nWidth, cJPEGMem )
   METHOD Cancel()
   METHOD PrnToPdf( cInputFile )
   METHOD SetType( nPrinterType )
   METHOD PageHeader()
   METHOD PageFooter()
   METHOD MaxRowTest( nRows )
   METHOD SetInfo( cAuthor, cCreator, cTitle, cSubject )
   METHOD Begin()
   METHOD End( lPreview )
   METHOD DrawZebrado( nNivel, lDraw )
   METHOD SelectPrinterType( nPrinterType )
   METHOD DrawI25BarCode( nRow, nCol, nHeight, cCode, nOneBarWidth )
   METHOD DrawBarcodeQRCode( nRow, nCol, nHeight, cCode, nFlags )
   METHOD PrintOptions(  )
   METHOD PrintPreview(  )

   ENDCLASS

METHOD Row( nAddRows ) CLASS PDFCLass

   IF nAddRows != NIL
      ::nRow += nAddRows
      ::MaxRowTest()
   ENDIF

   RETURN ::nRow

METHOD Col( nAddCols ) CLASS PDFClass

   IF nAddCols != NIL
      ::nCol += nAddCols
   ENDIF

   RETURN ::nCol

METHOD Begin() CLASS PDFClass

   IF ::nPrinterType == PDFCLASS_TXT
//      ::cFileName := MyTempFile( "LST" )
      SET PRINTER TO ( ::cFileName )
      SetPrc( 0, 0 )
      SET DEVICE TO PRINT
   ELSE
//      ::cFileName := MyTempFile( "PDF" )
      ::oPdf := HPDF_New()
      HPDF_SetCompressionMode( ::oPDF, HPDF_COMP_ALL )
      HPDF_SetCurrentEncoder( ::oPDF, ::cCodePage )
      //HPDF_SetPassword( ::oPDF, "owner", "" )
      //HPDF_SetPermission( ::oPDF, HPDF_ENABLE_READ + HPDF_ENABLE_PRINT ) // + HPDF_ENABLE_EDIT_ALL + HPDF_ENABLE_COPY + HPDF_ENABLE_EDIT )
      ::SetInfo()
   ENDIF

   RETURN NIL

METHOD End( lPreview ) CLASS PDFClass

   hb_Default( @lPreview, .T. )
   ::PageFooter()
//   Mensagem()
   IF ::nPrinterType == PDFCLASS_TXT
      SET PRINTER TO
      SET DEVICE TO SCREEN
      SetPrc(0,0)
      IF lPreview
//         PrintPreview( ::cFileName, ( ::nPageWidth == 132 ) ) // compress=true for 132 cols
         fErase( ::cFileName )
      ELSE
         PrintBegin()
         @ 0,0 SAY MemoRead( ::cFileName )
         PrintEnd()
         fErase( ::cFileName )
      ENDIF
   ELSE
//      IF ::nPdfPage == 0
//         ::AddPage()
//         ::DrawText( 10, 10, "NENHUM CONTEUDO (NO CONTENT)",, ::nFontSize * 2 )
//      ENDIF
      IF File( ::cFileName )
         fErase( ::cFileName )
      ENDIF
      HPDF_SaveToFile( ::oPdf, ::cFileName )
      HPDF_Free( ::oPdf )
//      ShellExecuteOpen( ::cFileName )
//	  WAPI_ShellExecute( NIL, "OPEN", ::cFileName , NIL,, NIL )
   ENDIF

   RETURN NIL

METHOD SetInfo( cAuthor, cCreator, cTitle, cSubject ) CLASS PDFClass

   IF ::nPrinterType == PDFCLASS_TXT
      RETURN NIL
   ENDIF
   hb_Default( @cAuthor, "SGC Sistemas" )
   hb_Default( @cCreator, "Harupdf" )
   hb_Default( @cTitle, "SGC" )
   hb_Default( @cSubject, cTitle )
   IF ! Empty( cAuthor )
      HPDF_SetInfoAttr( ::oPDF, HPDF_INFO_AUTHOR, cAuthor )
   ENDIF
   IF ! Empty( cCreator )
      HPDF_SetInfoAttr( ::oPDF, HPDF_INFO_CREATOR, cCreator )
   ENDIF
   IF ! Empty( cTitle )
      HPDF_SetInfoAttr( ::oPDF, HPDF_INFO_TITLE, cTitle )
   ENDIF
   IF ! Empty( cSubject )
      HPDF_SetInfoAttr( ::oPdf, HPDF_INFO_SUBJECT, cSubject )
   ENDIF
   HPDF_SetInfoDateAttr( ::oPDF, HPDF_INFO_CREATION_DATE, { Year( Date() ), Month( Date() ), Day( Date() ), Val( Substr( Time(), 1, 2 ) ), Val( Substr( Time(), 4, 2 ) ), Val( Substr( Time(), 7, 2 ) ), "+", 4, 0 } )

   RETURN NIL

METHOD SetType( nPrinterType ) CLASS PDFClass

   IF nPrinterType != NIL
      ::nPrinterType := nPrinterType
   ENDIF
   DO CASE
   CASE ::nPrinterType == PDFCLASS_PORTRAIT
      ::nFontSize   := 9
      ::nPageWidth  := 841.89 // A4
      ::nPageHeight := 595.28 // A4
   CASE ::nPrinterType == PDFCLASS_LANDSCAPE
      ::nFontSize   := 6
      ::nPageWidth  := 595.28 // A4
      ::nPageHeight := 841.89 // A4
   CASE ::nPrinterType == PDFCLASS_TXT
      ::nPageWidth  := 132
      ::nPageHeight := 66
	CASE ::nPrinterType ==  PDFCLASS_ROLLS
      ::nFontSize   	:= 9
      ::nPageWidth  	:= 226.77 // ROLLS
      ::nPageHeight 	:= 836.22 // ROLLS
	  ::nLeftMargin 	:= 10
	  ::nRightMargin	:= 10
	  ::nTopMargin		:= 7
	  ::nBottomMargin 	:= 7
   ENDCASE

   RETURN NIL

   /*
   Note: rotate page is bad for screen, better to use automatic adjust when print
   */

METHOD AddPage() CLASS PDFClass

   IF ::nPrinterType != PDFCLASS_TXT
      ::oPage := HPDF_AddPage( ::oPdf )
      //      // HPDF_Page_SetSize( ::oPage, HPDF_PAGE_SIZE_A4, iif( ::nPrinterType == PDFCLASS_LANDSCAPE, HPDF_PAGE_PORTRAIT, HPDF_PAGE_LANDSCAPE ) )
      //      IF ::nPrinterType == PDFCLASS_PORTRAIT
      //         HPDF_Page_SetWidth( ::oPage, ::nPageHeight )
      //         HPDF_Page_SetHeight( ::oPage, ::nPageWidth )
      //         //HPDF_Page_SetRotate( ::oPage, iif( ::nPrinterType == PDFCLASS_LANDSCAPE, 0, 90 ) )
      //      ELSE
      HPDF_Page_SetWidth( ::oPage, ::nPageWidth )
      HPDF_Page_SetHeight( ::oPage, ::nPageHeight )
      //      ENDIF
      HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPdf, ::cFontName, ::cCodePage ), ::nFontSize )
   ENDIF
   ::nRow := 0

   RETURN NIL

METHOD Cancel() CLASS PDFClass

   IF ::nPrinterType != PDFCLASS_TXT
      HPDF_Free( ::oPdf )
   ENDIF

   RETURN NIL

METHOD DrawBoxTitleText( nTop, nLeft, nBottom, nRight, cTitle, cText, cPicture, nAlign, nFontSizeText, cFontNameText, nFontSizeTitle, cFontNameTitle ) CLASS PDFClass

   hb_Default( @nFontSizeTitle, 6 )
   hb_Default( @cFontNameTitle, ::cFontName )
   hb_Default( @nFontSizeText, ::nFontSize )
   hb_Default( @cFontNameText, ::cFontName )
   hb_Default( @cPicture, "" )
   hb_Default( @nAlign, HPDF_TALIGN_LEFT )

   ::DrawBox( nTop, nLeft, nBottom, nRight )
   cText   := Transform( cText, cPicture )
   ::nCol  := nRight
   nTop    := ::RowToPDFRow( nTop )
   nLeft   := ::ColToPDFCol( nLeft )
   nBottom := ::RowToPDFRow( nBottom )
   nRight  := ::ColToPDFCol( nRight )

   HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPDF, cFontNameTitle, ::cCodePage ), nFontSizeTitle )
   HPDF_Page_BeginText( ::oPage )
   HPDF_Page_TextRect( ::oPage, nLeft + 2, nTop, nRight - 2, nBottom, cTitle, nAlign, NIL )
   HPDF_Page_EndText( ::oPage )

   HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPDF, cFontNameText, ::cCodePage ), nFontSizeText )
   HPDF_Page_BeginText( ::oPage )
   HPDF_Page_TextRect( ::oPage, nLeft + 2, nTop - nFontSizeTitle - 1, nRight - 2, nBottom, cText, nAlign, NIL )
   HPDF_Page_EndText( ::oPage )

   RETURN NIL

METHOD DrawText( nTop, nLeft, xValue, cPicture, nFontSize, cFontName, nAngle, anRGB ) CLASS PDFClass

   LOCAL nRadian , cTexto

   hb_Default( @nFontSize, ::nFontSize )
   hb_Default( @cFontName, ::cFontName )
   hb_Default( @cPicture, "" )
   hb_Default( @nAngle, ::nAngle )

   cTexto  := Transform( xValue, cPicture )
   ::nCol  := nLeft + Len( cTexto )
   IF ::nPrinterType == PDFCLASS_TXT
      @ nTop, nLeft SAY cTexto
   ELSE
      nTop  := ::RowToPDFRow( nTop )
      nLeft := ::ColToPDFCol( nLeft )
      HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPdf, cFontName, ::cCodePage ), nFontSize )
      IF anRGB != NIL
         HPDF_Page_SetRGBFill( ::oPage, anRGB[ 1 ], anRGB[ 2 ], anRGB[ 3 ] )
         HPDF_Page_SetRGBStroke( ::oPage, anRGB[ 1 ], anRGB[ 2], anRGB[ 3] )
      ENDIF
      HPDF_Page_BeginText( ::oPage )
      nRadian := ( nAngle / 180 ) * 3.141592
      HPDF_Page_SetTextMatrix( ::oPage, Cos( nRadian ), Sin( nRadian ), -Sin( nRadian ), Cos( nRadian ), nLeft, nTop )
      HPDF_Page_ShowText( ::oPage, cTexto )
      HPDF_Page_EndText( ::oPage )
      IF anRGB != NIL
         HPDF_Page_SetRGBFill( ::oPage, 0, 0, 0 )
         HPDF_Page_SetRGBStroke( ::oPage, 0, 0, 0 )
      ENDIF
   ENDIF

   RETURN NIL

METHOD DrawLine( nTop, nLeft, nBottom, nRight, nPenSize ) CLASS PDFClass

   IF ::nPrinterType == PDFCLASS_TXT
      IF nTop == nBottom // Matrix can draw line in a single row
         nTop  := Round( nTop, 0 )
         nLeft := Round( nLeft, 0 )
         @ nTop, nLeft SAY Replicate( "-", nRight - nLeft )
         ::nCol := Col()
      ENDIF
   ELSE
      hb_Default( @nPenSize, PDFCLASS_PENSIZE )
      nTop     := ::RowToPDFRow( nTop )
      nLeft    := ::ColToPDFCol( nLeft )
      nBottom  := ::RowToPDFRow( nBottom )
      nRight   := ::ColToPDFCol( nRight )
      HPDF_Page_SetLineWidth( ::oPage, nPenSize )
      HPDF_Page_MoveTo( ::oPage, nLeft, nTop )
      HPDF_Page_LineTo( ::oPage, nRight, nBottom )
      HPDF_Page_Stroke( ::oPage )
   ENDIF

   RETURN NIL

METHOD DrawImageBox( nTop, nLeft, nBottom, nRight, cJPEGFile ) CLASS PDFClass

   LOCAL oImage, nWidth, nHeight

   IF ::nPrinterType == PDFCLASS_TXT // .OR. ! File( cJPEGFile )
      RETURN NIL
   ENDIF
   nWidth  :=  ::ColToPdfCol( nRight - nLeft ) - ::ColToPdfCol( 0 )
   nHeight := ( ::RowToPdfRow( 0 ) - ::RowToPdfRow( nBottom - nTop ) )
   nBottom := ::RowToPDFRow( nBottom )
   nLeft   := ::ColToPdfCol( nLeft )
   oImage  := HPDF_LoadJPEGImageFromFile( ::oPdf, cJPEGFile )
   HPDF_Page_DrawImage( ::oPage, oImage, nLeft, nBottom, nWidth, nHeight )

   RETURN NIL

METHOD DrawImageSize( nRow, nCol, nHeight, nWidth, cJPEGFile ) CLASS PDFClass

   ::DrawImageBox( nRow, nCol, nRow + nHeight, nCol + nWidth, cJPEGFile )

   RETURN NIL

METHOD DrawMemImageBox( nTop, nLeft, nBottom, nRight, cJPEGMem ) CLASS PDFClass

   LOCAL oImage, nWidth, nHeight

   IF ::nPrinterType == PDFCLASS_TXT
      RETURN NIL
   ENDIF
   IF cJPEGMem == NIL
      RETURN NIL
   ENDIF
   nWidth  :=  ::ColToPdfCol( nRight - nLeft ) - ::ColToPdfCol( 0 )
   nHeight := ( ::RowToPdfRow( 0 ) - ::RowToPdfRow( nBottom - nTop ) )
   nBottom := ::RowToPDFRow( nBottom )
   nLeft   := ::ColToPdfCol( nLeft )
   oImage  := HPDF_LoadJPEGImageFromMem( ::oPDF, cJPEGMem, Len( cJPEGMem ) )
   HPDF_Page_DrawImage( ::oPage, oImage, nLeft, nBottom, nWidth, nHeight )

   RETURN NIL

METHOD DrawMemImageSize( nRow, nCol, nHeight, nWidth, cJPEGMem ) CLASS PDFClass

   ::DrawMemImageBox( nRow, nCol, nRow + nHeight, nCol + nWidth, cJPEGMem )

   RETURN NIL

METHOD DrawBox( nTop, nLeft, nBottom, nRight, nPenSize, nFillType, anRGB ) CLASS PDFClass

   LOCAL nWidth, nHeight

   IF ::nPrinterType == PDFCLASS_TXT
      RETURN NIL
   ENDIF
   hb_Default( @nFillType, 1 )
   hb_Default( @nPenSize, PDFCLASS_PENSIZE )
   nWidth    := nRight - nLeft
   nHeight   := nBottom - nTop
   nTop      := ::RowToPDFRow( nTop )
   nLeft     := ::ColToPDFCol( nLeft )
   nWidth    := ::ColToPdfCol( nWidth ) - ::ColToPdfCol( 0 )
   nHeight   := -( ::RowToPdfRow( 0 ) - ::RowToPdfRow( nHeight ) )
   HPDF_Page_SetLineWidth( ::oPage, nPenSize )
   IF anRGB != NIL
      HPDF_Page_SetRGBFill( ::oPage, anRGB[ 1 ], anRGB[ 2 ], anRGB[ 3 ] )
      HPDF_Page_SetRGBStroke( ::oPage, anRGB[ 1 ], anRGB[ 2 ], anRGB[ 3 ] )
   ENDIF
   HPDF_Page_Rectangle( ::oPage, nLeft, nTop, nWidth, nHeight )
   IF nFillType == 1
      HPDF_Page_Stroke( ::oPage )     // borders only
   ELSEIF nFillType == 2
      HPDF_Page_Fill( ::oPage )       // inside only
   ELSE
      HPDF_Page_FillStroke( ::oPage ) // all
   ENDIF
   IF anRGB != NIL
      HPDF_Page_SetRGBStroke( ::oPage, 0, 0, 0 )
      HPDF_Page_SetRGBFill( ::oPage, 0, 0, 0 )
   ENDIF

   RETURN NIL

METHOD DrawBoxSize( nTop, nLeft, nHeight, nWidth, nPenSize, nFillType, anRGB ) CLASS PDFClass

   ::DrawBox( nTop, nLeft, nTop + nHeight, nLeft + nWidth, nPenSize, nFillType, anRGB )

   RETURN NIL

METHOD RowToPDFRow( nValue ) CLASS PDFClass

   DO CASE
   CASE ::nDrawMode == PDFCLASS_DRAWMODE_ROWCOL
      nValue := ::nPageHeight - ::nBottomMargin - ( nValue * ::nFontSize * ::nLineHeight )
   CASE ::nDrawMode == PDFCLASS_DRAWMODE_CENTIMETER
      nValue := ::nPageHeight - ( nValue * 2.83464 )
   CASE ::nDrawMode == PDFCLASS_DRAWMODE_PIXEL
      nValue := ::nPageHeight - nValue
   ENDCASE

   RETURN nValue

METHOD ColToPDFCol( nValue ) CLASS PDFClass

   DO CASE
   CASE ::nDrawMode == PDFCLASS_DRAWMODE_ROWCOL
      nValue := nValue * ::nFontSize / 1.666 + ::nLeftMargin
   CASE ::nDrawMode == PDFCLASS_DRAWMODE_CENTIMETER
      nValue := nValue * 2.83464 // 72 * 0.03937
   CASE ::nDrawMode == PDFCLASS_DRAWMODE_PIXEL
      // Nothing to do
   ENDCASE

   RETURN nValue

METHOD MaxRow() CLASS PDFClass

   LOCAL nPageHeight, nMaxRow

   IF ::nPrinterType == PDFCLASS_TXT
      RETURN 63
   ENDIF
   nPageHeight := ::nPageHeight - ::nTopMargin - ::nBottomMargin
   nMaxRow     := Int( nPageHeight / ( ::nFontSize * ::nLineHeight )  )

   RETURN nMaxRow

METHOD MaxCol() CLASS PDFClass

   LOCAL nPageWidth, nMaxCol

   IF ::nPrinterType == PDFCLASS_TXT
      RETURN ::nPageWidth
   ENDIF
   nPageWidth := ::nPageWidth - ::nRightMargin - ::nLeftMargin
   nMaxCol    := Int( nPageWidth / ::nFontSize * 1.666 )

   RETURN nMaxCol

METHOD PrnToPdf( cInputFile ) CLASS PDFClass

   LOCAL cTxtReport, cTxtPage, cTxtLine, nRow

   cTxtReport := MemoRead( cInputFile ) + Chr(12)
   TokenInit( @cTxtReport, Chr(12) )
   DO WHILE ! TokenEnd()
      cTxtPage := TokenNEXT( cTxtReport ) + hb_eol()
      IF Len( cTxtPage ) > 5
         IF Substr( cTxtPage, 1, 1 ) == Chr(13)
            cTxtPage := Substr( cTxtPage, 2 )
         ENDIF
         ::AddPage()
         nRow := 0
         DO WHILE At( hb_eol(), cTxtPage ) != 0
            cTxtLine := Substr( cTxtPage, 1, At( hb_eol(), cTxtPage ) - 1 )
            cTxtPage := Substr( cTxtPage, At( hb_eol(), cTxtPage ) + 2 )
            ::DrawText( nRow++, 0, cTxtLine )
         ENDDO
      ENDIF
   ENDDO

   RETURN NIL

METHOD PageHeader() CLASS PDFClass

   LOCAL nCont

   IF Len( ::acHeader ) > 0
      IF ::nPageNumber != 0 .AND. ::nRow != 0 .AND. ::nPdfPage != 0
         ::PageFooter()
      ENDIF
   ENDIF
   ::nPdfPage    += 1
   ::nPageNumber += 1
   ::nRow        := 0
//   Mensagem( "Impressão em andamento, folha " + StrZero( ::nPageNumber, 7 ) )
   ::AddPage()
   IF Len( ::acHeader ) > 0
      ::DrawText( 0, 0, ::cAppEmpresaNome )
      ::DrawText( 0, ( ::MaxCol() - Len( ::acHeader[ 1 ] ) ) / 2, ::acHeader[ 1 ] )
      ::DrawText( 0, ::MaxCol() - 12, "Folha " + StrZero( ::nPageNumber, 6 ) )
      ::DrawLine( 0.5, 0, 0.5, ::MaxCol() )
      ::nRow := 2
      IF Len( ::acHeader ) > 1
         FOR nCont = 2 TO Len( ::acHeader )
            IF ! Empty( ::acHeader[ nCont ] )
               IF nCont == 2
                  ::DrawText( ::nRow++, 0, Padc( AllTrim( ::acHeader[ 2 ] ), ::MaxCol() ) )
               ELSE
                  ::DrawText( ::nRow++, 0, ::acHeader[ nCont ] )
               ENDIF
            ENDIF
         NEXT
         ::DrawLine( ::nRow - 0.5, 0, ::nRow++ - 0.5, ::MaxCol() )
         ::nRow++
      ENDIF
   ENDIF
   ::nCol := 0

   RETURN NIL

METHOD PageFooter() CLASS PDFClass

   LOCAL cTxt
   MEMVAR m_Prog

   IF Len( ::acHeader ) != 0 .AND. ::nPdfPage != 0 // adicionada checagem de nPdfPage
      cTxt := "JPA/" + m_Prog + "/" + Right( Dtos( Date() ), 6 ) + SoNumeros( Time() )
      ::DrawLine( ::MaxRow(), 0, ::MaxRow(), ::MaxCol() - Len( cTxt ) )
      ::DrawText( ::MaxRow(), ::MaxCol() - Len( cTxt ), cTxt )
   ENDIF

   RETURN NIL

METHOD MaxRowTest( nRows ) CLASS PDFClass

   hb_Default( @nRows, 0 )
   IF ::nRow > ::MaxRow() - 2 - nRows
      ::PageHeader()
   ENDIF

   RETURN NIL

METHOD DrawZebrado( nNivel, lDraw ) CLASS PDFClass

   LOCAL nColor

   hb_Default( @nNivel, 1 )
   hb_Default( @lDraw, .F. )
   nNivel := iif( nNivel < 1, 1, iif( nNivel > 5, 5, nNivel ) )
   nColor := ( 10 - nNivel ) / 10   // 0.9, 0.8, 0.7, 0.6
   IF nNivel != 1 .OR. ::lDrawZebrado .OR. lDraw
      ::DrawBox( ::nRow - 1 + 0.3, 0, ::nRow + 0.3, ::MaxCol(), 0.2, 2, { nColor, nColor, nColor } )
   ENDIF
   IF ! lDraw
      ::lDrawZebrado := ! ::lDrawZebrado
   ENDIF

   RETURN NIL

   METHOD DrawI25BarCode( nRow, nCol, nHeight, cCode, nOneBarWidth ) CLASS PDFClass

      LOCAL oZebraBarCode
   
      nCol         := ::ColToPdfCol( nCol )
      nRow         := ::RowToPdfRow( nRow + nHeight )
      nHeight      := ::RowToPdfRow( 0 ) - ::RowToPdfRow( nHeight )
      hb_default( @nOneBarWidth, 0.4 )
   
      // HPDF_Page_GSave( ::oPage )
      // HPDF_Page_Concat( ::oPage, 0.1, 0, 0, 0.1, 0, 0)
   
      oZebraBarCode := hb_zebra_create_itf( cCode, HB_ZEBRA_FLAG_WIDE2_5 )
      IF ( oZebraBarCode != NIL )
         IF hb_zebra_geterror( oZebraBarCode ) == 0
            hb_zebra_draw( oZebraBarCode, {| a, b, c, d | HPDF_Page_Rectangle( ::oPage, a, b, c, d ) }, nCol, nRow, nOneBarWidth, nHeight )
            HPDF_Page_Fill( ::oPage )
         ENDIF
      ENDIF
      hb_zebra_destroy( oZebraBarCode )
      // HPDF_Page_GRestore( ::oPage )
   
      RETURN Nil
   
   METHOD DrawBarcodeQRCode( nRow, nCol, nHeight, cCode, nFlags ) CLASS PDFClass
   
      LOCAL hZebra, nWidth
   
      nCol         := ::ColToPdfCol( nCol )
      nRow         := ::RowToPdfRow( nRow + nHeight )
      nHeight      := ::RowToPdfRow( 0 ) - ::RowToPdfRow( nHeight )
      nWidth       := nHeight
   
      hZebra := hb_Zebra_Create_QRCode( cCode, nFlags )
      IF hb_Zebra_GetError( hZebra ) == 0
         hb_Zebra_Draw( hZebra, { | x, y, w, h | HPDF_Page_Rectangle( ::oPage, x, y, w, h ) }, nCol, nRow, nWidth, -nHeight )
         HPDF_Page_Fill( ::oPage )
         hb_Zebra_Destroy( hZebra )
      ENDIF
   
      RETURN NIL



METHOD SelectPrinterType( nPrinterType ) CLASS PDFClass

//   wAchoice( 5, 10, txtSaida(), @nPrinterType, "Formato de Saída" )
   ::SetType( nPrinterType )

   RETURN ( LastKey() != K_ESC )

FUNCTION TxtSaida()

   RETURN { "PDF Paisagem", "PDF Retrato", "Matricial" }

FUNCTION ConfirmaImpressao()

   LOCAL lPrint

   lPrint := hwg_MsgYesNo( "Confirma a impressão?" )
//   IF lPrint
//      Mensagem( "Relatório sendo efetuado... ESC interrompe" )
//   ENDIF

   RETURN lPrint

FUNCTION PrintSelect( cImpressora )

   LOCAL acPrinterList, nOpc := 1, lOk, nCont

   acPrinterList := Win_PrinterList()
   FOR nCont = 1 TO Len( acPrinterList )
      IF acPrinterList[ nCont ] == Win_PrinterGetDefault()
         nOpc := nCont
         EXIT
      ENDIF
   NEXT
//   WAchoice( 6, Int( MaxCol() / 4 ), acPrinterList, @nOpc, "Impressora" )
   lOk := ( LastKey() != K_ESC )
   IF lOk
      cImpressora := acPrinterList[ nOpc ]
      hwg_Exclamation( cImpressora )
      // Win_PrinterSetDefault( acPrinterList[ nOpc ] )
   ENDIF

   RETURN lOk

   /*
   STATIC FUNCTION PrintRaw( cFileTxt, cReportName )

   LOCAL cPrinter := ""

   hb_Default( @cReportName, "win_PrintFileRaw" )
   cPrinter := Win_PrintDlgDc( @cPrinter,,, )
   IF ! Empty( cPrinter )
   Win_PrintFileRaw( cPrinter, cFileTxt, cReportName )
   ENDIF

   RETURN NIL
   */

FUNCTION AppPrinterType( xValue )

   STATIC AppPrinterType := PDFCLASS_PORTRAIT

   IF xValue != NIL .AND. xValue > 0 .AND. xValue <= Len( TxtSaida() )
      AppPrinterType := xValue
   ENDIF

   RETURN AppPrinterType
   
   
FUNCTION PrintBegin()

   SET DEVICE TO PRINT
   SetPRC( 0, 0 )

   RETURN NIL

FUNCTION PrintEnd()

   SET DEVICE TO SCREEN
   SET PRINTER TO
   SetPRC( 0, 0 )

   RETURN NIL
   
METHOD PrintPreview(  ) CLASS PDFClass

   if strzero(M->NIV_ACESSO,1,0)$"012457"
      IF ! EMPTY(::cDefaultPrinter)
         IF FILE(hb_Dirbase()+'SumatraPDF.EXE')
            WAPI_ShellExecute(NIL, 'OPEN', hb_Dirbase()+'SumatraPDF.EXE', '"' + ::cFileName + '" -print-to "' + ::cDefaultPrinter + '"',, NIL )
         ELSE
            WAPI_ShellExecute(0, 'PRINT', '"' + ::cFileName + '"', '"'  + ::cDefaultPrinter + '"',, NIL )
         ENDIF
      ELSE
         WAPI_ShellExecute( NIL, "OPEN", ::cFileName , NIL,, NIL )	
      ENDIF
   else
      IF FILE(hb_Dirbase()+'SumatraPDF.EXE')
         WAPI_ShellExecute(NIL, 'OPEN', hb_Dirbase()+'SumatraPDF.EXE', '"' + ::cFileName + '"',, NIL )
      ELSE
         WAPI_ShellExecute( NIL, "OPEN", ::cFileName , NIL,, NIL )	
      ENDIF
   endif

return nil

METHOD PrintOptions(  ) CLASS PDFClass

LOCAL oDlg;
	, oLabel1;
	, oCombo1, oCombo2;
	, vCombo1;
	, nCombo2;
	, oLabel2;
	, oOwnerbutton2, oOwnerbutton1 ;
	, aPrn := Win_PrinterList( .t., .f. );
	, iCarga;
	, oBitmap1; 
	, oLabel3;
	

//	IF Empty( aPrn )
//		IF hwg_MsgYesNo( "ATENÇÃO !!! Não foi possivel localizar Nenhuma impressora Instalada no Windows, Deseja Instalar uma Agora ?", "Aviso do Sistema" )
//			RunApplet_imp( "AddPrinter" )
//		ENDIF
//		RETURN nil
//	ENDIF
	for iCarga=1 to len(aPrn)
		IF aPrn[iCarga,1] = WIN_PRINTERGETDEFAULT()
			::cDefaultPrinter := WIN_PRINTERGETDEFAULT()
			vCombo1:=iCarga
			exit
		ENDIF
	next


 
	INIT DIALOG oDlg TITLE "Impressão de Relatórios"  ;
		ICON HIcon():Addresource('SGC_ICON')  ;
		AT 0,0 SIZE 658,237 STYLE WS_DLGFRAME + WS_SYSMENU + DS_CENTER  CLIPPER  NOEXIT  ;  
		
	@ 21,48 BITMAP oBitmap1  SHOW 'REL_PRINT' FROM RESOURCE TRANSPARENT STRETCH 0  ;
         SIZE 90,90
	@ 18,6 SAY oLabel1 CAPTION "INFORME AS OPÇÕES DE IMPRESSÃO"  SIZE 644,22 ;
        STYLE SS_CENTER    ;
        FONT HFont():Add( '',0,-16,700,,,) 

	@ 120,50 SAY oLabel3 CAPTION "Impressora:"  SIZE 118,24 ;
		STYLE SS_CENTER +WS_DLGFRAME 	

	@ 252,50 GET COMBOBOX oCombo1 VAR vCombo1  ITEMS aPRN  SIZE 375,24 ;
			ON CHANGE {|| ::cDefaultPrinter := Alltrim(aPrn[vCombo1,1] ) }


	@ 252,85 GET COMBOBOX oCombo2 VAR nCombo2 ;
        ITEMS {"Relatório Bobina (40 col)","Relatório A4 (80 col)"}  SIZE 226,24 
 		
	@ 120,85 SAY oLabel2 CAPTION "Formato:"  SIZE 118,24 ;
		STYLE SS_CENTER +WS_DLGFRAME 	

	@ 404,145 OWNERBUTTON oOwnerbutton1  SIZE 98,32   ;
        TEXT 'Visualizar'  ;
        COORDINATES 28, 0, 0, 0  ;
        BITMAP 'print_preview' FROM RESOURCE TRANSPARENT;
        COORDINATES 5, 0, 0, 0;
		ON CLICK {|| IIF(nCombo2 = 1, ::SetType( PDFCLASS_ROLLS ), ::SetType( PDFCLASS_LANDSCAPE )),hwg_Enddialog(), oDlg:lresult:=.T., ::cDefaultPrinter := ""  }

   
	@ 525,145 OWNERBUTTON oOwnerbutton2  SIZE 98,32   ;
        TEXT 'Imprimir'  ;
        COORDINATES 30, 0, 0, 0  ;
        BITMAP 'print_impressora' FROM RESOURCE TRANSPARENT;
        COORDINATES 5, 0, 0, 0;
		ON CLICK {|| IIF(nCombo2 = 1, ::SetType( PDFCLASS_ROLLS ), ::SetType( PDFCLASS_LANDSCAPE )),hwg_Enddialog(), oDlg:lresult:=.T. }

	ACTIVATE DIALOG oDlg CENTER


RETURN oDlg:lresult


PIX

Enviado: 04 Jun 2023 18:19
por Itamar M. Lins Jr.
Olá!
Valeu! Vendo o código, não precisa de explicação. Podemos entender com maior facilidade.
Falta a checagem se caiu em conta. Para não precisar ficar acessando o banco para saber se caiu.

Saudações,
Itamar M. Lins Jr.

PIX

Enviado: 04 Jun 2023 18:40
por Fernando queiroz
Itamar M. Lins Jr. escreveu:Olá!
Valeu! Vendo o código, não precisa de explicação. Podemos entender com maior facilidade.
Falta a checagem se caiu em conta. Para não precisar ficar acessando o banco para saber se caiu.

Saudações,
Itamar M. Lins Jr.
Estou estudando as possibilidades para fazer isso, ja deixei tudo pronto para fazer essa funcionalidade, so falta ver com qual API eu vou trabalhar.
Vendo as opções do mercado me deparei com a API do GERENCIANET https://dev.gerencianet.com.br/docs/api-pix-introducao
pesquisei no Youtube e vi que tem gente que esta usando e falando muito bem.

tenho de fazer contato com eles para ver custos e como implantar,

PIX

Enviado: 05 Jun 2023 12:10
por Fernando queiroz
https://youtu.be/3SHvugcVG-Q

video explicando como fazer a geração e retorno de pagamento PIX

achei bem interessante fazer a integracao via GERENCIANET ( BANCO EFI )

No video a linguagem é node.js, mas da para adaptar para HARBOUR em ultimo caso faria igual e colocaria para rodar no servidor de modo independente