Knowledgebase (2311)
Children categories
Bookmarks give convenience when users want go to specified location and it is clearly to know the contents brief information. Spire.Doc for .NET has a powerful function of operating the word elements of bookmarks. Developers can add bookmarks, Edit/replace bookmarks and remove bookmarks in word documents. Now Spire.Doc starts to support preserve bookmarks in DOCX to PDF conversion. This article will show you how to preserve bookmarks in C# when converting word document into PDF file format.
Download and install Spire.Doc for .NET (Version 5.2.20 or above) and then add Spire.Doc.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Doc\Bin\NET4.0\ Spire.Doc.dll".
Here comes to the details of how to preserve the bookmarks from word to PDF conversion in C#.
Step 1: Load a word documents with bookmarks.
Document doc = new Document();
doc.LoadFromFile("test.docx", FileFormat.Docx);
Step 2: Create an instance of ToPdfParameterList
ToPdfParameterList toPdf = new ToPdfParameterList();
Step 3: Set CreateWordBookmarks to true to use word bookmarks when create the bookmarks.
toPdf.CreateWordBookmarks = true;
Step 4: Save the PDF file.
doc.SaveToFile("test.Pdf",toPdf);
Effective screenshot of preserve the bookmarks in result PDF page:

Full codes:
using Spire.Doc;
namespace PreventBookmark
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("test.docx", FileFormat.Docx);
ToPdfParameterList toPdf = new ToPdfParameterList();
toPdf.CreateWordBookmarks = true;
doc.SaveToFile("test.Pdf", toPdf);
System.Diagnostics.Process.Start("test.Pdf");
}
}
}
As is shown in the following presentation slide, shapes automatically stack in separate layers as you add them. To change the order of overlapping shapes, we can move the layers forward and backward. But how can we achieve this task programmatically using C# or VB.NET? This article is aimed to present you a solution on how to reorder overlapping shapes using Spire.Presentation.

In the early edition, Spire.Presentation is already capable of adding different kinds of shapes to the slides, setting color and fill style of the shape. In the Version2.0.18, we add reordering overlapping shapes as a new feature to satisfy our customer’s demands. Now, let’s see how to make it happen with sample code snippet.
Step 1: Create a new instance of Spire.Presentation class and load the test file.
Spire.Presentation.Presentation presentation = new Presentation();
presentation.LoadFromFile("..\\..\\test.pptx");
Step 2: Get the first shape from the slide.
IShape shape = presentation.Slides[0].Shapes[0];
Step 3: Change the shape's Zorder by setting its position index.
presentation.Slides[0].Shapes.ZOrder(1, shape);
Step 4: Save to a PPTX file and launch the file.
string output = "output.pptx"; presentation.SaveToFile(output,FileFormat.Pptx2010); System.Diagnostics.Process.Start(output);
Output:

Full code:
using Spire.Presentation;
namespace ReorderOverlappingShape
{
class Program
{
static void Main(string[] args)
{
//Create an instance of Spire.Presentation
Spire.Presentation.Presentation presentation = new Presentation();
//Load a pptx file
presentation.LoadFromFile("..\\..\\test.pptx");
//Get the first shape of the first slide
IShape shape = presentation.Slides[0].Shapes[0];
//Change the shape's zorder
presentation.Slides[0].Shapes.ZOrder(1, shape);
//Save to a pptx2010 file.
string output = "output.pptx";
presentation.SaveToFile(output, FileFormat.Pptx2010);
//Launch the output file
System.Diagnostics.Process.Start(output);
}
}
}
Imports Spire.Presentation
Namespace ReorderOverlappingShape
Class Program
Private Shared Sub Main(args As String())
'Create an instance of Spire.Presentation
Dim presentation As Spire.Presentation.Presentation = New Presentation()
'Load a pptx file
presentation.LoadFromFile("..\..\test.pptx")
'Get the first shape of the first slide
Dim shape As IShape = presentation.Slides(0).Shapes(0)
'Change the shape's zorder
presentation.Slides(0).Shapes.ZOrder(1, shape)
'Save to a pptx2010 file.
Dim output As String = "output.pptx"
presentation.SaveToFile(output, FileFormat.Pptx2010)
'Launch the output file
System.Diagnostics.Process.Start(output)
End Sub
End Class
End Namespace
Everytime we try to open a password-protected PowerPoint file, we will then be prompted to enter the password. This can be really a bothering thing itself. But things get worse if we forget the password. To avoid this situation from being occurred, we can choose to remove the encryption if the PowerPoint file is not necessarily protected. In this article, I’ll introduce you how to remove encryption on password-protected PowerPoint file using Spire.Presentation.
In the classes of Spire.Presentation, you can invoke Presentation.LoadFromFile(string file, string password) method to load the file that you want to remove protection, then you're entitled to remove encryption by calling Presentation.RemoveEncryption() method. More details:
Step 1: Create Presentation instance and load file.
Presentation presentation = new Presentation();
presentation.LoadFromFile("Presentation1.pptx", "test");
Step 2: Remove encryption.
presentation.RemoveEncryption();
Step 3: Save and launch the file.
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
Effect Screenshot:

Full Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Presentation;
namespace RemoveProtect
{
class Program
{
static void Main(string[] args)
{
// create Presentation instance and load file
Presentation presentation = new Presentation();
presentation.LoadFromFile("Presentation1.pptx", "test");
//remove encryption
presentation.RemoveEncryption();
//save the file
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Spire.Presentation
Namespace RemoveProtect
Class Program
Shared Sub Main(ByVal args() As String)
' create Presentation instance and load file
Dim presentation As Presentation = New Presentation()
presentation.LoadFromFile("Presentation1.pptx", "test")
'remove encryption
presentation.RemoveEncryption()
'save the file
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010)
System.Diagnostics.Process.Start("result.pptx")
End Sub
End Class
End Namespace