ParagraphFormatting.vb
''
'' This code is part of Document Solutions for PDF demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Drawing

'' This sample demonstrates the most basic paragraph formatting options:
'' - first line indent
'' - line spacing.
Public Class ParagraphFormatting
    Function CreatePDF(ByVal stream As Stream) As Integer

        Dim makePara As Func(Of String) =
            Function()
                Return Util.LoremIpsum(1, 5, 10, 15, 30)
            End Function

        Dim doc = New GcPdfDocument()
        Dim g = doc.NewPage().Graphics
        '' Using Graphics.CreateTextLayout() ensures that TextLayout's resolution
        '' is set to the same value as that of the graphics (which is 72 dpi by default):
        Dim tl = g.CreateTextLayout()
        '' Default font:
        tl.DefaultFormat.Font = StandardFonts.Times
        tl.DefaultFormat.FontSize = 12
        '' Set TextLayout to the whole page:
        tl.MaxWidth = doc.PageSize.Width
        tl.MaxHeight = doc.PageSize.Height
        '' ...and have it manage the page margins (1" all around):
        tl.MarginAll = tl.Resolution
        '' First line offset 1/2":
        tl.FirstLineIndent = 72 / 2
        '' 1.5 line spacing:
        tl.LineSpacingScaleFactor = 1.5F
        ''
        tl.Append(makePara())
        tl.PerformLayout(True)
        '' Render text at (0,0) (margins are added by TextLayout):
        g.DrawTextLayout(tl, PointF.Empty)
        ''
        '' Done:
        doc.Save(stream)
        Return doc.Pages.Count
    End Function
End Class