HPDF_Page_CurveTo

Moderator: Rathinagiri

Post Reply
User avatar
jairpinho
Posts: 209
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 1 time
Contact:

HPDF_Page_CurveTo

Post by jairpinho » Thu Sep 28, 2017 5:40 pm

Hello, this function is not implemented in hmg
HPDF_Page_CurveTo
HPDF_Page_CurveTo2
HPDF_Page_CurveTo3
I made a simple example not working.

Code: Select all

cArquivo:= DiskName()+ ":\"+CurDir() + "\Relatorio"+ ".pdf" 


   SELECT HPDFDOC cArquivo TO lSuccess ORIENTATION HPDF_ORIENT_LANDSCAPE PAPERSIZE HPDF_PAPER_A4
   SET HPDFDOC  COMPRESS ALL
   SET HPDFDOC  PAGEMODE TO OUTLINE
   SET HPDFINFO AUTHOR      TO 'Jair Pinho'
   SET HPDFINFO CREATOR     TO 'Jair Pinho'
   SET HPDFINFO TITLE      TO 'Relaório'
   SET HPDFINFO SUBJECT     TO 'Criado com LibHaru/HPDF Library'
   SET HPDFINFO KEYWORDS    TO 'HMG, HPDF, Documentation, LibHaru, Harbour, MiniGUI'
   SET HPDFINFO DATECREATED TO date() TIME time()
   SET HPDFDOC  ENCODING TO "WinAnsiEncoding"


   if lSuccess
      
        START HPDFPAGE
        SET HPDFDOC PAGEOUTLINE TITLE "Relatorio de Tendencias" 

			@ 140 , 010  HPDFPRINT LINE TO  140 , 280 PENWIDTH 0.5 COLOR { 255, 0, 0 } // linha x  mm  inicia em cima top = 0
			@ 010 , 050  HPDFPRINT LINE TO  160 , 050 PENWIDTH 0.5 COLOR { 255, 0, 0 }   // linha y  mm inicia em cima top = 0
					
			//@ 297-x1, 210-y1  HPDFPRINT LINE TO 297-x2 , 210-y2 PENWIDTH 2 COLOR { 255, 0, 0 }
			HPDF_Page_CurveTo3(100,50,100,125)
			
			
		END HPDFPAGE
		END HPDFDOC	 
	endif
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

edk
Posts: 168
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 49 times
Been thanked: 99 times

Post by edk » Thu Sep 28, 2017 8:42 pm

Some notes for Hpdf_ functions
1st. units for xpos,ypos, wsize, hsize are in pixels not millimeters
2nd. ypos is reversed. 0 is bottom of page
3rd. fill page is needed.

Try

Code: Select all

hPage       := _HMG_SYSDATA[ 150 ][ 7 ]
nHeight     := _HMG_SYSDATA[ 150 ][ 5 ]
nxPos       := _HMG_HPDF_MM2Pixel( 100 )
nyPos       := nHeight - _HMG_HPDF_MM2Pixel( 50 )
   
HPDF_Page_CurveTo3(nxPos, nyPos, _HMG_HPDF_MM2Pixel( 100 ), _HMG_HPDF_MM2Pixel( 125) )
HPDF_Page_Fill( hPage )

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

Post by jairpinho » Thu Sep 28, 2017 9:18 pm

edk wrote:
Thu Sep 28, 2017 8:42 pm
Some notes for Hpdf_ functions
1st. units for xpos,ypos, wsize, hsize are in pixels not millimeters
2nd. ypos is reversed. 0 is bottom of page
3rd. fill page is needed.

Try

Code: Select all

hPage       := _HMG_SYSDATA[ 150 ][ 7 ]
nHeight     := _HMG_SYSDATA[ 150 ][ 5 ]
nxPos       := _HMG_HPDF_MM2Pixel( 100 )
nyPos       := nHeight - _HMG_HPDF_MM2Pixel( 50 )
   
HPDF_Page_CurveTo3(nxPos, nyPos, _HMG_HPDF_MM2Pixel( 100 ), _HMG_HPDF_MM2Pixel( 125) )
HPDF_Page_Fill( hPage )

Thank you Edk
I could do a functional example for hmg ide, I need this function to do a line graph, with the function HPDFPRINT LINE TO does not work because the values I have are of pixel, and in my executable I need to convert pixel to mm and generate the graph in pdf
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

edk
Posts: 168
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 49 times
Been thanked: 99 times

Post by edk » Fri Sep 29, 2017 10:01 am

You gave bad parameters, missing the handle of a page object.
Here's an example of how to use functions CurveTo.

Code: Select all

//Note: all units are in pixels. The Y axis is reversed relative to HMG HPDF. Point 0 indicates the bottom edge of the page. 

    Page := _HMG_SYSDATA[ 150 ][ 7 ]	//The handle of a page object

/* Curve Example(CurveTo2) */
    x = 330
    y = 440
    x1 = 430
    y1 = 530
    x2 = 480
    y2 = 470
    x3 = 480
    y3 = 90

    HPDF_Page_SetRGBFill (page, 0, 0, 0)				//sets the filling color. See colors: http://libharu.sourceforge.net/graphics.html#Colors
    HPDF_Page_SetRGBStroke( page, 0, 0, 0)				//sets the stroking color

    HPDF_Page_BeginText (page)						//begins a text object and sets the current text position to the point (0, 0).
    HPDF_Page_MoveTextPos (page, 300, 540)				//moves the current text position to the start of the next line with using specified offset values. If the start position of the current line is (x1, y1), the start of the next line is (x1 + x, y1 + y). 
    HPDF_Page_ShowText (page, "CurveTo2(x1, y1, x2, y2)")		//prints the text at the current position on the page.
    HPDF_Page_EndText (page)						//ends a text object

    HPDF_Page_BeginText (page)
    HPDF_Page_MoveTextPos (page, x + 5, y - 5)
    HPDF_Page_ShowText (page, "Current point")
    HPDF_Page_MoveTextPos (page, x1 - x, y1 - y)
    HPDF_Page_ShowText (page, "(x1, y1)")
    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1)
    HPDF_Page_ShowText (page, "(x2, y2)")
    HPDF_Page_EndText (page)

    HPDF_Page_SetDash (page, {3}, 1, 0)					//Sets the line dash pattern in the page to dotted line

    HPDF_Page_SetLineWidth (page, 0.5)					//sets the width of the line used to stroke a path
    HPDF_Page_MoveTo (page, x1, y1)					//starts a new subpath and move the current point for drawing path	
    HPDF_Page_LineTo (page, x2, y2)					//appends a path from the current point to the specified point
    HPDF_Page_Stroke (page)						//paints the current path

    HPDF_Page_SetDash (page, NIL, 0, 0)					//Sets the line dash pattern in the page to solid line

    HPDF_Page_SetLineWidth (page, 1.5)					//sets the width of the line used to stroke a path

    HPDF_Page_MoveTo (page, x, y)					//starts a new subpath and move the current point for drawing path
    HPDF_Page_CurveTo2 (page, x1, y1, x2, y2)				//appends a Bézier curve to the current path using two spesified points
    HPDF_Page_Stroke (page)						//paints the current path

    /* Curve Example(CurveTo3) */
    y -= 150
    y1 -= 150
    y2 -= 150

    HPDF_Page_BeginText (page)
    HPDF_Page_MoveTextPos (page, 300, 390)
    HPDF_Page_ShowText (page, "CurveTo3(x1, y1, x2, y2)")
    HPDF_Page_EndText (page)

    HPDF_Page_BeginText (page)
    HPDF_Page_MoveTextPos (page, x + 5, y - 5)
    HPDF_Page_ShowText (page, "Current point")
    HPDF_Page_MoveTextPos (page, x1 - x, y1 - y)
    HPDF_Page_ShowText (page, "(x1, y1)")
    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1)
    HPDF_Page_ShowText (page, "(x2, y2)")
    HPDF_Page_EndText (page)

    HPDF_Page_SetDash (page, {3}, 1, 0)					//Sets the line dash pattern in the page to dotted line

    HPDF_Page_SetLineWidth (page, 0.5)					//sets the width of the line used to stroke a path
    HPDF_Page_MoveTo (page, x, y)					//starts a new subpath and move the current point for drawing path
    HPDF_Page_LineTo (page, x1, y1)					//appends a path from the current point to the specified point
    HPDF_Page_Stroke (page)						//paints the current path

    HPDF_Page_SetDash (page, NIL, 0, 0)					//Sets the line dash pattern in the page to solid line

    HPDF_Page_SetLineWidth (page, 1.5)					//sets the width of the line used to stroke a path
    HPDF_Page_MoveTo (page, x, y)					//starts a new subpath and move the current point for drawing path
    HPDF_Page_CurveTo3 (page, x1, y1, x2, y2)				//appends a Bézier curve to the current path using two spesified points
    HPDF_Page_Stroke (page)						//paints the current path

    /* Curve Example(CurveTo) */
    y -= 150
    y1 -= 160
    y2 -= 130
    x2 += 10

    HPDF_Page_BeginText (page)
    HPDF_Page_MoveTextPos (page, 300, 240)
    HPDF_Page_ShowText (page, "CurveTo(x1, y1, x2, y2, x3, y3)")
    HPDF_Page_EndText (page)

    HPDF_Page_BeginText (page)
    HPDF_Page_MoveTextPos (page, x + 5, y - 5)
    HPDF_Page_ShowText (page, "Current point")
    HPDF_Page_MoveTextPos (page, x1 - x, y1 - y)
    HPDF_Page_ShowText (page, "(x1, y1)")
    HPDF_Page_MoveTextPos (page, x2 - x1, y2 - y1)
    HPDF_Page_ShowText (page, "(x2, y2)")
    HPDF_Page_MoveTextPos (page, x3 - x2, y3 - y2)
    HPDF_Page_ShowText (page, "(x3, y3)")
    HPDF_Page_EndText (page)

    HPDF_Page_SetDash (page, {3}, 1, 0)					//Sets the line dash pattern in the page to dotted line

    HPDF_Page_SetLineWidth (page, 0.5)					//sets the width of the line used to stroke a path
    HPDF_Page_MoveTo (page, x, y)					//starts a new subpath and move the current point for drawing path
    HPDF_Page_LineTo (page, x1, y1)					//appends a path from the current point to the specified point
    HPDF_Page_Stroke (page)						//paints the current path
    
    HPDF_Page_MoveTo (page, x2, y2)					//starts a new subpath and move the current point for drawing path
    HPDF_Page_LineTo (page, x3, y3)					//appends a path from the current point to the specified point
    HPDF_Page_Stroke (page)						//paints the current path

    HPDF_Page_SetDash (page, NIL, 0, 0)					//Sets the line dash pattern in the page to solid line

    HPDF_Page_SetLineWidth (page, 1.5)					//sets the width of the line used to stroke a path
    HPDF_Page_MoveTo (page, x, y)					//starts a new subpath and move the current point for drawing path
    HPDF_Page_CurveTo (page, x1, y1, x2, y2, x3, y3)			//appends a Bézier curve to the current path using two spesified points
    HPDF_Page_Stroke (page)						//paints the current path

Post Reply