var sTitle as string
sTitle = "Service WorkOrder"
var dWidth as double = Document.Graphics.TextWidth(sTitle)
var TextLength as Integer = (Document.Graphics.Width / 2) - (dWidth / 2)
Document.Graphics.DrawText(sTitle, TextLength, 115)
If you want to center a block of text, you can do it the same way @Gary_Smith told to you, except you need to do the maths with the wrapping value instead of the string width.
For example:
Const kLorem As String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Var d As New PDFDocument
Var g As Graphics = d.Graphics
Var x As Double = (d.PageWidth/2) - 200 // 220 because we are going to wrapt the text at a 400 width.
g.DrawText(kLorem,x,100,400)
Var f As FolderItem = SpecialFolder.Desktop.Child("CenteredText.pdf")
d.Save(f)
f.Open