label at runtime

Moderator: Rathinagiri

KDJ
Posts: 164
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 148 times

Re: label at runtime

Post by KDJ » Thu Sep 07, 2017 5:38 pm

Can be used BT_DrawText or BT_DrawTextEx function.
Sample is in: ...\hmg\SAMPLES\BosTaurus\Demo3.prg.

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

Post by jairpinho » Thu Sep 07, 2017 6:02 pm

KDJ wrote:
Thu Sep 07, 2017 5:38 pm
Can be used BT_DrawText or BT_DrawTextEx function.
Sample is in: ...\hmg\SAMPLES\BosTaurus\Demo3.prg.


Thank you, KDJ, exactly.
nTypeText := BT_TEXT_OPAQUE + BT_TEXT_BOLD + BT_TEXT_ITALIC + BT_TEXT_UNDERLINE
nAlingText := BT_TEXT_CENTER + BT_TEXT_BASELINE
nOrientation := 90
BT_DrawText (hDC, 300, 400, " The Power of HMG 1", "Comic Sans MS", 42, WHITE, BLACK, nTypeText, nAlingText, nOrientation)
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

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

Post by jairpinho » Thu Sep 07, 2017 6:22 pm

this is the result, now I just need to do this in pdf.
Main.zip
(3.51 KiB) Downloaded 7 times
Image
Attachments
GRAPH-OK.png
GRAPH-OK.png (88.85 KiB) Viewed 110 times
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

edk
Posts: 140
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 39 times
Been thanked: 77 times

Post by edk » Thu Sep 07, 2017 7:20 pm

I hope this will be helpful:

Code: Select all

#include "hmg.ch"

Function Main()
Local i

SELECT HPDFDOC "sample.pdf" PAPERLENGTH 300 PAPERWIDTH 300 LOG
SET HPDFDOC ENCODING TO "WinAnsiEncoding"
START HPDFDOC
    START HPDFPAGE
	    
	@10,10 HPDFPRINT "Rotate Demo"
        
        HPDF_RotateText( 50, 80, "ABCxyz123", Nil, Nil, 90 ) 
	HPDF_RotateText( 50, 80, "ABCxyz123", Nil, Nil, 180)
        HPDF_RotateText( 50, 80, "ABCxyz123", Nil, Nil, 270)
	HPDF_RotateText( 50, 80, "ABCxyz123", Nil, Nil, 0 )
	
	FOR i=100 TO 300 STEP 10
		@i,10 HPDFPRINt "Happy HMG"
	NEXT i

	FOR i=0 To 345 STEP 15
		HPDF_RotateText( 150, 150, "Happy HMG", Nil, 10, i )	
	NEXT i	


    END HPDFPAGE
        

END HPDFDOC

Execute File 'sample.pdf'
Return Nil
*******************************
PROCEDURE HPDF_RotateText( nRow, nCol, cTxt, cFont, nFontSize, nAngle )
* Rotating text

   Local nRad, nTextWidth 
   
   Local hPdf        := _HMG_SYSDATA[ 150 ][ 1 ]
   Local hPage       := _HMG_SYSDATA[ 150 ][ 7 ]

   Local nWidth      := _HMG_SYSDATA[ 150 ][ 4 ]
   Local nHeight     := _HMG_SYSDATA[ 150 ][ 5 ]
   Local nxPos       := _HMG_HPDF_MM2Pixel( nCol )
   Local nyPos       := nHeight - _HMG_HPDF_MM2Pixel( nRow )

   DEFAULT cFont       := "Helvetica"
   DEFAULT nFontSize    := 12   
   DEFAULT cTXt        := ""
   DEFAULT nAngle      := 0


   nTextWidth := HPDF_Page_TextWidth( hPage, cTxt )

   nRad := nAngle / 180 * 3.141592 	//radian value

   HPDF_Page_SetFontAndSize( hPage, HPDF_GetFont( hPdf, cFont, NIL ), nFontSize )
   HPDF_Page_BeginText( hPage )
   HPDF_Page_SetTextMatrix ( hPage, cos ( nRad ), sin ( nRad ), -sin ( nRad ), cos ( nRad ), nxPos , nyPos - nFontSize)
   HPDF_Page_ShowText( hPage, cTxt )
   HPDF_Page_EndText( hPage )

RETURN

pdf.JPG
pdf.JPG (24.92 KiB) Viewed 102 times

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

Post by jairpinho » Thu Sep 07, 2017 10:04 pm

edk wrote:
Thu Sep 07, 2017 7:20 pm
I hope this will be helpful:

Code: Select all

#include "hmg.ch"

Function Main()
Local i

SELECT HPDFDOC "sample.pdf" PAPERLENGTH 300 PAPERWIDTH 300 LOG
SET HPDFDOC ENCODING TO "WinAnsiEncoding"
START HPDFDOC
    START HPDFPAGE
	    
	@10,10 HPDFPRINT "Rotate Demo"
        
        HPDF_RotateText( 50, 80, "ABCxyz123", Nil, Nil, 90 ) 
	HPDF_RotateText( 50, 80, "ABCxyz123", Nil, Nil, 180)
        HPDF_RotateText( 50, 80, "ABCxyz123", Nil, Nil, 270)
	HPDF_RotateText( 50, 80, "ABCxyz123", Nil, Nil, 0 )
	
	FOR i=100 TO 300 STEP 10
		@i,10 HPDFPRINt "Happy HMG"
	NEXT i

	FOR i=0 To 345 STEP 15
		HPDF_RotateText( 150, 150, "Happy HMG", Nil, 10, i )	
	NEXT i	


    END HPDFPAGE
        

END HPDFDOC

Execute File 'sample.pdf'
Return Nil
*******************************
PROCEDURE HPDF_RotateText( nRow, nCol, cTxt, cFont, nFontSize, nAngle )
* Rotating text

   Local nRad, nTextWidth 
   
   Local hPdf        := _HMG_SYSDATA[ 150 ][ 1 ]
   Local hPage       := _HMG_SYSDATA[ 150 ][ 7 ]

   Local nWidth      := _HMG_SYSDATA[ 150 ][ 4 ]
   Local nHeight     := _HMG_SYSDATA[ 150 ][ 5 ]
   Local nxPos       := _HMG_HPDF_MM2Pixel( nCol )
   Local nyPos       := nHeight - _HMG_HPDF_MM2Pixel( nRow )

   DEFAULT cFont       := "Helvetica"
   DEFAULT nFontSize    := 12   
   DEFAULT cTXt        := ""
   DEFAULT nAngle      := 0


   nTextWidth := HPDF_Page_TextWidth( hPage, cTxt )

   nRad := nAngle / 180 * 3.141592 	//radian value

   HPDF_Page_SetFontAndSize( hPage, HPDF_GetFont( hPdf, cFont, NIL ), nFontSize )
   HPDF_Page_BeginText( hPage )
   HPDF_Page_SetTextMatrix ( hPage, cos ( nRad ), sin ( nRad ), -sin ( nRad ), cos ( nRad ), nxPos , nyPos - nFontSize)
   HPDF_Page_ShowText( hPage, cTxt )
   HPDF_Page_EndText( hPage )

RETURN

pdf.JPG
EDK thanks for the function you created to rotate the text in pdf
now and the graph in pdf the text is ok
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

EduardoLuis
Posts: 516
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Been thanked: 28 times

Post by EduardoLuis » Fri Sep 08, 2017 4:35 pm

HI EDK

Great job.- This expands HMGPDFPRINT possibilities.-
Tranks for your contribution and for share with us.-
With regards
Eduardo

Post Reply