This article guides on how to convert a PS file to PDF using C#. It has all the details to set the IDE, a list of steps, and a sample code for developing a PS file to PDF converter using C#. You can control the conversion by using the methods and properties in the PsLoadOptions object.
Steps to Convert PostScript to PDF using C#
- Set the environment for using Aspose.PDF for .NET to transform PS to PDF
- Create an object of the PsLoadOptions for customizing the conversion process
- Create the Document class object to load the PS file
- Pass the PS file name and PsLoadOptions object for loading the PS file
- Save the document object as a PDF file by passing the output file name
These steps summarize the process to convert PS in PDF using C#. Load the license, create an object of the PsLoadOptions class, and create a Document object with the source PS file and desired load options. Finally, set the properties in the Document object and save it as a PDF file on the disk.
Code to Convert from PS to PDF using C#
using Aspose.Pdf; | |
using System.IO; | |
namespace DocumentProcessor | |
{ | |
class PsConverter | |
{ | |
static void Main(string[] args)//PS to PDF | |
{ | |
var pdfLicense = new License();// License for PS conversion | |
pdfLicense.SetLicense("License.lic");// PDF Product license | |
var options = new PsLoadOptions();// PS loading options | |
var document = new Document("Sample.ps", options);// Load PS file | |
document.Save("PSToPDF_out.pdf");// Save PDF exported from PS | |
} | |
} | |
} |
This code has demonstrated the process to change PS to PDF using C#. You may use the WarningHandler property for handling any warnings generated during the conversion process. The DisableFontLicenseVerifications property is used to enable or disable the restrictions imposed on a font license during file loading.
This article has taught us to change the PS format to PDF using C#. To transform an EPS file to a PDF, refer to the article on How to convert EPS to PDF file in C#.