'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.IOImports System.DrawingImports GrapeCity.Documents.CommonImports GrapeCity.Documents.PdfImports GrapeCity.Documents.Text
'' Shows how to change page size and orientation in DsPdf.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() '' The default page size is Letter (8 1/2" x 11") with portrait orientation: 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}." '' Save original page bounds: Dim rOrig = page.Bounds '' Change page parameters: page.Landscape = True page.PaperKind = PaperKind.A4 Dim sNewPageInfo = $"New page size: {page.Size} pts ({page.Size.Width / in2mm}mm * {page.Size.Height / in2mm}mm),{vbCrLf}" + $"paper kind: {page.PaperKind}, landscape: {page.Landscape}." '' New page bounds: Dim rNew = page.Bounds '' Draw original and new page bounds: page.Graphics.DrawRectangle(rOrig, colorOrig, 6) page.Graphics.DrawRectangle(rNew, colorNew, 6) '' Draw original and new page infos: 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)) '' Done: doc.Save(stream) End SubEnd Class