PageSize.vb
'' 完毕:
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Common
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text

'' 演示如何在 GcDocs.Pdf 中更改页面大小和方向。
Public Class PageSize
    Sub CreatePDF(ByVal stream As Stream)
        Dim in2mm = 72.0F / 25.4F
        Dim colorOrig = Color.Red
        Dim colorNew = Color.Blue
        Dim doc = New GcPdfDocument()
        '' 默认页面尺寸为 Letter (8 1/2" x 11"),纵向:
        Dim page = doc.NewPage()
        Dim sOrigPageInfo = $"Original page size: {page.Size} pts ({page.Size.Width / 72.0F}"" * {page.Size.Height / 72.0F}""),{vbCrLf}" +
            $"paper kind: {page.PaperKind}, landscape: {page.Landscape}."
        '' 保存原始页面边界:
        Dim rOrig = page.Bounds
        '' 更改页面参数:
        page.Landscape = True
        page.PaperKind = PaperKind.A4
        Dim sNewPageInfo = $"New page size: {page.Size} pts ({page.Size.Width / 72.0F}"" * {page.Size.Height / 72.0F}""),{vbCrLf}" +
            $"paper kind: {page.PaperKind}, landscape: {page.Landscape}."
        '' 新页面边界:
        Dim rNew = page.Bounds
        '' 绘制原始页面边界和新页面边界:
        page.Graphics.DrawRectangle(rOrig, colorOrig, 6)
        page.Graphics.DrawRectangle(rNew, colorNew, 6)
        '' 绘制原始和新的页面信息:
        Dim tf = New TextFormat() With {
            .Font = StandardFonts.Times,
            .FontSize = 14,
            .ForeColor = colorOrig
        }
        page.Graphics.DrawString(sOrigPageInfo, tf, New PointF(72, 72))
        tf.ForeColor = colorNew
        page.Graphics.DrawString(sNewPageInfo, tf, New PointF(72, 72 * 2))
        '' 完毕:
        doc.Save(stream)
    End Sub
End Class