ByteScout PDF SDK - C# - Convert XPS to PDF - ByteScout

ByteScout PDF SDK – C# – Convert XPS to PDF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – C# – Convert XPS to PDF

How to convert XPS to PDF in C# and ByteScout PDF SDK

This tutorial will show how to convert XPS to PDF in C#

Source code documentation samples provide quick and easy way to add a required functionality into your application. What is ByteScout PDF SDK? It is the SDK for pdf documents generation, modification and updates. Can also generate and fill PDF forms. Provides support for text (fonts, style, size, font family), layers, pdf form fields, vector and raster drawings. It can help you to convert XPS to PDF in your C# application.

The SDK samples like this one below explain how to quickly make your application do convert XPS to PDF in C# with the help of ByteScout PDF SDK. In your C# project or application you may simply copy & paste the code and then run your app! Test C# sample code examples whether they respond your needs and requirements for the project.

Trial version of ByteScout PDF SDK can be downloaded for free from our website. It also includes source code samples for C# and other programming languages.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System.Diagnostics; using System.Drawing.Imaging; using System.IO; using Bytescout.PDF; using Image = Bytescout.PDF.Image; using xps2img; namespace Images { /// <summary> /// This example demonstrates converting xps document to pdf /// </summary> class Program { static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; //Create instance and load file Xps2Image xps2Image = new Xps2Image("Sample.xps"); // Set parameter Parameters oParam = new Parameters(); oParam.Dpi = 300; // Set Dpi oParam.ImageType = ImageType.Png; // Output image type // Get Bitmap from input file var outBitmapList = xps2Image.ToBitmap(oParam); foreach (var itmBitmap in outBitmapList) { // Create new pdf page Page page = new Page(PaperFormat.A4); // Save image to a bytestream MemoryStream byteStream = new MemoryStream(); itmBitmap.Save(byteStream, ImageFormat.Png); // Fill page with image Image pageImage = new Image(byteStream); page.Canvas.DrawImage(pageImage, 5, 5, pageImage.Width / 2, pageImage.Height/3); // Add pdf page to pdf document pdfDocument.Pages.Add(page); } // Save document to file pdfDocument.Save("result.pdf"); // Cleanup pdfDocument.Dispose(); // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

app.config
      
<?xml version="1.0" encoding="utf-8"?> <configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

packages.config
      
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="xps2img" version="0.2.0" targetFramework="net45" /> </packages>

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next