'' 完毕:
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text
'' 此示例列出了每个系统字体中可用的 Unicode 范围。
public class UnicodeRanges
Function CreatePDF(ByVal stream As Stream) As Integer
'' 设置:
Dim doc = New GcPdfDocument()
Dim tl = New TextLayout(72) With {
.MaxWidth = doc.PageSize.Width,
.MaxHeight = doc.PageSize.Height,
.MarginAll = 72
}
tl.DefaultFormat.FontSize = 7
Dim tfH = New TextFormat() With {.Font = StandardFonts.TimesBold, .FontSize = 12}
Dim tfP = New TextFormat() With {.Font = StandardFonts.Times, .FontSize = 11}
'' 循环遍历所有系统字体,
'' 列出每种字体提供的 Unicode 范围:
For Each font In FontCollection.SystemFonts
tl.AppendLine($"{font.FontFileName} [{font.FullFontName}] [{font.FontFamilyName}]", tfH)
Dim shot = font.CreateFontTables(TableTag.OS2)
tl.AppendLine(shot.GetUnicodeRanges(), tfP)
tl.AppendLine()
Next
'' 拆分并渲染 TextLayout,如 PaginatedText 示例所示:
Dim tso = New TextSplitOptions(tl) With {
.MinLinesInFirstParagraph = 2,
.MinLinesInLastParagraph = 2
}
tl.PerformLayout(True)
While True
Dim rest As TextLayout = Nothing
Dim SplitResult = tl.Split(tso, rest)
doc.Pages.Add().Graphics.DrawTextLayout(tl, PointF.Empty)
If SplitResult <> SplitResult.Split Then
Exit While
End If
tl = rest
End While
''
'' 完毕:
doc.Save(stream)
Return doc.Pages.Count
End Function
End Class