Get width of a text in
points.
Use this function to
determine the width of a text in order to create frames around it, or a
weblink, etc.
Hint: See
PdfSetPageFormat
for more information on dimensions of various page formats
Parameters:
Name |
Type |
Description |
aText |
String |
Any
one line string whose width needs to be determined. Example: Go to homepage |
Returns:
Type |
Value |
Description |
Double |
0.0 or
higher |
Returns
the width of the character string parameter, in points. |
Available in:
WindowMain |
WindowLink |
YES |
YES |
Used in:
XojoScript
Name |
GUID |
Create
Seminar Invoice As PDF |
2C3F7F29-A29A-4338-ACF5-51894B709DA5 |
Create
Seminar Invoice With Slip As PDF |
739DA58E-17EE-41CE-BB54-E7362CFE17D4 |
Hint: You can
find references to XojoScripts which make use of this function by sending the
following SQL statement to the database:
Select id,GUID, ScriptName,ScriptCode from
im_scripts where ScriptCode Like '%PdfGetTextWidth%'
Example XojoScript:
If
PdfStart("testfile.pdf")
> 0 Then
PdfSetPageCoordsTopDown
Dim x,y As Double = 30.0
// Set output font and
color
PdfSetFont("Arial","Regular",10.0)
// Localized texts
Dim txt As String = "Go to homepage"
// Define Link
Dim url As String = "https://www.seminar.pro"
// Textcolor of weblink
Dim colorstring As String = "&c6B000100"
Call PdfSetStrokeColor(colorstring)
Call PdfSetFillColor(colorstring)
Call PdfWriteText(x,y,txt)
// Framecolor of weblink
colorstring = "&cFFCC6600"
Call PdfSetStrokeColor(colorstring)
Call PdfSetFillColor(colorstring)
// Get width of text to
calculate and define width of link
Call PdfWebLink(x-2,y,PdfGetTextWidth(txt)+ 4,14.0,url)
// Finalize PDF
Call PdfCloseFile
// Show it to the user
Call Pdflaunch
End
If