It is pretty easy in MS PowerPoint to export a certain shape as image with following two steps:

  • 1. Select the object shape
  • 2. From the right-click menu select Save as Picture

However, Spire.Presentation also provides easy method for programmers to save shapes out of slides. In the following section, we’ll introduce how to export shapes as images via Spire.Presentation with an example.

Test File:

As is shown in the screenshot, the sample file for testing contains several shapes on the first slide.

How to Export Shapes as Images in PowerPoint in C#, VB.NET

Code Snippet for Exporting Shape as Image:

Step 1: Initialize a new instance of Presentation class and load the test file from disk.

Presentation ppt = new Presentation();
ppt.LoadFromFile("test.pptx");

Step 2: Use for loop to traverse every shape in the slide. Call ShapeList.SaveAsImage(int shapeIndex) to save shape as image, then save this image to the specified file in the specified format.

for (int i = 0; i < ppt.Slides[0].Shapes.Count; i++)
{
    Image image = ppt.Slides[0].Shapes.SaveAsImage(i);
    image.Save(String.Format("Picture-{0}.png", i), System.Drawing.Imaging.ImageFormat.Png);
}

Output:

Picture-0

How to Export Shapes as Images in PowerPoint in C#, VB.NET

Picture-1

How to Export Shapes as Images in PowerPoint in C#, VB.NET

Entire Code:

C#
using Spire.Presentation;
using System.Drawing;

namespace ExportShape
{

    class Program
    {

        static void Main(string[] args)
        {
            //create PPT document 
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("test.pptx");

            for (int i = 0; i < ppt.Slides[0].Shapes.Count; i++)
            {
                Image image = ppt.Slides[0].Shapes.SaveAsImage(i);
                image.Save(System.String.Format("Picture-{0}.png", i), System.Drawing.Imaging.ImageFormat.Png);
            }


        }
    }
}
VB.NET
Imports Spire.Presentation
Imports System.Drawing

Namespace ExportShape

	Class Program

		Private Shared Sub Main(args As String())
			'create PPT document 
			Dim ppt As New Presentation()
			ppt.LoadFromFile("test.pptx")

			For i As Integer = 0 To ppt.Slides(0).Shapes.Count - 1
				Dim image As Image = ppt.Slides(0).Shapes.SaveAsImage(i)
				image.Save(System.[String].Format("Picture-{0}.png", i), System.Drawing.Imaging.ImageFormat.Png)
			Next


		End Sub
	End Class
End Namespace

Spire.XLS has powerful functions to export Excel worksheets into different image file formats. In the previous articles, we have already shown you how to convert Excel worksheets into BMP, PNG, GIF, JPG, JPEG, TIFF. Now Spire.XLS newly starts to support exporting Excel worksheet into EMF image. With the help of Spire.XLS, you only need three lines of codes to finish the conversion function.

Make sure Spire.XLS (Version 7.6.43 or above) has been installed correctly and then add Spire.xls.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Xls\Bin\NET4.0\ Spire. Xls.dll". Here comes to the details of how to convert excel worksheet to EMF image.

Step 1: Create an excel document and load the document from file.

Workbook workbook = new Workbook();
workbook.LoadFromFile("XLS2.xlsx");

Step 2: Get the first worksheet in excel workbook.

Worksheet sheet = workbook.Worksheets[0];

Step 3: Save excel worksheet into EMF image.

sheet.SaveToEMFImage("result.emf", 1, 1, 19, 6, system.Drawing.Imaging.EmfType.EmfPlusDual);

Effective screenshot:

How to convert Excel worksheet to EMF image in C#

Full codes:

using Spire.Xls;

namespace XLStoEMF
{
    class Program
    {
        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("XLS2.xlsx");
            
            Worksheet sheet = workbook.Worksheets[0];
            sheet.SaveToEMFImage("result.emf", 1, 1, 19,6, System.Drawing.Imaging.EmfType.EmfPlusDual);
            
         }
    }
}

Set offset of the filled image could make your chart background pictures zoom and show proportional as you wish. This article shows how to set the offset of image via Spire.XLS.

Here are the steps:

Step 1: Create an instance of Spire.XLS.Workbook.

Workbook book = new Workbook();

Step 2: Load data and create a contrast sheet.

workbook.LoadFromFile("test.xlsx",ExcelVersion.Version2013);
Worksheet sheet = workbook.Worksheets[0];
Worksheet sheet1 = workbook.Worksheets.Add("Contrast"); 

Step 3: Add chart1 and background image to sheet1 as comparision.

Chart chart1 = sheet1.Charts.Add(ExcelChartType.ColumnClustered);
chart1.DataRange = sheet.Range["D1:E9"];
chart1.SeriesDataFromRange = false;

chart1.LeftColumn = 1;
chart1.TopRow = 11;
chart1.RightColumn = 8;
chart1.BottomRow = 33;

chart1.ChartArea.Fill.CustomPicture(Image.FromFile("2.jpg"), "None");

Step 4: Add same chart and background image then set offset of image by transforming image in sheet[0] as form of XlsShapeFill. Then set the property of PicStretch of each direction with percentage and Tile property.

Chart chart = sheet.Charts.Add(ExcelChartType.ColumnClustered);
chart.DataRange = sheet.Range["D1:E9"];
chart.SeriesDataFromRange = false;
                 
chart.LeftColumn = 1;
chart.TopRow = 11;
chart.RightColumn = 8;
chart.BottomRow = 33;
          
chart.ChartArea.Fill.CustomPicture(Image.FromFile("2.jpg"), "None");
            
IChart ichart = sheet.Charts[0];
(ichart.ChartArea.Fill as XlsShapeFill).Tile = false;
(ichart.ChartArea.Fill as XlsShapeFill).PicStretch.Left = 10;
(ichart.ChartArea.Fill as XlsShapeFill).PicStretch.Top = 20;
(ichart.ChartArea.Fill as XlsShapeFill).PicStretch.Right = 10;
(ichart.ChartArea.Fill as XlsShapeFill).PicStretch.Bottom = 5;

Step 5: Save and review.

workbook.SaveToFile("result.xlsx", ExcelVersion.Version2013);
System.Diagnostics.Process.Start("result.xlsx");

Screenshot:

Set the offset of image when the fill way of chart is picture fill via Spire.XLS

Set the offset of image when the fill way of chart is picture fill via Spire.XLS

Full code:

using Spire.Xls;
using Spire.Xls.Core;
using Spire.Xls.Core.Spreadsheet.Shapes;
using System.Drawing;
namespace SetOffsetofImage
{
    class Program
    {
        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("test.xlsx", ExcelVersion.Version2013);
            Worksheet sheet = workbook.Worksheets[0];
            Worksheet sheet1 = workbook.Worksheets.Add("Contrast");

            //add contrast
            Chart chart1 = sheet1.Charts.Add(ExcelChartType.ColumnClustered);
            chart1.DataRange = sheet.Range["D1:E9"];
            chart1.SeriesDataFromRange = false;

            //Chart Position
            chart1.LeftColumn = 1;
            chart1.TopRow = 11;
            chart1.RightColumn = 8;
            chart1.BottomRow = 33;

            chart1.ChartArea.Fill.CustomPicture(Image.FromFile("2.jpg"), "None");

            //add original
            Chart chart = sheet.Charts.Add(ExcelChartType.ColumnClustered);
            chart.DataRange = sheet.Range["D1:E9"];
            chart.SeriesDataFromRange = false;

            //Chart Position
            chart.LeftColumn = 1;
            chart.TopRow = 11;
            chart.RightColumn = 8;
            chart.BottomRow = 33;

            chart.ChartArea.Fill.CustomPicture(Image.FromFile("2.jpg"), "None");

            IChart ichart = sheet.Charts[0];
            (ichart.ChartArea.Fill as XlsShapeFill).Tile = false;
            (ichart.ChartArea.Fill as XlsShapeFill).PicStretch.Left = 10;
            (ichart.ChartArea.Fill as XlsShapeFill).PicStretch.Top = 20;
            (ichart.ChartArea.Fill as XlsShapeFill).PicStretch.Right = 10;
            (ichart.ChartArea.Fill as XlsShapeFill).PicStretch.Bottom = 5;

            workbook.SaveToFile("result.xlsx", ExcelVersion.Version2013);
            System.Diagnostics.Process.Start("result.xlsx");
        }
    }
}

When a user opens a PDF document they see the initial view of the PDF. By default, the Bookmarks Panel or Thumbnails Panel is not shown when the PDF is opened. In this article, we're going to demonstrate how to set document properties so that the Bookmarks Panel or Thumbnails Panel will be open every time the file is launched.

Check the test file below, only the page content is showing when the document is opened.

How to Automatically Display Bookmarks or Thumbnails When PDF is Opened in C#, VB.NET

Code Snippet and Effect:

Step 1: Create a new PDF document and load the test file.

PdfDocument Pdf = new PdfDocument();
Pdf.LoadFromFile("Test.pdf");

Step 2: In the class of ViewerPreferences, there is a PageMode property that specifies how the document should be displayed when opened. Set PageMode as UseOutlines, save the changes to a new PDF file named "ShowBookmarks".

Pdf.ViewerPreferences.PageMode = PdfPageMode.UseOutlines;
Pdf.SaveToFile("ShowBookmarks.pdf");

Open the newly-generated file, Bookmarks Panel will be automatically displayed as below:

How to Automatically Display Bookmarks or Thumbnails When PDF is Opened in C#, VB.NET

Step 3: If we set PageMode as UseThumbs, and save the changes to another PDF file named "ShowThumbnails", then we will get following effect if we open this file.

Pdf.ViewerPreferences.PageMode = PdfPageMode.UseThumbs;
Pdf.SaveToFile("ShowThumbnails.pdf");

How to Automatically Display Bookmarks or Thumbnails When PDF is Opened in C#, VB.NET

Full Code:

[C#]
using Spire.Pdf;

namespace Bookmarks
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument Pdf = new PdfDocument();
            Pdf.LoadFromFile("Test.pdf");
            Pdf.ViewerPreferences.PageMode = PdfPageMode.UseOutlines;
            Pdf.SaveToFile("ShowBookmarks.pdf");
            Pdf.ViewerPreferences.PageMode = PdfPageMode.UseThumbs;
            Pdf.SaveToFile("ShowThumbnails.pdf");
        }
    }
}
[VB.NET]
Imports Spire.Pdf

Namespace Bookmarks
	Class Program
		Private Shared Sub Main(args As String())
			Dim Pdf As New PdfDocument()
			Pdf.LoadFromFile("Test.pdf")
			Pdf.ViewerPreferences.PageMode = PdfPageMode.UseOutlines
			Pdf.SaveToFile("ShowBookmarks.pdf")
			Pdf.ViewerPreferences.PageMode = PdfPageMode.UseThumbs
			Pdf.SaveToFile("ShowThumbnails.pdf")
		End Sub
	End Class
End Namespace

Spire.Presentation has powerful functions to export PowerPoint documents into different image file formats. In the previous articles, we have already shown you how to convert PowerPoint documents into TIFF, PNG and JPG. This article will demonstrate how to convert PowerPoint documents into EMF image. With Spire.Presentation for .NET, we can save presentation slides as an EMF image with the same size with the original slide's size and we can also set a specific size for the resulted EMF image.

Convert Presentation slides to EMF with the default size:

Step 1: Create a presentation document.

Presentation presentation = new Presentation();

Step 2: Load the PPTX file from disk.

presentation.LoadFromFile("Sample.pptx", FileFormat.Pptx2010);

Step 3: Save the presentation slide to EMF image by the method of SaveAsEMF().

presentation.Slides[2].SaveAsEMF("Result.emf");

Effective screenshot:

How to convert PowerPoint document to EMF image in C#

Convert Presentation slides to EMF with a specific size of 1075*710:

Step 1: Create a presentation document.

Presentation presentation = new Presentation();

Step 2: Load the PPTX file from disk.

presentation.LoadFromFile("sample.pptx");

Step 3: Save the presentation slide to EMF image with a specific size of 1075*710 by the method of SaveAsEMF(string filePath, int width, int height).

presentation.Slides[2].SaveAsEMF("Result2.emf", 1075, 710);

Effective screenshot:

How to convert PowerPoint document to EMF image in C#

Full codes:

using Spire.Presentation;
namespace PPStoEMF
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();
            presentation.LoadFromFile("Sample.pptx", FileFormat.Pptx2010);

            //presentation.Slides[2].SaveAsEMF("Result.emf");
            presentation.Slides[2].SaveAsEMF("Result2.emf", 1075, 710);
        }
    }
}

We can set Asian typography for paragraph for .doc files, there are four text alignments: Top, Center, Baseline, Bottom and Auto. In this article let's see how to set alignment when append HTML string code to .doc in C#.

Download Spire.Doc 5.3.83 or upper version, then add reference to your project.

Here are the steps:

Step 1: Create a HTML file contain the following code.

<html>
<body>
<i>f</i>(<i>x</i>)=<img align="middle" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAlCAYAAADBa/A+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADvSURBVFhH7ZNbCsUwCES7/03nIkSwRh1rL00+PCCJVaeTPq5xMG2uSpuLuC7fwlZzZOxYc0TZnDwZ76WYzjVRjQnn57oQmdC5x9ses6IHUO7xd3NW8xNzVPPCwrtOLBXdbAlHgpJMX9SzVGQz7fUw55Eo87ZnqVAzh8x5z8jrHpl6pBNPb6bNVWlzVW7m5N+zKyT9Wqu0OYn3fVl8am754IHBz5+cpGxOP3qda9CNLNAMVESmmG3mMjw1lzrwXF0iEap5gUj1zNUlI0Jk+4i05lxNWCR1ysIh0Ixb1SJQCNQJ1pERgRU30uaqHGxujB+eJddCfZBWMwAAAABJRU5ErkJggg==" />

Step 2: Create a new document and add new section.

Document doc2 = new Document();
doc2.AddSection();

Step 3: Create new paragraph p and set its property of TextAlignment as "Center".

p.AppendText("Alignment:Center      ");
p.AppendHTML(File.ReadAllText(@"test.html"));
p.Format.TextAlignment = TextAlignment.Center; 

Step 4: Set other options to make a contrast, Auto is Baseline by default.

Paragraph p1 = doc2.Sections[0].AddParagraph();
p1.AppendText("Alignment:Baseline   ");
p1.AppendHTML(File.ReadAllText(@"test.html"));
p1.Format.TextAlignment = TextAlignment.Baseline;

Paragraph p2 = doc2.Sections[0].AddParagraph();
p2.AppendText("Alignment:Bottom    ");
p2.AppendHTML(File.ReadAllText(@"test.html"));
p2.Format.TextAlignment = TextAlignment.Bottom;

Paragraph p3 = doc2.Sections[0].AddParagraph();
p3.AppendText("Alignment:Top          ");
p3.AppendHTML(File.ReadAllText(@"test.html"));
p3.Format.TextAlignment = TextAlignment.Top;

Paragraph p4 = doc2.Sections[0].AddParagraph();
p4.AppendText("Alignment:Auto        ");
p4.AppendHTML(File.ReadAllText(@"test.html"));
p4.Format.TextAlignment = TextAlignment.Auto;

Step 5: Save and review.

doc2.SaveToFile(@"test.doc", FileFormat.Doc);
System.Diagnostics.Process.Start("test.doc");

The screen shot:

Set text alignment when append HTML string code to .doc in C#

Full Code Here:

using Spire.Doc;
using Spire.Doc.Documents;
using System.IO;
namespace SetTextAlignment
{
 class Program
    {
     
      static void Main(string[] args)
        {
            Document doc2 = new Document();
            doc2.AddSection();
            Paragraph p = doc2.Sections[0].AddParagraph();
            p.AppendText("Alignment:Center      ");
            p.AppendHTML(File.ReadAllText(@"test.html"));
            p.Format.TextAlignment = TextAlignment.Center;

            Paragraph p1 = doc2.Sections[0].AddParagraph();
            p1.AppendText("Alignment:Baseline   ");
            p1.AppendHTML(File.ReadAllText(@"test.html"));
            p1.Format.TextAlignment = TextAlignment.Baseline;

            Paragraph p2 = doc2.Sections[0].AddParagraph();
            p2.AppendText("Alignment:Bottom    ");
            p2.AppendHTML(File.ReadAllText(@"test.html"));
            p2.Format.TextAlignment = TextAlignment.Bottom;

            Paragraph p3 = doc2.Sections[0].AddParagraph();
            p3.AppendText("Alignment:Top          ");
            p3.AppendHTML(File.ReadAllText(@"test.html"));
            p3.Format.TextAlignment = TextAlignment.Top;

            Paragraph p4 = doc2.Sections[0].AddParagraph();
            p4.AppendText("Alignment:Auto        ");
            p4.AppendHTML(File.ReadAllText(@"test.html"));
            p4.Format.TextAlignment = TextAlignment.Auto;

            doc2.SaveToFile(@"test.doc", FileFormat.Doc);
            System.Diagnostics.Process.Start("test.doc");

        }
    }
}

Using Spire.XLS, programmers are able to save the whole worksheet as PDF by calling the method SaveToPdf(). However, you may only want to save or export a part of worksheet as PDF. Since Spire.XLS doesn't provide a method to directly convert a range of cells to PDF, we can copy the selected ranges to a new worksheet and then save it as PDF file. This method seems complex, but it is still efficient with Spire.XLS.

Look at the test file below, we only want the cells from A1 to H11 converted as PDF. We will firstly create a new blank worksheet, copy the selected range to the new sheet using CellRange.Copy() method, then convert the new sheet as PDF.

How to Convert Selected Range of Cells to PDF in C#, VB.NET

Code Snippet:

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

Workbook workbook = new Workbook();
workbook.LoadFromFile("test.xlsx", ExcelVersion.Version2010);

Step 2: Add a new worksheet to workbook.

workbook.Worksheets.Add("newsheet");

Step 3: Copy the selected range from where it stores to the new worksheet.

workbook.Worksheets[0].Range["A1:H11"].Copy(workbook.Worksheets[1].Range["A1:H11"]);

Step 4: Convert the new worksheet to PDF.

workbook.Worksheets[1].SaveToPdf("result.pdf", Spire.Xls.FileFormat.PDF);

Result:

How to Convert Selected Range of Cells to PDF in C#, VB.NET

Full Code:

[C#]
using Spire.Xls;
namespace Convert
{
    class Program
    {
          static void Main(string[] args)
{
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("test.xlsx", ExcelVersion.Version2010);
    // add a new sheet to workbook
    workbook.Worksheets.Add("newsheet");
    //Copy your area to new sheet.
    workbook.Worksheets[0].Range["A1:H11"].Copy(workbook.Worksheets[1].Range["A1:H11"]);
    //convert new sheet to pdf
    workbook.Worksheets[1].SaveToPdf("result.pdf", Spire.Xls.FileFormat.PDF);

}

        }
    }
[VB.NET]
Imports Spire.Xls
Namespace Convert
	Class Program
		Private Shared Sub Main(args As String())
			Dim workbook As New Workbook()
			workbook.LoadFromFile("test.xlsx", ExcelVersion.Version2010)
			' add a new sheet to workbook
			workbook.Worksheets.Add("newsheet")
			'Copy your area to new sheet.
			workbook.Worksheets(0).Range("A1:H11").Copy(workbook.Worksheets(1).Range("A1:H11"))
			'convert new sheet to pdf
			workbook.Worksheets(1).SaveToPdf("result.pdf", Spire.Xls.FileFormat.PDF)

		End Sub

	End Class
End Namespace

PDF form is often used to display, catch and edit data. People can fill blanks with data and submit data to server. Spire.PDF now enables users to add fields and create form in existing PDF document.

Here are the steps:

Step 1: Create PDF document, and load a blank PDF file, then get the first page.

PdfDocument pdf = new PdfDocument("Blank.pdf");
pdf.AllowCreateForm = (pdf.Form == null) ? true : false;
PdfPageBase page = pdf.Pages[0];

Step 2: Set font and font color. Preset coordinate.

PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 13f);
PdfBrush brush = PdfBrushes.Black;
float x = 10;
float y = 10;
float tempX = 0;
float tempY = 0;

Step 3: Draw textbox.

string text = "Textbox: ";
page.Canvas.DrawString(text, font, brush, x, y);
tempX = font.MeasureString(text).Width + 15;
tempY = font.MeasureString(text).Height + 15;
PdfTextBoxField textbox = new PdfTextBoxField(page, "TextBox");
textbox.Bounds = new RectangleF(tempX, y, tempX * 2, 15);
textbox.BorderWidth = 0.75f;
textbox.BorderStyle = PdfBorderStyle.Solid;
pdf.Form.Fields.Add(textbox);

Step 4: Draw checkbox.

text = "Checkbox: ";
y += tempY;
page.Canvas.DrawString(text, font, brush, x, y);
tempX = font.MeasureString(text).Width + 15;
tempY = font.MeasureString(text).Height + 15;
PdfCheckBoxField checkbox = new PdfCheckBoxField(page, "CheckBox");
checkbox.Bounds = new RectangleF(tempX, y, 15, 15);
checkbox.BorderWidth = 0.75f;
checkbox.Style = PdfCheckBoxStyle.Cross;
pdf.Form.Fields.Add(checkbox);

Step 5: Draw Listbox and add content.

//ListBox
text = "Listbox: ";
y += tempY;
page.Canvas.DrawString(text, font, brush, x, y);
tempX = font.MeasureString(text).Width + 15;
tempY = font.MeasureString(text).Height + 15;
PdfListBoxField listbox = new PdfListBoxField(page, "ListBox");
listbox.Bounds = new RectangleF(tempX, y, tempX * 2, tempY * 2);
listbox.BorderWidth = 0.75f;
for (int i = 0; i < 3; i++)
{
     string tempText = string.Format("Text {0}", i);
     string tempValue = string.Format("Value {0}", i);
     listbox.Items.Add(new PdfListFieldItem(tempText, tempValue));
}
pdf.Form.Fields.Add(listbox);

Step 6: Draw RadioButton.

//RadioButton
text = "Radiobutton: ";
y += tempY * 2 + 15;
page.Canvas.DrawString(text, font, brush, x, y);
tempX = font.MeasureString(text).Width + 15;
tempY = font.MeasureString(text).Height + 15;
PdfRadioButtonListField radiobutton = new PdfRadioButtonListField(page, "RadioButton");
for (int i = 0; i < 3; i++)
{
     PdfRadioButtonListItem item = new PdfRadioButtonListItem(string.Format("rb{0}", i));
     item.BorderWidth = 0.75f;
     item.Bounds = new RectangleF(tempX + i * 20, y, 15, 15);
     radiobutton.Items.Add(item);
}
pdf.Form.Fields.Add(radiobutton);

Step 7: Draw combobox and add content.

//ComboBox
text = "ComboBox: ";
y += tempY;
page.Canvas.DrawString(text, font, brush, x, y);
tempX = font.MeasureString(text).Width + 15;
tempY = font.MeasureString(text).Height + 15;
PdfComboBoxField combobox = new PdfComboBoxField(page, "ComboBox");
combobox.Bounds = new RectangleF(tempX, y, tempX, 15);
combobox.BorderWidth = 0.75f;
for (int i = 0; i < 3; i++)
{
    string tempText = string.Format("Text {0}", i);
    string tempValue = string.Format("Value {0}", i);
    combobox.Items.Add(new PdfListFieldItem(tempText, tempValue));
}
pdf.Form.Fields.Add(combobox);

Step 8: Save and review

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

Result screenshot:

How to add form field to an existing PDF via Spire.PDF

Full Code:

using Spire.Pdf;
using Spire.Pdf.Fields;
using Spire.Pdf.Graphics;
using System.Drawing;


namespace AddFormFieldToExistingPDF
{
    class Program
    {
        static void Main(string []args)
        {
            PdfDocument pdf = new PdfDocument("Blank.pdf");
            pdf.AllowCreateForm = (pdf.Form == null) ? true : false;
            PdfPageBase page = pdf.Pages[0];


            PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 13f);
            PdfBrush brush = PdfBrushes.Black;
            float x = 10;
            float y = 10;
            float tempX = 0;
            float tempY = 0;

            //TextBox
            string text = "Textbox: ";
            page.Canvas.DrawString(text, font, brush, x, y);
            tempX = font.MeasureString(text).Width + 15;
            tempY = font.MeasureString(text).Height + 15;
            PdfTextBoxField textbox = new PdfTextBoxField(page, "TextBox");
            textbox.Bounds = new RectangleF(tempX, y, tempX * 2, 15);
            textbox.BorderWidth = 0.75f;
            textbox.BorderStyle = PdfBorderStyle.Solid;
            pdf.Form.Fields.Add(textbox);

            //CheckBox
            text = "Checkbox: ";
            y += tempY;
            page.Canvas.DrawString(text, font, brush, x, y);
            tempX = font.MeasureString(text).Width + 15;
            tempY = font.MeasureString(text).Height + 15;
            PdfCheckBoxField checkbox = new PdfCheckBoxField(page, "CheckBox");
            checkbox.Bounds = new RectangleF(tempX, y, 15, 15);
            checkbox.BorderWidth = 0.75f;
            checkbox.Style = PdfCheckBoxStyle.Cross;
            pdf.Form.Fields.Add(checkbox);

            //ListBox
            text = "Listbox: ";
            y += tempY;
            page.Canvas.DrawString(text, font, brush, x, y);
            tempX = font.MeasureString(text).Width + 15;
            tempY = font.MeasureString(text).Height + 15;
            PdfListBoxField listbox = new PdfListBoxField(page, "ListBox");
            listbox.Bounds = new RectangleF(tempX, y, tempX * 2, tempY * 2);
            listbox.BorderWidth = 0.75f;
            for (int i = 0; i < 3; i++)
            {
                string tempText = string.Format("Text {0}", i);
                string tempValue = string.Format("Value {0}", i);
                listbox.Items.Add(new PdfListFieldItem(tempText, tempValue));
            }
            pdf.Form.Fields.Add(listbox);

            //RadioButton
            text = "Radiobutton: ";
            y += tempY * 2 + 15;
            page.Canvas.DrawString(text, font, brush, x, y);
            tempX = font.MeasureString(text).Width + 15;
            tempY = font.MeasureString(text).Height + 15;
            PdfRadioButtonListField radiobutton = new PdfRadioButtonListField(page, "RadioButton");
            for (int i = 0; i < 3; i++)
            {
                PdfRadioButtonListItem item = new PdfRadioButtonListItem(string.Format("rb{0}", i));
                item.BorderWidth = 0.75f;
                item.Bounds = new RectangleF(tempX + i * 20, y, 15, 15);
                radiobutton.Items.Add(item);
            }
            pdf.Form.Fields.Add(radiobutton);

            //ComboBox
            text = "ComboBox: ";
            y += tempY;
            page.Canvas.DrawString(text, font, brush, x, y);
            tempX = font.MeasureString(text).Width + 15;
            tempY = font.MeasureString(text).Height + 15;
            PdfComboBoxField combobox = new PdfComboBoxField(page, "ComboBox");
            combobox.Bounds = new RectangleF(tempX, y, tempX, 15);
            combobox.BorderWidth = 0.75f;
            for (int i = 0; i < 3; i++)
            {
                string tempText = string.Format("Text {0}", i);
                string tempValue = string.Format("Value {0}", i);
                combobox.Items.Add(new PdfListFieldItem(tempText, tempValue));
            }
            pdf.Form.Fields.Add(combobox);

            pdf.SaveToFile("Result.pdf");
            System.Diagnostics.Process.Start("Result.pdf");
        }
    }
}

When we create a PowerPoint slide that contains charts on it, we may not want others to change the chart data, especially when we create a presentation of financial report, it is very important for legal reasons that no changes get made when the slides are presented. In this article, I'll introduce how to protect chart on PowerPoint slide via Spire.Presentation in C# and VB.NET.

Test File:

How to Protect Chart on PowerPoint Slide in C#, VB.NET

Code Snippet:

Step 1: Create a new instance of Presentation class. Load the sample file to PPT document by calling LoadFromFile() method.

Presentation ppt = new Presentation();
ppt.LoadFromFile("sample.pptx",FileFormat.Pptx2010);

Step 2: Get the second shape from slide and convert it as IChart. The first shape in the sample file is a textbox.

IChart chart = ppt.Slides[0].Shapes[1] as IChart;

Step 3: Set the Boolean value of IChart.IsDataProtect as true.

chart.IsDataProtect = true;

Step 4: Save the file.

ppt.SaveToFile("result.pptx", FileFormat.Pptx2010);

Output:

Run this program and open the result file, you’ll get following warning message if you try to modify the chart data in Excel.

How to Protect Chart on PowerPoint Slide in C#, VB.NET

Full Code:

[C#]
using Spire.Presentation;
using Spire.Presentation.Charts;

namespace ProtectChart
{

    class Program
    {
        static void Main(string[] args)
        {

            Presentation ppt = new Presentation();
            ppt.LoadFromFile("sample.pptx", FileFormat.Pptx2010);

            IChart chart = ppt.Slides[0].Shapes[1] as IChart;
            chart.IsDataProtect = true;
            ppt.SaveToFile("result.pptx", FileFormat.Pptx2010);


        }
    }
}
[VB.NET]
Imports Spire.Presentation
Imports Spire.Presentation.Charts

Namespace ProtectChart

	Class Program
		Private Shared Sub Main(args As String())

			Dim ppt As New Presentation()
			ppt.LoadFromFile("sample.pptx", FileFormat.Pptx2010)

			Dim chart As IChart = TryCast(ppt.Slides(0).Shapes(1), IChart)
			chart.IsDataProtect = True
			ppt.SaveToFile("result.pptx", FileFormat.Pptx2010)


		End Sub
	End Class
End Namespace

Now Spire.Doc support using uninstalled font when converting Doc to PDF to diversity text content. In this article, we'll talk about how to realize this function:

Step 1: Download a font uninstalled in system.

How to use uninstalled font when converting Doc to PDF via Spire.Doc

Step 2: Create a new blank Word document.

Document document = new Document();

Step 3: Add a section and create a new paragraph.

Section section = document.AddSection();
Paragraph paragraph = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();

Step 4: Append text for a txtRange.

TextRange txtRange = paragraph.AppendText(text);

Step 5: Create an example for class ToPdfParameterList named to pdf, and create a new PrivateFontPathlist for property PrivateFontPaths, instantiate one PrivateFontPath with name and path of downloaded font.

ToPdfParameterList toPdf = new ToPdfParameterList()
{
    PrivateFontPaths = new List()
        {
          new PrivateFontPath("DeeDeeFlowers",@"D:\DeeDeeFlowers.ttf")
        }
};

Step 6: Set the new font for the txtaRange.

txtRange.CharacterFormat.FontName = "DeeDeeFlowers";

Step 7: Convert the Doc to PDF.

document.SaveToFile("result.pdf", toPdf);

Step 8: Review converted PDF files.

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

Result screenshot:

How to use uninstalled font when converting Doc to PDF via Spire.Doc

Full Code Below:

Document document = new Document();
           
//Add the first secition
Section section = document.AddSection();
//Create a new paragraph and get the first paragraph
Paragraph paragraph
    = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();

//Append Text
String text
    = "This paragraph is demo of text font and color. "
    + "The font name of this paragraph is Tahoma. "
    + "The font size of this paragraph is 20. "
    + "The under line style of this paragraph is DotDot. "
    + "The color of this paragraph is Blue. ";
 TextRange txtRange = paragraph.AppendText(text);

//Import the font
 ToPdfParameterList toPdf = new ToPdfParameterList()
 {
     PrivateFontPaths = new List<PrivateFontPath>()
         {
          new PrivateFontPath("DeeDeeFlowers",@"D:\DeeDeeFlowers.ttf")
         }
};
//Make use of the font.
txtRange.CharacterFormat.FontName = "DeeDeeFlowers";

document.SaveToFile("result.pdf", toPdf);

System.Diagnostics.Process.Start("result.pdf");
page 52