ByteScout PDF SDK - VBScript and VB6 - Use Layers in PDF - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout PDF SDK – VBScript and VB6 – Use Layers in PDF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – VBScript and VB6 – Use Layers in PDF

How to use layers in PDF in VBScript and VB6 with ByteScout PDF SDK

This code in VBScript and VB6 shows how to use layers in PDF with this how to tutorial

We made thousands of pre-made source code pieces for easy implementation in your own programming projects. ByteScout PDF SDK is the pdf library that can create, update and modify PDF files. Supports text with fonts and style selections, layers, form fields, drawing lines and objects, automatic tables, images. Can be used to create and fill pdf forms. It can be used to use layers in PDF using VBScript and VB6.

Fast application programming interfaces of ByteScout PDF SDK for VBScript and VB6 plus the instruction and the code below will help you quickly learn how to use layers in PDF. Just copy and paste the code into your VBScript and VB6 application’s code and follow the instruction. Implementing VBScript and VB6 application typically includes multiple stages of the software development so even if the functionality works please test it with your data and the production environment.

You can download free trial version of ByteScout PDF SDK from our website to see and try many others source code samples for VBScript and VB6.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Layers.vbs
      
' This example demonstrates how to add layers with optional content. ' 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 ' Add main layer Set allContents = comHelpers.CreateLayer("Main Layer") canvas.BeginMarkedContent(allContents) ' Add sub-layer Set layer1 = comHelpers.CreateLayer("Square") canvas.BeginMarkedContent(layer1) canvas.DrawRectangle_2 comHelpers.CreateSolidBrush(comHelpers.CreateColorRGB(0, 255, 0)), 20, 20, 100, 100 canvas.EndMarkedContent() ' Add second sub-layer Set layer2 = comHelpers.CreateLayer("Circle") canvas.BeginMarkedContent(layer2) canvas.DrawCircle_2 comHelpers.CreateSolidBrush(comHelpers.CreateColorRGB(255, 0, 0)), 70, 180, 50 canvas.EndMarkedContent() ' Add third sub-layer Set layer3 = comHelpers.CreateLayer("Triangle") canvas.BeginMarkedContent(layer3) Set pointsArray = comHelpers.CreatePointsArray(Array(Array(20, 340), Array(70, 240), Array(120, 340))) canvas.DrawPolygon_2 comHelpers.CreateSolidBrush(comHelpers.CreateColorRGB(0, 0, 255)), (pointsArray) canvas.EndMarkedContent() canvas.EndMarkedContent() pdfDocument.OptionalContents.Layers.Add(layer1) pdfDocument.OptionalContents.Layers.Add(layer2) pdfDocument.OptionalContents.Layers.Add(layer3) pdfDocument.OptionalContents.Layers.Add(allContents) ' Configure layers ' Group sub-layers Set group = comHelpers.CreateOptionalContentGroup() group.Add(comHelpers.CreateOptionalContentGroupLayer((layer1))) group.Add(comHelpers.CreateOptionalContentGroupLayer((layer2))) group.Add(comHelpers.CreateOptionalContentGroupLayer((layer3))) ' Order sub-layers pdfDocument.OptionalContents.Configuration.Order.Add(comHelpers.CreateOptionalContentGroupLayer((allContents))) pdfDocument.OptionalContents.Configuration.Order.Add(group) ' Make the third layer invisible by default (for example) pdfDocument.OptionalContents.Configuration.OFF.Add(layer3) ' Force the PDF viewer to show the layers panel initially pdfDocument.PageMode = comHelpers.PAGEMODE_OPTIONALCONTENT ' 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

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next