Universal 3D (U3D) is a compressed file format for 3D computer graphic data. 3D modules in U3D format can be inserted into PDF documents and interactively visualized by Acrobat Reader. This article presents how to embed a pre-created U3D file into a PDF document using Spire.PDF in C#, VB.NET.

Main Steps:

Step 1: Initialize a new object of PdfDocuemnt, and add a blank page to the PDF document.

PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();

Step 2: Draw a rectangle on the page to define the canvas area for the 3D file.

Rectangle rt = new Rectangle(0, 80, 200, 200);

Step 3: Initialize a new object of Pdf3DAnnotation, load the .u3d file as 3D annotation.

Pdf3DAnnotation annotation = new Pdf3DAnnotation(rt, "teapot.u3d");
annotation.Activation = new Pdf3DActivation();
annotation.Activation.ActivationMode = Pdf3DActivationMode.PageOpen;

Step 4: Define a 3D view mode.

Pdf3DView View= new Pdf3DView();
View.Background = new Pdf3DBackground(new PdfRGBColor(Color.Purple
));
View.ViewNodeName = "test";
View.RenderMode = new Pdf3DRendermode(Pdf3DRenderStyle.Solid);
View.InternalName = "test";
View.LightingScheme = new Pdf3DLighting();
View.LightingScheme.Style = Pdf3DLightingStyle.Day;

Step 5: Set the 3D view mode for the annotation.

annotation.Views.Add(View);

Step 6: Add the annotation to PDF.

page.Annotations.Add(annotation);

Step 7: Save the file.

doc.SaveToFile("Create3DPdf.pdf", FileFormat.PDF);

Output:

How to Embed 3D Interactive Graphics into PDF Document in C#, VB.NET

Full Code:

[C#]
using Spire.Pdf;
using Spire.Pdf.Annotations;
using Spire.Pdf.Graphics;
using System.Drawing;

namespace Embed3DInteractiveGraphics
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add();

            Rectangle rt = new Rectangle(0, 80, 200, 200); 
            Pdf3DAnnotation annotation = new Pdf3DAnnotation(rt, "teapot.u3d");
            annotation.Activation = new Pdf3DActivation();
            annotation.Activation.ActivationMode = Pdf3DActivationMode.PageOpen; 
            Pdf3DView View= new Pdf3DView();
            View.Background = new Pdf3DBackground(new PdfRGBColor(Color.Purple));
            View.ViewNodeName = "test";
            View.RenderMode = new Pdf3DRendermode(Pdf3DRenderStyle.Solid);
            View.InternalName = "test";
            View.LightingScheme = new Pdf3DLighting();
            View.LightingScheme.Style = Pdf3DLightingStyle.Day;
            annotation.Views.Add(View);

            page.Annotations.Add(annotation);
            doc.SaveToFile("Create3DPdf.pdf", FileFormat.PDF);
        }
    }
}
[VB.NET]
Imports Spire.Pdf
Imports Spire.Pdf.Annotations
Imports Spire.Pdf.Graphics
Imports System.Drawing

Namespace Embed3DInteractiveGraphics
	Class Program
		Private Shared Sub Main(args As String())
			Dim doc As New PdfDocument()
			Dim page As PdfPageBase = doc.Pages.Add()

			Dim rt As New Rectangle(0, 80, 200, 200)
			Dim annotation As New Pdf3DAnnotation(rt, "teapot.u3d")
			annotation.Activation = New Pdf3DActivation()
			annotation.Activation.ActivationMode = Pdf3DActivationMode.PageOpen
			Dim View As New Pdf3DView()
			View.Background = New Pdf3DBackground(New PdfRGBColor(Color.Purple))
			View.ViewNodeName = "test"
			View.RenderMode = New Pdf3DRendermode(Pdf3DRenderStyle.Solid)
			View.InternalName = "test"
			View.LightingScheme = New Pdf3DLighting()
			View.LightingScheme.Style = Pdf3DLightingStyle.Day
			annotation.Views.Add(View)

			page.AnnotationsWidget.Add(annotation)
			doc.SaveToFile("Create3DPdf.pdf", FileFormat.PDF)
		End Sub
	End Class
End Namespace

As a comprehensive PDF component, Spire.PDF supports to sign a PDF digitally, embed certificate in PDF as well as delete signatures in existing PDF documents. In this article, you'll learn how to remove all digital signatures from a PDF with C#, VB.NET.

Test File:

How to Remove Digital Signature Field from PDF in C#, VB.NET

Code Snippet:

Step 1: Create a new PdfDocument object and load the test file.

PdfDocument pdf = new PdfDocument("test.pdf");

Step 2: Get loaded form from PDF.

PdfFormWidget widgets = pdf.Form as PdfFormWidget;

Step 3: Get the list of filed collection, and judge if each filed is a signature filed. If yes, remove the signature field using PdfFieldCollection.RemoveAt(int index) method.

for (int i = 0; i < widgets.FieldsWidget.List.Count; i++)
{
    PdfFieldWidget widget = widgets.FieldsWidget.List[i] as PdfFieldWidget;
    if (widget is PdfSignatureFieldWidget)
    {
        widgets.FieldsWidget.RemoveAt(i);
    }
}

Step 4: Save and launch the result file.

pdf.SaveToFile("result.pdf");
System.Diagnostics.Process.Start("result.pdf");

Result:

How to Remove Digital Signature Field from PDF in C#, VB.NET

Full Code:

[C#]
using Spire.Pdf;
using Spire.Pdf.Widget;

namespace RemoveDigitalSignature
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument pdf = new PdfDocument("test.pdf");

            PdfFormWidget widgets = pdf.Form as PdfFormWidget;
            for (int i = 0; i < widgets.FieldsWidget.List.Count; i++)
            {
                PdfFieldWidget widget = widgets.FieldsWidget.List[i] as PdfFieldWidget;
                if (widget is PdfSignatureFieldWidget)
                {
                    widgets.FieldsWidget.RemoveAt(i);
                }
            }

            pdf.SaveToFile("result.pdf");
            System.Diagnostics.Process.Start("result.pdf");
        }
    }
}
[VB.NET]
Imports Spire.Pdf
Imports Spire.Pdf.Widget

Namespace RemoveDigitalSignature
	Class Program
		Private Shared Sub Main(args As String())
			Dim pdf As New PdfDocument("test.pdf")
Dim widgets As PdfFormWidget = TryCast(pdf.Form, PdfFormWidget)
For i As Integer = 0 To widgets.FieldsWidget.List.Count - 1
	Dim widget As PdfFieldWidget = TryCast(widgets.FieldsWidget.List(i), PdfFieldWidget)
	If TypeOf widget Is PdfSignatureFieldWidget Then

		widgets.FieldsWidget.RemoveAt(i)
	End If
Next

pdf.SaveToFile("result.pdf")
System.Diagnostics.Process.Start("result.pdf")
		End Sub
	End Class
End Namespace

There are articles in our tutorials that introduce how to add trendline, error bars and data tables to Excel charts in C# using Spire.XLS. It's worthy of mention that Spire.XLS also supports data labels which are widely used to quickly identify a data series in a chart. In label options, we could set whether label contains series name, category name, value, percentages (pie chart) and legend key. This article is going to introduce the method to set and format data labels for Excel charts in C# using Spire.XLS.

Note: before start, please download the latest version of Spire.XLS and add the .dll in the bin folder as the reference of Visual Studio.

Step 1: Create an Excel document and add sample data.

            Workbook workbook = new Workbook();
            workbook.CreateEmptySheets(1);
            Worksheet sheet = workbook.Worksheets[0];
            sheet.Name = "Demo";
            sheet.Range["A1"].Value = "Month";
            sheet.Range["A2"].Value = "Jan";
            sheet.Range["A3"].Value = "Feb";
            sheet.Range["A4"].Value = "Mar";
            sheet.Range["A5"].Value = "Apr";
            sheet.Range["A6"].Value = "May";
            sheet.Range["A7"].Value = "Jun";
            sheet.Range["B1"].Value = "Peter";
            sheet.Range["B2"].NumberValue = 25;
            sheet.Range["B3"].NumberValue = 18;
            sheet.Range["B4"].NumberValue = 8;
            sheet.Range["B5"].NumberValue = 13;
            sheet.Range["B6"].NumberValue = 22;
            sheet.Range["B7"].NumberValue = 28;

Step 2: Create a line markers chart based on the sample data.

            Chart chart = sheet.Charts.Add(ExcelChartType.LineMarkers);
            chart.DataRange = sheet.Range["B1:B7"];
            chart.PlotArea.Visible = false;
            chart.SeriesDataFromRange = false;
            chart.TopRow = 5;
            chart.BottomRow = 26;
            chart.LeftColumn = 2;
            chart.RightColumn =11;
            chart.ChartTitle = "Data Labels Demo";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size = 12;
            Spire.Xls.Charts.ChartSerie cs1 = chart.Series[0];      
            cs1.CategoryLabels = sheet.Range["A2:A7"];

Step 3: Set which parts are displayed in the data labels and the delimiter to separate them.

            cs1.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasLegendKey = false;
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasPercentage = false;
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasSeriesName = true;
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasCategoryName = true;
            cs1.DataPoints.DefaultDataPoint.DataLabels.Delimiter = ". ";

Step 4: Set the font, position and fill effects for data labels in the chart.

            cs1.DataPoints.DefaultDataPoint.DataLabels.Size = 9;
            cs1.DataPoints.DefaultDataPoint.DataLabels.Color = Color.Red;
            cs1.DataPoints.DefaultDataPoint.DataLabels.FontName = "Calibri";
            cs1.DataPoints.DefaultDataPoint.DataLabels.Position = DataLabelPositionType.Center;
            cs1.DataPoints.DefaultDataPoint.DataLabels.FrameFormat.Fill.Texture = GradientTextureType.Papyrus;

Step 5: Save the document as Excel 2010.

            workbook.SaveToFile("S3.xlsx", ExcelVersion.Version2010);
            System.Diagnostics.Process.Start("S3.xlsx");

Effects:

How to set and format data labels for Excel charts in C#

Full Codes:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Xls;
using System.Drawing;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            
            Workbook workbook = new Workbook();
            workbook.CreateEmptySheets(1);
            Worksheet sheet = workbook.Worksheets[0];

            sheet.Name = "Demo";
            sheet.Range["A1"].Value = "Month";
            sheet.Range["A2"].Value = "Jan";
            sheet.Range["A3"].Value = "Feb";
            sheet.Range["A4"].Value = "Mar";
            sheet.Range["A5"].Value = "Apr";
            sheet.Range["A6"].Value = "May";
            sheet.Range["A7"].Value = "Jun";
            sheet.Range["B1"].Value = "Peter";
            sheet.Range["B2"].NumberValue = 25;
            sheet.Range["B3"].NumberValue = 18;
            sheet.Range["B4"].NumberValue = 8;
            sheet.Range["B5"].NumberValue = 13;
            sheet.Range["B6"].NumberValue = 22;
            sheet.Range["B7"].NumberValue = 28;
           
            Chart chart = sheet.Charts.Add(ExcelChartType.LineMarkers);
            chart.DataRange = sheet.Range["B1:B7"];
            chart.PlotArea.Visible = false;
            chart.SeriesDataFromRange = false;
            chart.TopRow = 5;
            chart.BottomRow = 26;
            chart.LeftColumn = 2;
            chart.RightColumn =11;
            chart.ChartTitle = "Data Labels Demo";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size = 12;
            Spire.Xls.Charts.ChartSerie cs1 = chart.Series[0];      
            cs1.CategoryLabels = sheet.Range["A2:A7"];
          
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasLegendKey = false;
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasPercentage = false;
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasSeriesName = true;
            cs1.DataPoints.DefaultDataPoint.DataLabels.HasCategoryName = true;
            cs1.DataPoints.DefaultDataPoint.DataLabels.Delimiter = ". ";

            cs1.DataPoints.DefaultDataPoint.DataLabels.Size = 9;
            cs1.DataPoints.DefaultDataPoint.DataLabels.Color = Color.Red;
            cs1.DataPoints.DefaultDataPoint.DataLabels.FontName = "Calibri";
            cs1.DataPoints.DefaultDataPoint.DataLabels.Position = DataLabelPositionType.Center;
            cs1.DataPoints.DefaultDataPoint.DataLabels.FrameFormat.Fill.Texture = GradientTextureType.Papyrus;
        
            workbook.SaveToFile("S3.xlsx", ExcelVersion.Version2010);
            System.Diagnostics.Process.Start("S3.xlsx");
        }
    }
}
page 236