Annotation3D.vb
C# VB
'''' 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.PdfImports GrapeCity.Documents.Pdf.Annotations
'' This demo shows how to embed an interactive 3D model in a PDF using Annotation3D.Public Class Annotation3D Public Function CreatePDF(ByVal stream As Stream) As Integer Dim doc = New GcPdfDocument() Dim page = doc.NewPage()
Dim rc = Util.AddNote( "The rectangle below is a Model3DAnnotation containing a 3D model. " & "It activates automatically when this page becomes visible, but can only be viewed interactively " & "in a PDF reader with native 3D support, such as Adobe Acrobat/Reader.", page)
' Load the 3D model (U3D format): Dim modelPath = Path.Combine("Resources", "3DModels", "plane64x64_base.u3d") Using modelStream = File.OpenRead(modelPath) ' Add a 3D annotation showing the model, activated when the page becomes visible: Dim m3d = New Model3DAnnotation With { .Stream = New Model3DStream(modelStream, Model3DStreamFormat.U3D), .ActivationCondition = Model3DActivationCondition.PageBecomesVisible, .DeactivationCondition = Model3DDeactivationCondition.PageBecomesInvisible, .Page = page, .Rect = New RectangleF(rc.X, rc.Bottom + 18, 72 * 5, 72 * 4) }
doc.Save(stream) End Using
Return doc.Pages.Count End FunctionEnd Class