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

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

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

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

Learn to code in C# to convert xps to pdf with pdf sdk with this step-by-step tutorial

These source code samples are assembled by their programming language and functions they apply. ByteScout Premium Suite is the bundle that includes twelve SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording. It can be applied to convert xps to pdf with pdf sdk using C#.

Want to save time? You will save a lot of time on writing and testing code as you may just take the C# code from ByteScout Premium Suite for convert xps to pdf with pdf sdk below and use it in your application. Just copy and paste the code into your C# application’s code and follow the instructions. Applying C# application mostly includes various stages of the software development so even if the functionality works please test it with your data and the production environment.

ByteScout provides the free trial version of ByteScout Premium Suite along with the documentation and source code samples.

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

Explore ByteScout Premium Suite Documentation

Explore Samples

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

Explore ByteScout Premium Suite Documentation

Explore Samples

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

Explore ByteScout Premium Suite Documentation

Explore Samples

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

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next