原文来自:http://www.evget.com/zh-CN/Info/catalog/17325.html
Essential Studio Reporting Edition中的Essential PDF是一个能从您的数据中产生Adobe PDF文件 的.NET库。它具有一个成熟的对象模型,允许用任何.NET语言来轻松地创建PDF文件。它不依赖于任何外部条件。在Pdf 3D Annotation类的支持下,Essential PDF支持嵌入三维对象集合(如CAD软件的对象)在PDF文件中。
下面的代码示例演示了如何嵌入一个U3D文件。
[C#]
// Pdf 3D Annotation
Pdf3DAnnotation annot = new Pdf3DAnnotation(new RectangleF(10, 70, 150, 150), @"..\..\Data\AQuick Example.u3d");
// Create font, font style and brush.
Font f = new Font("Calibri", 11, FontStyle.Regular);
PdfFont font = new PdfTrueTypeFont(f, false);
PdfBrush brush = new PdfSolidBrush(Color.DarkBlue);
PdfBrush bgbrush = new PdfSolidBrush(Color.WhiteSmoke);
PdfColor color = new PdfColor(Color.Thistle);
page.Graphics.DrawRectangle(bgbrush, new RectangleF(10, 270, 150, 150));
// Pdf 3D Appearance
annot.Appearance = new PdfAppearance(annot);
annot.Appearance.Normal.Graphics.DrawString("Click to activate", font, brush, new PointF(40, 40));
annot.Appearance.Normal.Draw(page, new PointF(annot.Location.X, annot.Location.Y));
Pdf3DProjection projection = new Pdf3DProjection();
projection.ProjectionType = Pdf3DProjectionType.Perspective;
projection.FieldOfView = 10;
projection.ClipStyle = Pdf3DProjectionClipStyle.ExplicitNearFar;
projection.NearClipDistance = 10;
Pdf3DActivation activation = new Pdf3DActivation();
activation.ActivationMode = Pdf3DActivationMode.ExplicitActivation;
activation.ShowToolbar = false;
annot.Activation = activation;
Pdf3DBackground background = new Pdf3DBackground();
background.Color = color;
Pdf3DRendermode rendermode = new Pdf3DRendermode();
rendermode.Style = Pdf3DRenderStyle.Solid;
Pdf3DLighting lighting = new Pdf3DLighting();
lighting.Style = Pdf3DLightingStyle.Headlamp;
// Create the default view.
Pdf3DProjection projection1 = new Pdf3DProjection(Pdf3DProjectionType.Perspective);
projection1.FieldOfView = 50;
projection1.ClipStyle = Pdf3DProjectionClipStyle.ExplicitNearFar;
projection1.NearClipDistance = 10;
Pdf3DView defaultView = CreateView("Default View", new float[] { -0.382684f, 0.92388f, -0.0000000766026f, 0.18024f, 0.0746579f, 0.980785f, 0.906127f, 0.37533f, -0.19509f, -122.669f, -112.432f, 45.6829f }, 131.695f, background, projection, rendermode, lighting);
annot.Views.Add(defaultView);
// Add the pdf Annotation.
page.Annotations.Add(annot);
[VB.NET]
' Pdf 3D Annotation
Dim annot As Syncfusion.Pdf.Interactive.Pdf3DAnnotation = New Syncfusion.Pdf.Interactive.Pdf3DAnnotation(New RectangleF(10, 70, 150, 150), "..\..\Data\AQuick Example.u3d")
' Create font, font style and brush.
Dim f As Font = New Font("Calibri", 11, FontStyle.Regular)
Dim font As Syncfusion.Pdf.Graphics.PdfFont = New Syncfusion.Pdf.Graphics.PdfTrueTypeFont(f, False)
Dim brush As Syncfusion.Pdf.Graphics.PdfBrush = New Syncfusion.Pdf.Graphics.PdfSolidBrush(color.DarkBlue)
Dim bgbrush As Syncfusion.Pdf.Graphics.PdfBrush = New Syncfusion.Pdf.Graphics.PdfSolidBrush(color.WhiteSmoke)
Dim color As Syncfusion.Pdf.Graphics.PdfColor = New Syncfusion.Pdf.Graphics.PdfColor(color.Thistle)
page.Graphics.DrawRectangle(bgbrush, New RectangleF(10, 270, 150, 150))
' Pdf 3D Appearance
annot.Appearance = New PdfAppearance(annot)
annot.Appearance.Normal.Graphics.DrawString("Click to activate", font, brush, New PointF(40, 40))
annot.Appearance.Normal.Draw(page, New PointF(annot.Location.X, annot.Location.Y))
Dim projection As Syncfusion.Pdf.Interactive.Pdf3DProjection = New Syncfusion.Pdf.Interactive.Pdf3DProjection()
projection.ProjectionType = Pdf3DProjectionType.Perspective
projection.FieldOfView = 10
projection.ClipStyle = Pdf3DProjectionClipStyle.ExplicitNearFar
projection.NearClipDistance = 10
Dim activation As Syncfusion.Pdf.Interactive.Pdf3DActivation = New Syncfusion.Pdf.Interactive.Pdf3DActivation()
activation.ActivationMode = Pdf3DActivationMode.ExplicitActivation
activation.ShowToolbar = False
annot.Activation = activation
Dim background As Syncfusion.Pdf.Interactive.Pdf3DBackground = New Syncfusion.Pdf.Interactive.Pdf3DBackground()
background.Color = color
Dim rendermode As Syncfusion.Pdf.Interactive.Pdf3DRendermode = New Syncfusion.Pdf.Interactive.Pdf3DRendermode()
rendermode.Style = Pdf3DRenderStyle.Solid
Dim lighting As Syncfusion.Pdf.Interactive.Pdf3DLighting = New Syncfusion.Pdf.Interactive.Pdf3DLighting()
lighting.Style = Pdf3DLightingStyle.Headlamp
' Create the default view.
Dim projection1 As Syncfusion.Pdf.Interactive.Pdf3DProjection = New Syncfusion.Pdf.Interactive.Pdf3DProjection(Pdf3DProjectionType.Perspective)
projection1.FieldOfView = 50
projection1.ClipStyle = Pdf3DProjectionClipStyle.ExplicitNearFar
projection1.NearClipDistance = 10
Dim defaultView As Syncfusion.Pdf.Interactive.Pdf3DView = CreateView("Default View", New Single() {-0.382684F, 0.92388F, -0.0000000766026F, 0.18024F, 0.0746579F, 0.980785F, 0.906127F, 0.37533F, -0.19509F, -122.669F, -112.432F, 45.6829F}, 131.695F, background, projection, rendermode, lighting)
annot.Views.Add(defaultView)
' Add the pdf Annotation.
page.Annotations.Add(annot)