Hi
While generating PDF, the command
HPDFURLLINK creates a text link that has border around it. I use this syntax:
@200, 20 HPDFURLLINK xvariable to "URL link" color { 255, 20, 147 } FONT "COURIER-BOLD" SIZE 8
This creates a border around the text. I am not sure how to create a borderless link. Any suggestions ?
Thank you all.
Regarding HPDFURLLINK command
Moderator: Rathinagiri
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Regarding HPDFURLLINK command
I think it is the feature of LibHaru PDF library.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Regarding HPDFURLLINK command
Thank you Rathi ji for the reply. I took this command and syntax from the HMG_HPDF_doc.PDF which I think has been created by you and this PDF file is given in HMG3.4.4\SAMPLES\HPDF\HMG_HPDF.
I want to create a borderless text link but this command doesn't say anything about it. Perhaps you can help.
Regards
Paramvir
Re: Regarding HPDFURLLINK command
Replace the _HMG_HPDF_SetURLLink function in the h_HMG_HPDF.Prg file with the one below, then rebuild the HMG.
Code: Select all
Function _HMG_HPDF_SetURLLink( nRow, nCol, cText, cLink, cFontName, nFontSize, nRColor, nGColor, nBColor, cAlign, lColor, lFont, lSize, lBold, lItalic )
Local nWidth := _HMG_SYSDATA[ 150 ][ 4 ]
Local nHeight := _HMG_SYSDATA[ 150 ][ 5 ]
Local nTextWidth := 0
Local nxPos := _HMG_HPDF_MM2Pixel( nCol )
Local nyPos := nHeight - _HMG_HPDF_MM2Pixel( nRow )
Local oFont := Nil
Local cFont := ''
Local aRect := { }
Local aCurXY := {}
Local oAnnot := Nil
Local hUrlLink := Nil
default cFontName := ''
default nFontSize := 12
default nRColor := 0
default nGColor := 0
default nBColor := 0
default lColor := .f.
default lFont := .f.
default lSize := .f.
default lBold := .f.
default lItalic := .f.
default cAlign := ''
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
// set color
If lColor
HPDF_Page_SetRGBFill( _HMG_SYSDATA[ 150 ][ 7 ], nRColor/255, nGColor/255, nBColor/255 )
else
HPDF_Page_SetRGBFill( _HMG_SYSDATA[ 150 ][ 7 ], 0.0, 0.0, 0.0 )
endIf
// set font
//If HMG_LEN( alltrim( cFontName ) ) == 0
// cFontName := _HMG_HPDF_SetFont( cFontName )
// oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, _HMG_SYSDATA[ 150 ][ 10 ] )
//else
// cFontName := alltrim( cFontName )
cFontName := AllTrim(_HMG_HPDF_SetFont( cFontName, lBold, lItalic ))
if HMG_UPPER (cFileExt (cFontName)) == '.TTF' // load ttf font
cFont := HPDF_LOADTTFONTFROMFILE( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, .t. )
If HMG_LEN( alltrim( cFont ) ) == 0
_HMG_HPDF_Error( 6 , cFontName )
Return Nil
endif
oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFont, _HMG_SYSDATA[ 150 ][ 10 ] )
else
If HMG_UPPER( alltrim( cFontName ) ) == "SYMBOL" .or. HMG_UPPER( alltrim( cFontName ) ) == "ZAPFDINGBATS"
oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, Nil )
else
oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, _HMG_SYSDATA[ 150 ][ 10 ] )
endIf
endif
//endIf
If oFont == Nil
_HMG_HPDF_Error( 6 , cFontName )
Return Nil
else
HPDF_Page_SetFontAndSize( _HMG_SYSDATA[ 150 ][ 7 ], oFont, nFontSize )
nTextWidth := HPDF_Page_TextWidth( _HMG_SYSDATA[ 150 ][ 7 ], cText )
do case
case HMG_UPPER( alltrim( cAlign ) ) == 'CENTER'
nxPos := nxPos - ( nTextWidth / 2 )
case HMG_UPPER( alltrim( cAlign ) ) == 'RIGHT'
nxPos := nxPos - ( nTextWidth )
endcase
HPDF_Page_BeginText( _HMG_SYSDATA[ 150 ][ 7 ] )
HPDF_PAGE_TEXTOUT( _HMG_SYSDATA[ 150 ][ 7 ], nxPos, nyPos, cText )
aRect := { nxPos - 4, nyPos + nFontsize + 4, nxPos + nTextWidth + 4, nyPos - 4 }
hUrlLink := HPDF_Page_CreateURILinkAnnot( _HMG_SYSDATA[ 150 ][ 7 ], aRect, cLink )
IF hUrlLink != Nil
HPDF_Annotation_SetBorderStyle ( hUrlLink, HPDF_BS_UNDERLINED )
ENDIF
HPDF_Page_EndText( _HMG_SYSDATA[ 150 ][ 7 ] )
endif
Return Nil
Re: Regarding HPDFURLLINK command
Thank you Edk for the generous help and sharing your code. I would like to try it although it seems a bit daunting for a person like me with limited programming knowledge. Thank you once again.edk wrote: ↑Fri Jun 26, 2020 11:15 am Replace the _HMG_HPDF_SetURLLink function in the h_HMG_HPDF.Prg file with the one below, then rebuild the HMG.
Code: Select all
Function _HMG_HPDF_SetURLLink( nRow, nCol, cText, cLink, cFontName, nFontSize, nRColor, nGColor, nBColor, cAlign, lColor, lFont, lSize, lBold, lItalic ) Local nWidth := _HMG_SYSDATA[ 150 ][ 4 ] Local nHeight := _HMG_SYSDATA[ 150 ][ 5 ] Local nTextWidth := 0 Local nxPos := _HMG_HPDF_MM2Pixel( nCol ) Local nyPos := nHeight - _HMG_HPDF_MM2Pixel( nRow ) Local oFont := Nil Local cFont := '' Local aRect := { } Local aCurXY := {} Local oAnnot := Nil Local hUrlLink := Nil default cFontName := '' default nFontSize := 12 default nRColor := 0 default nGColor := 0 default nBColor := 0 default lColor := .f. default lFont := .f. default lSize := .f. default lBold := .f. default lItalic := .f. default cAlign := '' 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 // set color If lColor HPDF_Page_SetRGBFill( _HMG_SYSDATA[ 150 ][ 7 ], nRColor/255, nGColor/255, nBColor/255 ) else HPDF_Page_SetRGBFill( _HMG_SYSDATA[ 150 ][ 7 ], 0.0, 0.0, 0.0 ) endIf // set font //If HMG_LEN( alltrim( cFontName ) ) == 0 // cFontName := _HMG_HPDF_SetFont( cFontName ) // oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, _HMG_SYSDATA[ 150 ][ 10 ] ) //else // cFontName := alltrim( cFontName ) cFontName := AllTrim(_HMG_HPDF_SetFont( cFontName, lBold, lItalic )) if HMG_UPPER (cFileExt (cFontName)) == '.TTF' // load ttf font cFont := HPDF_LOADTTFONTFROMFILE( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, .t. ) If HMG_LEN( alltrim( cFont ) ) == 0 _HMG_HPDF_Error( 6 , cFontName ) Return Nil endif oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFont, _HMG_SYSDATA[ 150 ][ 10 ] ) else If HMG_UPPER( alltrim( cFontName ) ) == "SYMBOL" .or. HMG_UPPER( alltrim( cFontName ) ) == "ZAPFDINGBATS" oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, Nil ) else oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, _HMG_SYSDATA[ 150 ][ 10 ] ) endIf endif //endIf If oFont == Nil _HMG_HPDF_Error( 6 , cFontName ) Return Nil else HPDF_Page_SetFontAndSize( _HMG_SYSDATA[ 150 ][ 7 ], oFont, nFontSize ) nTextWidth := HPDF_Page_TextWidth( _HMG_SYSDATA[ 150 ][ 7 ], cText ) do case case HMG_UPPER( alltrim( cAlign ) ) == 'CENTER' nxPos := nxPos - ( nTextWidth / 2 ) case HMG_UPPER( alltrim( cAlign ) ) == 'RIGHT' nxPos := nxPos - ( nTextWidth ) endcase HPDF_Page_BeginText( _HMG_SYSDATA[ 150 ][ 7 ] ) HPDF_PAGE_TEXTOUT( _HMG_SYSDATA[ 150 ][ 7 ], nxPos, nyPos, cText ) aRect := { nxPos - 4, nyPos + nFontsize + 4, nxPos + nTextWidth + 4, nyPos - 4 } hUrlLink := HPDF_Page_CreateURILinkAnnot( _HMG_SYSDATA[ 150 ][ 7 ], aRect, cLink ) IF hUrlLink != Nil HPDF_Annotation_SetBorderStyle ( hUrlLink, HPDF_BS_UNDERLINED ) ENDIF HPDF_Page_EndText( _HMG_SYSDATA[ 150 ][ 7 ] ) endif Return Nil
Regards
Paramvir
Re: Regarding HPDFURLLINK command
GREAT! Thank you EDK. I just did what you showed in the video and yes! now the link is borderless. Thank you for all the pains you have taken.
Regards
Paramvir
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Regarding HPDFURLLINK command
Nice Edk. Have you tried to update to the latest libharupdf? Because it has the feature of Unicode/UTF-8edk wrote: ↑Fri Jun 26, 2020 11:15 am Replace the _HMG_HPDF_SetURLLink function in the h_HMG_HPDF.Prg file with the one below, then rebuild the HMG.
Code: Select all
Function _HMG_HPDF_SetURLLink( nRow, nCol, cText, cLink, cFontName, nFontSize, nRColor, nGColor, nBColor, cAlign, lColor, lFont, lSize, lBold, lItalic ) Local nWidth := _HMG_SYSDATA[ 150 ][ 4 ] Local nHeight := _HMG_SYSDATA[ 150 ][ 5 ] Local nTextWidth := 0 Local nxPos := _HMG_HPDF_MM2Pixel( nCol ) Local nyPos := nHeight - _HMG_HPDF_MM2Pixel( nRow ) Local oFont := Nil Local cFont := '' Local aRect := { } Local aCurXY := {} Local oAnnot := Nil Local hUrlLink := Nil default cFontName := '' default nFontSize := 12 default nRColor := 0 default nGColor := 0 default nBColor := 0 default lColor := .f. default lFont := .f. default lSize := .f. default lBold := .f. default lItalic := .f. default cAlign := '' 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 // set color If lColor HPDF_Page_SetRGBFill( _HMG_SYSDATA[ 150 ][ 7 ], nRColor/255, nGColor/255, nBColor/255 ) else HPDF_Page_SetRGBFill( _HMG_SYSDATA[ 150 ][ 7 ], 0.0, 0.0, 0.0 ) endIf // set font //If HMG_LEN( alltrim( cFontName ) ) == 0 // cFontName := _HMG_HPDF_SetFont( cFontName ) // oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, _HMG_SYSDATA[ 150 ][ 10 ] ) //else // cFontName := alltrim( cFontName ) cFontName := AllTrim(_HMG_HPDF_SetFont( cFontName, lBold, lItalic )) if HMG_UPPER (cFileExt (cFontName)) == '.TTF' // load ttf font cFont := HPDF_LOADTTFONTFROMFILE( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, .t. ) If HMG_LEN( alltrim( cFont ) ) == 0 _HMG_HPDF_Error( 6 , cFontName ) Return Nil endif oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFont, _HMG_SYSDATA[ 150 ][ 10 ] ) else If HMG_UPPER( alltrim( cFontName ) ) == "SYMBOL" .or. HMG_UPPER( alltrim( cFontName ) ) == "ZAPFDINGBATS" oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, Nil ) else oFont := HPDF_GetFont( _HMG_SYSDATA[ 150 ][ 1 ], cFontName, _HMG_SYSDATA[ 150 ][ 10 ] ) endIf endif //endIf If oFont == Nil _HMG_HPDF_Error( 6 , cFontName ) Return Nil else HPDF_Page_SetFontAndSize( _HMG_SYSDATA[ 150 ][ 7 ], oFont, nFontSize ) nTextWidth := HPDF_Page_TextWidth( _HMG_SYSDATA[ 150 ][ 7 ], cText ) do case case HMG_UPPER( alltrim( cAlign ) ) == 'CENTER' nxPos := nxPos - ( nTextWidth / 2 ) case HMG_UPPER( alltrim( cAlign ) ) == 'RIGHT' nxPos := nxPos - ( nTextWidth ) endcase HPDF_Page_BeginText( _HMG_SYSDATA[ 150 ][ 7 ] ) HPDF_PAGE_TEXTOUT( _HMG_SYSDATA[ 150 ][ 7 ], nxPos, nyPos, cText ) aRect := { nxPos - 4, nyPos + nFontsize + 4, nxPos + nTextWidth + 4, nyPos - 4 } hUrlLink := HPDF_Page_CreateURILinkAnnot( _HMG_SYSDATA[ 150 ][ 7 ], aRect, cLink ) IF hUrlLink != Nil HPDF_Annotation_SetBorderStyle ( hUrlLink, HPDF_BS_UNDERLINED ) ENDIF HPDF_Page_EndText( _HMG_SYSDATA[ 150 ][ 7 ] ) endif Return Nil
It is a long pending one to have a native support for unicode pdf.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.