This simple topic covers how to convert Word to PCL in C#. It includes all the required information to set up the development environment and provides a working example code for converting DOCX to PCL using C#. The developed application can be used inside any .NET configured environment in Linux, macOS, or MS Windows.
Steps to Export DOCX to PCL in C#
- Configure the environment to use Aspose.Words for .NET to convert a Word file to PCL in C#
- Load the source Word document file using an instance of the Document class
- Create an instance of the PclSaveOptions class object and set the required output PCL file settings
- Save the Word document as a PCL file on the disk
The above mentioned steps entail the process to transform Word document to PCL in C# using a very simple API interface. The process will commence by loading the source Word document either from disk or using a memory stream, which is then followed by creating an instance of the PclSaveOptions class to set the required PCL file properties. Finally, the loaded Word document will be saved as a PCL file on the disk.
Code to Convert Word to PCL in C#
using Aspose.Words; | |
using Aspose.Words.Saving; | |
namespace Testword | |
{ | |
public class WordToPCL | |
{ | |
public static void ConvertToPCL() | |
{ | |
string FilePath = @"/Users/KnowledgeBase/TestData/"; | |
// Applying product license to convert Word files to PCL | |
License wordsLiense = new License(); | |
wordsLiense.SetLicense(FilePath + "Conholdate.Total.Product.Family.lic"); | |
Document sourceDocx = new Document(FilePath + "Test1.docx"); | |
PclSaveOptions options = new PclSaveOptions(); | |
options.AllowEmbeddingPostScriptFonts = true; | |
options.ColorMode = ColorMode.Grayscale; | |
options.JpegQuality = 100; | |
// Convert Word to PCL | |
sourceDocx.Save(FilePath + "DocumentPcl.pcl", options); | |
} | |
} | |
} |
The above example code performs the process to export DOCX to PCL in C# using simple API calls. The PclSaveOptions class offers several optional properties to customize the output PCL file including setting the ColorMode, CustomTimeZoneIfo, DefaultTemplate, Dml3DEffectsRenderingMode, ExportGeneratorName, FallbackFontName, and JpegQuality to name a few.
In this topic, we learned about how to convert Word documents to PCL using C#. If you want to learn the process of combining Word documents, refer to the article on how to merge Word Documents using C#.