ByteScout PDF Suite - C# - Convert xps to pdf with pdf sdk - ByteScout

ByteScout PDF Suite – C# – Convert xps to pdf with pdf sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Suite – C# – Convert xps to pdf with pdf sdk

How to convert xps to pdf with pdf sdk in C# and ByteScout PDF Suite

Learning is essential in computer world and the tutorial below will demonstrate how to convert xps to pdf with pdf sdk in C#

These sample source codes on this page below are displaying how to convert xps to pdf with pdf sdk in C#. ByteScout PDF Suite: the set that includes 6 SDK products to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript. It can convert xps to pdf with pdf sdk in C#.

These C# code samples for C# guide developers to speed up coding of the application when using ByteScout PDF Suite. This C# sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Complete and detailed tutorials and documentation are available along with installed ByteScout PDF Suite if you’d like to learn more about the topic and the details of the API.

If you want to try other source code samples then the free trial version of ByteScout PDF Suite is available for download from our website. Just try other source code samples for C#.

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 Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite 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 Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite 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 Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite 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 Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next