On this page you will learn from code samples for programming in VBScript.Writing of the code to draw rectangles in pdf with pdf sdk in VBScript can be executed by programmers of any level using ByteScout Premium Suite. ByteScout Premium Suite is the set that includes 12 SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording and you can use it to draw rectangles in pdf with pdf sdk with VBScript.
These VBScript code samples for VBScript guide developers to speed up coding of the application when using ByteScout Premium Suite. Follow the instructions from scratch to work and copy the VBScript code. If you want to use these VBScript sample examples in one or many applications then they can be used easily.
You can download free trial version of ByteScout Premium Suite from our website to see and try many others source code samples for VBScript.
' This example demonstrates how to draw rectangles. ' Create Bytescout.PDF.Document object Set pdfDocument = CreateObject("Bytescout.PDF.Document") pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" Set comHelpers = pdfDocument.ComHelpers ' Add page Set page1 = comHelpers.CreatePage(comHelpers.PAPERFORMAT_A4) pdfDocument.Pages.Add(page1) Set canvas = page1.Canvas ' Prepare pens and brushes Set borderPen = comHelpers.CreateSolidPen(comHelpers.CreateColorGray(128), 2.0) Set brush1 = comHelpers.CreateSolidBrush(comHelpers.CreateColorRGB(255, 0, 0)) Set brush2 = comHelpers.CreateSolidBrush(comHelpers.CreateColorRGB(0, 255, 255)) ' Draw transparent rectangle with border only canvas.DrawRectangle (borderPen), 100, 100, 100, 50 ' Draw rounded rectangle with broder and filling canvas.DrawRoundedRectangle_3 (borderPen), (brush1), 250, 100, 100, 50, 10 ' Draw rectangle as polygon Set pointsArray = comHelpers.CreatePointsArray(Array(Array(400, 100), Array(500, 100), Array(500, 150), Array(400, 150))) canvas.DrawPolygon_3 (borderPen), (brush2), (pointsArray) ' Save document to file pdfDocument.Save("result.pdf") ' Open document in default PDF viewer app Set shell = CreateObject("WScript.Shell") shell.Run "result.pdf", 1, false