pdf grid

Moderator: Rathinagiri

edk
Posts: 382
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 110 times
Been thanked: 278 times

Re: pdf grid

Post by edk » Fri Oct 06, 2017 3:59 pm

It should be in Ansi.
I think Jair was about the word "Mínimo:" as UTF8 in prg, which show as "MÃ-nimo" in PDF Ansi.
In the example I showed both words.
If you save prg in UTF8, then in PDF you will see MÃ-nimo instead of Mínimo (second word)

Maybe this will be helpful for PDF in UTF8 https://github.com/libharu/libharu/issues/27

User avatar
jairpinho
Posts: 251
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Fri Oct 06, 2017 7:26 pm

edk wrote:
Fri Oct 06, 2017 2:21 pm
I don't see the problem with accents:

Code: Select all

#include "hmg.ch"

Function Main()
Local i

SELECT HPDFDOC "sample.pdf" ORIENTATION HPDF_ORIENT_LANDSCAPE PAPERSIZE HPDF_PAPER_A4
SET HPDFDOC ENCODING TO "WinAnsiEncoding"
START HPDFDOC
    START HPDFPAGE

     print_grid( 400, 150, 160, 200, 5, 5, 20 , 20 , 10 , 10 )
     HPDF_RotateTextPx( 510, 200, 'MĂ-nimo: 119 -> "Mínimo: "', Nil, 7, 90 , , , , 'T' )  //units: pixels

     
     
    END HPDFPAGE
        

END HPDFDOC

Execute File 'sample.pdf'
Return Nil
*******************************
PROCEDURE HPDF_RotateTextPx( nRow, nCol, cTxt, cFont, nFontSize, nAngle, lBold, lItalic, aColors, cAlign)
* Rotating text

   Local nRad, nTextWidth, oFont, cFnt
   
   Local hPdf        := _HMG_SYSDATA[ 150 ][ 1 ]
   Local hPage       := _HMG_SYSDATA[ 150 ][ 7 ]
   Local cPdfEnc     := _HMG_SYSDATA[ 150 ][ 10 ]

   Local nWidth      := _HMG_SYSDATA[ 150 ][ 4 ]
   Local nHeight     := _HMG_SYSDATA[ 150 ][ 5 ]
   Local nxPos       := nCol
   Local nyPos       := nRow

   DEFAULT cFont       := "Helvetica"
   DEFAULT nFontSize   := 12   
   DEFAULT cTXt        := ""
   DEFAULT nAngle      := 0
   DEFAULT lBold       := .F.
   DEFAULT lItalic     := .F.
   DEFAULT aColors     := { 0, 0, 0}
   DEFAULT cAlign      :=""		//Empty - Left and bottom, R - Right, C - Center, T - Top, M - Middle

   If _HMG_SYSDATA[ 150 ][ 1 ] == Nil // PDF object not found!
      _HMG_HPDF_Error( 3 )
      Return Nil
   endif

   If _HMG_SYSDATA[ 150 ][ 7 ] == Nil // PDF Page object not found!
      _HMG_HPDF_Error( 5 )
      Return Nil
   endif

   
   IF VALTYPE(cAlign)#'C' 
      cAlign := ''		//Left as default
   ENDIF
   
   
   // set color
   If VALTYPE( aColors )#'A' .OR. LEN( aColors )#3 .OR. ;
      VALTYPE( aColors[1] )#'N' .OR. VALTYPE( aColors[2] )#'N' .OR. VALTYPE( aColors[3] )#'N' .OR. ;
      aColors[1]<0 .OR. aColors[1]>255 .OR. ;
      aColors[2]<0 .OR. aColors[2]>255 .OR. ;
      aColors[3]<0 .OR. aColors[3]>255
      
      aColors     := { 0, 0, 0}
   Endif 
   HPDF_Page_SetRGBFill( hPage, aColors[1]/255, aColors[2]/255, aColors[3]/255 )   

   // set font
   If HMG_LEN( AllTrim( cFont ) ) == 0
      cFont := _HMG_HPDF_SetFont( cFont, lBold, lItalic )
      oFont := HPDF_GetFont( hPdf, cFont, cPdfEnc )

   else

      cFont := AllTrim(_HMG_HPDF_SetFont( cFont, lBold, lItalic ))
    
      if HMG_UPPER (cFileExt (cFont)) == '.TTF' // load ttf font
   
         cFnt := HPDF_LOADTTFONTFROMFILE( hPdf, cFont, .t. )

         If HMG_LEN( Alltrim( cFnt ) ) == 0
            _HMG_HPDF_Error( 6 , cFont )
            Return Nil
         endif

         oFont := HPDF_GetFont( hPdf, cFnt, cPdfEnc )
     
      else
     
         If HMG_UPPER( alltrim( cFont ) ) == "SYMBOL" .or. HMG_UPPER( alltrim( cFont ) ) == "ZAPFDINGBATS"
            oFont := HPDF_GetFont( hPdf, cFont, Nil )
         else   
            oFont := HPDF_GetFont( hPdf, cFont, cPdfEnc )
         endIf
   
      endif

   endIf
   
   If oFont == Nil
      _HMG_HPDF_Error( 6 , cFont )
      Return Nil
   Endif

   HPDF_Page_SetFontAndSize( hPage, oFont, nFontSize )
   nTextWidth := HPDF_Page_TextWidth( hPage, cTxt )
   
   nRad := nAngle / 180 * 3.141592 	//radian value
   
   //calculate nxPos
   IF 'R'$HMG_UPPER(cAlign)		//Right
      nxPos:=nxPos - (nTextWidth* cos (nRad))
   ELSEIF 'C'$HMG_UPPER(cAlign)	//Center
   	 nxPos:=nxPos - ((nTextWidth* cos (nRad))/2)
   ENDIF
   
   //calculate nyPos
   IF 'T'$HMG_UPPER(cAlign)		//Top
      nyPos:=nyPos - (nTextWidth* sin (nRad))
   ELSEIF 'M'$HMG_UPPER(cAlign)	//Middle
   	 nyPos:=nyPos - ((nTextWidth* sin (nRad))/2)
   ENDIF
 
   HPDF_Page_BeginText( hPage )
   HPDF_Page_SetTextMatrix ( hPage, cos ( nRad ), sin ( nRad ), -sin ( nRad ), cos ( nRad ), nxPos , nyPos)
   HPDF_Page_ShowText( hPage, cTxt )
   HPDF_Page_EndText( hPage )

RETURN

*------------------------------------------------------------------------*
Function print_grid( nRow, nCol, height, width, nScaleLine_X, nScaleLine_Y, nScaleText_X, nScaleText_Y, nTag_x, nTag_Y )
*------------------------------------------------------------------------*
   Local  font,x,y, cLabel, nLabWidth
   Local Pdf        := _HMG_SYSDATA[ 150 ][ 1 ]
   Local Page       := _HMG_SYSDATA[ 150 ][ 7 ]  
   Local cPdfEnc    := _HMG_SYSDATA[ 150 ][ 10 ]

   Local nFontSize   := 5

    font := HPDF_GetFont (pdf, "Helvetica", cPdfEnc)

    HPDF_Page_SetFontAndSize (page, font, nFontSize)
    HPDF_Page_SetGrayFill (page, 0.5)
    HPDF_Page_SetGrayStroke (page, 0.8)


    /* Draw horizontal lines */
    y := 0 // distabcia inicio primeira linha
    while (y <= height )
        if  (y % (nScaleLine_Y*2) == 0)
            HPDF_Page_SetLineWidth (page, 0.5)
        else
           if (HPDF_Page_GetLineWidth (page) != 0.25)
              HPDF_Page_SetLineWidth (page, 0.25)
           Endif
        Endif

        HPDF_Page_MoveTo (page, nCol, y + nRow)
        HPDF_Page_LineTo (page, width + nCol, y + nRow)
        HPDF_Page_Stroke (page)

        if (y % nTag_Y == 0 .and. y > 0)
            HPDF_Page_SetGrayStroke (page, 0.5)

            HPDF_Page_MoveTo (page, nCol, y + nRow)
            HPDF_Page_LineTo (page, nScaleLine_Y + nCol , y + nRow)
            HPDF_Page_Stroke (page)

            HPDF_Page_SetGrayStroke (page, 0.8)
        Endif

        y += nScaleLine_Y
    End

    /* Draw vertical lines */



    x := 0 //distabcia inicio primeira linha
    while (x <= width)
        if (x % (nScaleLine_X*2) == 0)
            HPDF_Page_SetLineWidth (page, 0.5)
        else
            if (HPDF_Page_GetLineWidth (page) != 0.25)
                HPDF_Page_SetLineWidth (page, 0.25)
            Endif
        Endif

        HPDF_Page_MoveTo (page, x + nCol, nRow)
        HPDF_Page_LineTo (page, x + nCol, height + nRow)
        HPDF_Page_Stroke (page)

        if (x % nTag_X == 0 .and. x > 0)  // linha de referencia com a tag texto linha mais forte
            HPDF_Page_SetGrayStroke (page, 0.5)

            //tag esquerda
	    HPDF_Page_MoveTo (page, x + nCol, nRow)
            HPDF_Page_LineTo (page, x + nCol, nScaleLine_X + nRow )
            HPDF_Page_Stroke (page)

            //tag direita
	    HPDF_Page_MoveTo (page, x + nCol, height + nRow)
            HPDF_Page_LineTo (page, x + nCol, height - nScaleLine_X + nRow)
            HPDF_Page_Stroke (page)

            HPDF_Page_SetGrayStroke (page, 0.8)
        Endif

        x += nScaleLine_X
    End



    /* Draw horizontal text */


    y := 0 //distabcia inicio texto
    while (y < height)
        if (y % (nScaleText_Y) == 0 .and. y > 0)
	    cLabel:=ltrim(str(y))
            HPDF_Page_BeginText (page)
            HPDF_Page_MoveTextPos (page, nScaleLine_Y + nCol, y + nRow - (nFontSize/2) + .75  /* Middled Label */)
            HPDF_Page_ShowText (page, cLabel)
            HPDF_Page_EndText (page)
        Endif

        y += nScaleText_Y
    End


    /* Draw virtical text */

    x := 0
    while (x < width)
        if (x % (nScaleText_X) == 0 .and. x > 0)
            cLabel:=ltrim(str(x))
	    nLabWidth:=HPDF_Page_TextWidth( page, cLabel )

            //tag em baixo
	    HPDF_Page_BeginText (page)
            HPDF_Page_MoveTextPos (page, x + nCol - (nLabWidth/2)  /* Centered label */, nScaleLine_X + nRow + 1)
            HPDF_Page_ShowText (page, cLabel)
            HPDF_Page_EndText (page)

            //tag em cima
	    HPDF_Page_BeginText (page)
            HPDF_Page_MoveTextPos (page, x + nCol - (nLabWidth/2)  /* Centered label */, height - (nScaleLine_X * 2) + nRow)
            HPDF_Page_ShowText (page, cLabel)
            HPDF_Page_EndText (page)
        Endif

        x += nScaleText_X
    End

    HPDF_Page_SetGrayFill (page, 0)
    HPDF_Page_SetGrayStroke (page, 0)
	
Return Nil


sample.7z

Do you have a .prg file saved in UTF-8? Perhaps this is a problem.
Prg in ANSI works fine: Demo.7z
rotatetext () is okay the problem and in print_grid () follows new code

Code: Select all


*------------------------------------------------------------------------*
Function print_grid( nRow_pdf, nCol, height, width, nScaleLine_X, nScaleLine_Y, nScaleText_X, nScaleText_Y, nTag_x, nTag_Y,nMim,nMax )
*------------------------------------------------------------------------*
	Local  ofont, x , y , yMin_max, cLabel, nLabWidth
	Local Pdf        	:= _HMG_SYSDATA[ 150 ][ 1 ]
	Local Page       	:= _HMG_SYSDATA[ 150 ][ 7 ]  
	Local cEncoding 	:= _HMG_SYSDATA[ 150 ] [ 10 ]       //Value of "SET HPDFDOC ENCODING TO".   "SET HPDFDOC ENCODING TO" set _HMG_HPDF_SetEncoding
	Local nHeigth_pdf 	:= HPDF_Page_GetHeight (_HMG_SYSDATA[ 150 ][ 7 ])
	Local nCinza 		:= 0.90  // 1 igual a branco total
	Local nRow 			:= nHeigth_pdf - nRow_pdf
	Local nyPos       	:= 0
	
	Local cFont       := "Helvetica"
	Local nFontSize   	:= 10
  	Local lBold       := .F.
	Local  lItalic     := .F.
	Local  aColors     := { 0, 0, 0}
	Local  cAlign      :=""		//Empty - Left and bottom, R - Right, C - Center, T - Top, M - Middle
	
    

		ofont := HPDF_GetFont (Pdf, cFont, cEncoding)
		HPDF_Page_SetFontAndSize (Page, ofont, nFontSize)
		
	HPDF_Page_SetGrayFill (page, 0.25)
    HPDF_Page_SetGrayStroke (page, nCinza)
	
	/*
		As cores são especificadas usando três números reais (ou seja, com um ponto decimal) na forma R G B onde cada número define a quantidade de vermelho (R), verde (G) e azul (B) em uma cor.
		Os números válidos são de 0,0 a 1,0 inclusive ou divide por 255 
		HPDF_Page_SetRGBFill( hPage, aColors[1]/255, aColors[2]/255, aColors[3]/255 )
	*/
	
    /* Draw horizontal lines */
	
    yMin_max := 0 // linhas de tolerancias 
    while (yMin_max <= height )
	
		if yMin_max == nMim 
			HPDF_Page_SetLineWidth (page, 0.5)
			HPDF_Page_SetDash (page, {3}, 1, 1)
			//HPDF_Page_SetGrayStroke(page, 0,0,0)
			HPDF_Page_SetRGBStroke (page, 0 , 0 , 0 ) // (page, 0.0 , 255/255, 0.0 )
			
			HPDF_Page_MoveTo (page, nCol, yMin_max + nRow)
			HPDF_Page_LineTo (page, width + nCol, yMin_max + nRow)
			HPDF_Page_Stroke (page)	
			
			
			nAngle := 0
			nRad := nAngle / 180 * 3.141592 	//radian value
			nTextWidth := HPDF_Page_TextWidth( page ,"Mínimo: " +alltrim(str(nMim) ))
		   
		    nxPos:= 85  - (nTextWidth* cos (nRad))  // posição coluna do texto
			nyPos := nRow + nMim 
            HPDF_Page_BeginText (page)			
			HPDF_Page_SetTextMatrix ( page , cos ( nRad ), sin ( nRad ), -sin ( nRad ), cos ( nRad ), nxPos , nyPos  - nFontSize/2 + .75 ) // nyPos = posicao Linha(Row)
			HPDF_Page_ShowText (page, "Mínimo: "+alltrim(str(nMim)))
            HPDF_Page_EndText (page)			
			
			
			HPDF_Page_SetDash (page, NIL, 0, 0)
			HPDF_Page_SetGrayStroke (page, nCinza)
			
		elseif yMin_max == nMax
		
			HPDF_Page_SetLineWidth (page, 0.5)
			HPDF_Page_SetDash (page, {3}, 1, 1)
			//HPDF_Page_SetGrayStroke(page, 0,0,0)
			HPDF_Page_SetRGBStroke (page, 0 , 0, 0 ) // (page, 0.0 , 255/255, 0.0 )
			
			HPDF_Page_MoveTo (page, nCol, yMin_max + nRow)
			HPDF_Page_LineTo (page, width + nCol, yMin_max + nRow)
			HPDF_Page_Stroke (page)	

		
			nAngle := 0
			nRad := nAngle / 180 * 3.141592 	//radian value
			nTextWidth := HPDF_Page_TextWidth( page , "Máximo: "+alltrim(str(nMax)))
		   
		    nxPos:= 85  - (nTextWidth* cos (nRad))  // // posição coluna do texto
			nyPos := nRow + nMax
            HPDF_Page_BeginText (page)			
			HPDF_Page_SetTextMatrix ( page , cos ( nRad ), sin ( nRad ), -sin ( nRad ), cos ( nRad ), nxPos , nyPos  - nFontSize/2 + .75 ) // nyPos = posicao Linha(Row)
			HPDF_Page_ShowText (page, "Máximo: "+alltrim(str(nMax)))
            HPDF_Page_EndText (page)
			
			
			HPDF_Page_SetDash (page, NIL, 0, 0)
			HPDF_Page_SetGrayStroke (page, nCinza)

		endif
		
       yMin_max += 1
    End


Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

EduardoLuis
Posts: 601
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Has thanked: 1 time
Been thanked: 39 times

Post by EduardoLuis » Fri Oct 06, 2017 8:44 pm

Hi colleagues:

Edk last code works fine, i've tested.-
Jaipirinho, you must convert prg from UTF8 to ansi, replace ma nimo with Máximo, and save your prg.-
With regards.
Eduardo

User avatar
serge_girard
Posts: 2153
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 464 times
Been thanked: 108 times
Contact:

Post by serge_girard » Sat Oct 07, 2017 6:27 am

Thx Eduardo and Kryzstof ! This works fine.

Serge

User avatar
jairpinho
Posts: 251
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Wed Oct 11, 2017 4:27 pm

thank you all really my prg file was like utf8 converted to ansi it worked perfectly, it follows the complete design including all the requested topics in a single project, if anyone needs this ready, it was very useful in my project.

Related Posts
http://www.hmgforum.com/viewtopic.php?f=39&t=5404
http://www.hmgforum.com/viewtopic.php?f=40&t=5406


Project
Tendencia_Rev2_ok.rar
(6.69 KiB) Downloaded 69 times
Image
Image
Attachments
Relatoriojpg_Page2jpg_Page1.jpg
Relatoriojpg_Page2jpg_Page1.jpg (83.18 KiB) Viewed 1585 times
Relatoriojpg_Page1.jpg
Relatoriojpg_Page1.jpg (79.39 KiB) Viewed 1586 times
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

edk
Posts: 382
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 110 times
Been thanked: 278 times

Post by edk » Wed Oct 11, 2017 4:41 pm

Brawo Ty :D

User avatar
jairpinho
Posts: 251
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Wed Oct 11, 2017 5:07 pm

edk wrote:
Wed Oct 11, 2017 4:41 pm
Brawo Ty :D
You were important in this project, without your help you would not be able to
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
jairpinho
Posts: 251
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Tue Nov 27, 2018 12:58 am

Hi everyone, I did some tests with grid in pdf where I can customize the herders size of the lines and data in a vector, I am providing the result so that you need


Image

Code: Select all

***************************************************************************************
Function teste()
**************************************************************************************
Local i, lSuccess
LOCAL aSize_Col := {25,90,15,15}
LOCAL aSize_Row := {5,10,10,20,20}
Local aDados := {}

	SELECT HPDFDOC "sample.pdf" TO lSuccess ORIENTATION HPDF_ORIENT_LANDSCAPE PAPERSIZE HPDF_PAPER_A4
	SET HPDFDOC ENCODING TO "WinAnsiEncoding"
	START HPDFDOC
    START HPDFPAGE
	    
		//msgdebug(HPDF_Page_GetHeight (_HMG_SYSDATA[ 150 ][ 7 ]))
		 //msgdebug(HPDF_Page_GetWidth (_HMG_SYSDATA[ 150 ][ 7 ]))
 	@10,10 HPDFPRINT "Grid Demo Page 1"
	
	
	AADD(aDados , {"A1","A2","A3","A4","A5"})
	AADD(aDados , {"B1","B2","C3","C4","C5"})
	AADD(aDados , {"C1","C2","D3","D4","D5"})
	AADD(aDados , {"E1","E2","E3","E4","E5"})
	AADD(aDados , {"F1","F2","F3","F4","F5"})
	AADD(aDados , {"G1","G2","G3","G4","G5"})
	
	//MSGDEBUG(LEN(aDados))
	
	print_grid_A( 50, 50, 10 ,aSize_Col,{"col1","col2","col3","Col4"},aDados)

    END HPDFPAGE    
    
        

END HPDFDOC

IF lSuccess
   Execute File 'sample.pdf'
ENDIF	

Return Nil



Code: Select all


*------------------------------------------------------------------------*
Function print_grid_A( nRow_pdf, nCol_pdf, nSize_Row , aSize_Col, aHeaders, aDados )
*------------------------------------------------------------------------*
	    Local  font, cLabel, nLabWidth
	    Local Pdf        := _HMG_SYSDATA[ 150 ][ 1 ]
	    Local Page       := _HMG_SYSDATA[ 150 ][ 7 ]  
	    Local nFontSize   := 5
		Local nHeigth_pdf := HPDF_Page_GetHeight (_HMG_SYSDATA[ 150 ][ 7 ])  // pega altura da pagina em pixel
		Local nWidth_pdf := HPDF_Page_GetWidth  (_HMG_SYSDATA[ 150 ][ 7 ])  // pega comprimento da pagina em pixel
		Local nRow_Y :=	nHeigth_pdf - _HMG_HPDF_MM2Pixel( nRow_pdf )
		Local nCol_X :=  _HMG_HPDF_MM2Pixel( nCol_pdf ) //- nWidth_pdf
		Local nRow :=  nRow_pdf
		Local nCol :=  nCol_pdf
		LOCAL nQt_Col := LEN(aSize_Col)
		Local nSize_colunas := 0
		Local nSize_Linhas :=  0
		Local	y := 0// linhas na horizontal
		Local 	i := 0
		Local  nSize_Header  := 12

			IF EMPTY(aHeaders)
				MsgInfo("Cabeçalhos esta vazio")
				Return Nil
			Else
				nQt_Col := Len(aHeaders)
			ENDIF

			IF EMPTY(nSize_Row) 
				MsgInfo("tamanho da linha esta vazio")
				Return Nil
			else

				nQt_Row := Len(aDados)

			ENDIF

			IF EMPTY(aSize_Col)
				MsgInfo("tamanho da coluna esta vazio")
				Return Nil
			ENDIF
	
	
					font = HPDF_GetFont (pdf, "Helvetica", Nil)
					HPDF_Page_SetFontAndSize (page, font, nFontSize)
					HPDF_Page_SetGrayFill (page, 0)  // cor da fonte  = preto
					HPDF_Page_SetGrayStroke (page, 0)  // 0 == preto
					HPDF_Page_SetLineWidth (page, 0.5)

	
					nColuna := 1
					nLinha := 1 
					i := 0
					//* Draw vertical linhas montagem das colunas */
					x := 0 //linhas na vertical  ok

					for x := 1 to len(aSize_Col)
						nSize_colunas += _HMG_HPDF_MM2Pixel(aSize_Col[x])
					next

						nSize_Linhas += nSize_Row * nQt_Row

					Size_Row := 0
					y := 0		// linhas na horizontal
					i := 0
	
				//MONTA O HEADER nao mexer
					x := 0
					For  Col := 1  to nQt_Col
							cLabel:=aHeaders[Col]
							nLabWidth:=HPDF_Page_TextWidth( page, cLabel )
							IIF( Col == nQt_Col , 0 , Size_Col := _HMG_HPDF_MM2Pixel(aSize_Col[Col])	) 
							HPDF_Page_BeginText (page)
							HPDF_Page_MoveTextPos (page, (x + nCol_X + (Size_Col/2)) - (nLabWidth/2)   ,  nRow_Y - (nFontSize/2 - .75 ) - (nSize_Header/2)   ) // headers
							HPDF_Page_ShowText (page, cLabel)
							HPDF_Page_EndText (page)
							X += Size_Col
					NEXT		

For  Row := 0 to nQt_Row +1


					// Draw horizontal lines 
					HPDF_Page_MoveTo (page, nCol_X, y + nRow_Y)
					HPDF_Page_LineTo (page, nSize_colunas + nCol_X , y + nRow_Y)
					HPDF_Page_Stroke (page)
					
				//// DADOS NA GRID

				IF Row > 0 .and. Row < nQt_Row +1
				
					x := 0
					For  Col := 1  to nQt_Col
					
							cLabel:=aDados[Row,Col]
							nLabWidth:=HPDF_Page_TextWidth( page, cLabel )
							
							IIF( Col == nQt_Col , 0 , Size_Col := _HMG_HPDF_MM2Pixel(aSize_Col[Col])	) 
							
							HPDF_Page_BeginText (page)
							HPDF_Page_MoveTextPos (page, x + nCol_X + (Size_Col/2) - (nLabWidth/2 )   , nRow_Y + y - (nSize_Row/2) - (nFontSize/2 - .75 )     )  // headers
							HPDF_Page_ShowText (page, cLabel)
							HPDF_Page_EndText (page)
							X += Size_Col
					NEXT
					
				ENDIF

				IF ROW < 1
					y -= nSize_Header   // tamanho padra para headers  = nSize_Header
				ELSE
					y -= nSize_Row  //distancia entre linhas
				ENDIF
NEXT

				/////////////////////////////COLUNAS////////////////////////
	
		x := 0
		For  Col := 0  to nQt_Col
		
				IIF( Col == nQt_Col , 0 , Size_Col := _HMG_HPDF_MM2Pixel(aSize_Col[Col+1])	) 

				HPDF_Page_MoveTo (page, x + nCol_X,   nRow_Y)
				HPDF_Page_LineTo (page, x + nCol_X , nRow_Y  - nSize_Linhas - nSize_Header)
				HPDF_Page_Stroke (page)
				x += Size_Col  // distancia entre colunas
		next


    HPDF_Page_SetGrayFill (page, 0)
    HPDF_Page_SetGrayStroke (page, 0)
	
Return Nil

Attachments
samplejpg_Page1.jpg
samplejpg_Page1.jpg (27.41 KiB) Viewed 170 times
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
andyglezl
Posts: 1057
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 24 times
Been thanked: 46 times
Contact:

Post by andyglezl » Tue Nov 27, 2018 4:39 am

Hi everyone, I did some tests with grid in pdf where I can customize the herders size of the lines and data in a vector, I am providing the result so that you need

Es una pregunta ?
Puedes cambiar los siguientes valores para cada columna...
+------------------------------------------------------------------------
It is a question ?
You can change the following values for each column ...


LOCAL aSize_Col := {25,90,15,15}

LOCAL aSize_Row := {5,10,10,20,20} // ************ Where do you use this array?

print_grid_A( 50, 50, 10 , aSize_Col,{"col1","col2","col3","Col4"},aDados)

*------------------------------------------------------------------------*
Function print_grid_A( nRow_pdf, nCol_pdf, nSize_Row , aSize_Col, aHeaders, aDados )
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
jairpinho
Posts: 251
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Tue Nov 27, 2018 5:31 pm

andyglezl wrote:
Tue Nov 27, 2018 4:39 am
Hi everyone, I did some tests with grid in pdf where I can customize the herders size of the lines and data in a vector, I am providing the result so that you need

Es una pregunta ?
Puedes cambiar los siguientes valores para cada columna...
+------------------------------------------------------------------------
It is a question ?
You can change the following values for each column ...


LOCAL aSize_Col := {25,90,15,15}

LOCAL aSize_Row := {5,10,10,20,20} // ************ Where do you use this array?

print_grid_A( 50, 50, 10 , aSize_Col,{"col1","col2","col3","Col4"},aDados)

*------------------------------------------------------------------------*
Function print_grid_A( nRow_pdf, nCol_pdf, nSize_Row , aSize_Col, aHeaders, aDados )


Hello Andrés, yes I had this option I also removed to be equal a window grid with the only option for all lines this vector should be disregarded, the value 10 equals for all lines after the header, the header has a fixed value of 12.
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

Post Reply