Text Alignment
(Left, Center, Right, Full Justification)

When you write a string, you may want to align it to the left, center, right of a particular point, or to have that string justified, like you can see in books.

To do this, you just need to set the property ParagraphAlignment to one of this valid values:

  1. "Left"
  2. "Center"
  3. "Right"
  4. "Full"

This options are not case sensitive. You can also write directly the starting letter (L, C, R or F).

Please note as in the example and screenshot below that the alignment for CENTER and RIGHT options is based on the Y Position:

Private Sub Command3_Click()
  Dim x As New PDFDocument
  Dim txt As String
  
  txt = "Hello World"
  
  x.NewPDF "ciao"
  x.FontName = "Helvetica"
  x.FontHeight = 18
  x.ParagraphLeading = 3.5
  x.ParagraphWidth = 60
  x.DrawLine 1, 105, 105, 0, 297 ' a line in the middle of the paper
  ' as a guide...  

  x.ParagraphAlignment = "left"
  x.TextOut txt & " Left", 105, 20
  
  x.ParagraphAlignment = "center"
  x.TextOut txt & " Center", 105, 40
  
  x.ParagraphAlignment = "right"
  x.TextOut txt & " Center", 105, 60
  
  x.SavePDF "c:\prova.pdf"
  Form1.Caption = x.OCXVersion
End Sub
The resulting file shows that the text is aligned in reference to the starting point:

If you choose the "FULL" options you wrap the text between 2 lines, the Y position and the (Y Position + ParagraphWidth); in the following example the same text was aligned to the left (above) and FULL JUSTIFIED (below):