This short tutorial describes how to convert PCL file to PDF using C# REST API. You will learn to automatically transform Convert PCL to PDF using C# RESTful Service using a .NET-based Cloud SDK. The output PDF file is fetched from the response object and saved on the disk.
Prerequisite
- Create an account API credentials to change PCL to PDF
- Download Aspose.PDF Cloud SDK for Dotnet for converting Printer Command Language files to PDF
- Setup C# project with the above SDK
Steps to Convert PCL to PDF Online using C# REST API
- Create the PdfApi class object and set the Client ID and secret to change PCL to PDF
- Read the source PCL (Printer Command Language) file to byte array
- Change the PCL byte array to a memory stream
- Upload the PCL file contents to the Cloud storage
- Call the GetPclInStorageToPdf() method to transform the PCL file
- Save the resultant PDF file from the response object generated from the PCL file
These steps summarize how to convert PCL to PDF using C# .NET-based API. Load the source PCL file into a memory stream and upload it to the Cloud storage. Finally, call the GetPclInStorageToPdf() method to change the PCL file format to PDF in the cloud storage and return the stream containing the output PDF file contents.
Code for PCL to PDF Converter using C# Low Code API
using System; | |
using System.IO; | |
using Aspose.Pdf.Cloud.Sdk.Api; | |
using Aspose.Pdf.Cloud.Sdk.Model; | |
using System.Collections.Generic; | |
namespace Aspose.PDF.Cloud.Examples.Kb | |
{ | |
public class PdfTasks | |
{ | |
public static void ConvertPclToPdf() | |
{ | |
// Initialize API with credentials | |
var pdfService = new PdfApi("ClientSecret", "ClientID"); | |
string documentName = "MyPcl.pcl"; | |
// Upload the PCL file | |
using (var mdFileStream = new MemoryStream(File.ReadAllBytes(documentName))) | |
{ | |
var uploadResult = pdfService.UploadFile(documentName, mdFileStream); | |
} | |
// Convert PCL to PDF | |
var response = pdfService.GetPclInStorageToPdf(documentName); | |
FileStream fileStream = new FileStream("output.pdf", FileMode.Create, FileAccess.Write); | |
response.CopyTo(fileStream); | |
} | |
} | |
} |
This code demonstrates the changing of the file format from PCL to PDF using C# REST API. You may upload the output PDF file stream back to the Cloud storage and perform any other operation to customize it to fulfil your needs. This whole process requires just a few API calls to accomplish the task.
This guide has taught us to change PCL to PDF. To transform the FXA form to PDF, refer to the article on Convert XFA Form to PDF using C# REST API.