xps to pdf

How to convert XPS to PDF with .NET REST API.

The efficient document management is essential for seamless workflows, the ability to convert XPS files to PDF format emerges as a valuable tool. XPS, or XML Paper Specification, is a standardized document format developed by Microsoft, often used for printing and sharing documents. However, PDF, or Portable Document Format, reigns supreme as the universal standard for document exchange, offering enhanced compatibility and accessibility across various platforms and devices. Therefore, by converting XPS documents to PDF using .NET REST API, developers gain the ability to unlock a myriad of benefits.

XPS to PDF Conversion API

Converting XPS files to PDF format becomes effortless with the help of Aspose.PDF Cloud SDK for .NET. This powerful SDK streamlines the conversion process, ensuring accuracy and reliability in preserving document integrity. You can seamlessly initiates XPS to PDF conversion within your .NET applications, eliminating the need for complex local installations. Furthermore, the cloud-based architecture ensures scalability and accessibility, allowing you to integrate these advanced features seamlessly into your applications without worrying about infrastructure management.

In order to use the SDK, search Aspose.Pdf-Cloud in NuGet packages manager and click the Add Package button. This will add the SDK reference in your project.

  • Obtain your client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.

Convert XPS to PDF in C# .NET

With this cloud SDK, you can not only achieve efficient XPS to PDF conversion but also unlock a wide range of capabilities to enhance your document processing workflows. So, let’s follow the instructions given below for an unparalleled efficiency during XPS to PDF conversion.

The following section explains the details on how to easily convert XPS file to PDF format using C# .NET.

PdfApi pdfApi = new PdfApi(clientSecret, clientID);

Create an object of PdfApi class where we pass client credentials as arguments.

pdfApi.UploadFile("sourceFile.pdf", stream);

Upload the input PDF file to cloud storage.

var resltant = pdfApi.PutXpsInStorageToPdf(resultantPDF,"input.xps");

Call API to convert to convert XPS file available in cloud storage to PDF format. The resultant file is also saved in cloud storage.

xps to pdf

A preview of XPS to PDF conversion.

The sample XPS file and the resultant PDF generated in above example can be downloaded from Simple.xps and resultant.pdf

  • In order to view the resultant PDF, you may consider using our free online PDF Viewer application.

Convert XPS Document to PDF using cURL Commands

Alternatively, converting XPS files to PDF format using Aspose.PDF Cloud and cURL commands offers a streamlined and versatile solution for document conversion tasks. By utilizing cURL commands to interact with the Aspose.PDF Cloud API, you can initiate the conversion process seamlessly. When using this approach, the first step is to generate a JWT access token using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=163c02a1-fcaa-4f79-be54-33012487e783&client_secret=c71cfe618cc6c0944f8f96bdef9813ac" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Once we have a JWT token, please execute the following command to convert XPS file to PDF format and save the output on local drive.

curl -v "https://api.aspose.cloud/v3.0/pdf/create/xps?srcPath={inputXPS}" \
-X GET \
-H "accept: multipart/form-data" \
-H "authorization: Bearer {accessToken}" \
-o "resultant.pdf"

In case we have a requirement to store the output in cloud storage, please try using the following command.

curl -v "https://api.aspose.cloud/v3.0/pdf/{resultantPDF}/create/xps?srcPath={inputXPS}" \
-X PUT \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-d {}

Replace inputXPS with the name of input XPS file available in cloud storage, resultantPDF with the name of resultant PDF image and, accessToken with JWT access token generated above.

Conclusion

In conclusion, we have learned that by leveraging Aspose.PDF Cloud SDK for .NET or by utilizing cURL commands in conjunction with Aspose.PDF Cloud API, we can implement efficient and reliable solutions for converting XPS files to PDF format. Owing to its cloud-based architecture, you can access powerful document conversion and manipulation functionalities without the need for complex local installations. Therefore, we highly recommend to streamline the document processing workflows and unlock the full potential of digital content.

We highly recommend visiting the following blog posts for information on: