ByteScout PDF SDK - VB.NET - Convert XPS to PDF - ByteScout

ByteScout PDF SDK – VB.NET – Convert XPS to PDF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – VB.NET – Convert XPS to PDF

How to convert XPS to PDF in VB.NET and ByteScout PDF SDK

Tutorial on how to convert XPS to PDF in VB.NET

The sample source codes on this page shows how to convert XPS to PDF in VB.NET. ByteScout PDF SDK 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 be used to convert XPS to PDF using VB.NET.

The SDK samples like this one below explain how to quickly make your application do convert XPS to PDF in VB.NET with the help of ByteScout PDF SDK. In order to implement the functionality, you should copy and paste this code for VB.NET below into your code editor with your app, compile and run your application. Implementing VB.NET application typically includes multiple stages of the software development so even if the functionality works please test it with your data and the production environment.

ByteScout free trial version is available for download from our website. It includes all these programming tutorials along with source code samples.

Try ByteScout PDF SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

Program.vb
      
Imports System.Drawing.Imaging Imports System.IO Imports Bytescout.PDF Imports xps2img Imports Page = Bytescout.PDF.Page ''' <summary> ''' This example demonstrates converting xps document to pdf ''' </summary> Class Program Shared Sub Main() ' Create new document Dim pdfDocument = New Document() pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" 'Create instance And load file Dim xps2Image As New Xps2Image("Sample.xps") ' Set parameter Dim oParam As New Parameters() oParam.Dpi = 300 ' Set Dpi oParam.ImageType = ImageType.Png ' Output image type ' Get Bitmap from input file Dim outBitmapList = xps2Image.ToBitmap(oParam) For Each itmBitmap In outBitmapList ' Create New pdf page Dim page As New Page(PaperFormat.A4) ' Save image to a bytestream Dim byteStream As New MemoryStream() itmBitmap.Save(byteStream, ImageFormat.Png) ' Fill page with image Dim pageImage As 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) Next ' Save document to file pdfDocument.Save("result.pdf") ' Cleanup pdfDocument.Dispose() ' Open result document in default associated application (for demo purpose) Dim processStartInfo As New ProcessStartInfo("result.pdf") processStartInfo.UseShellExecute = True Process.Start(processStartInfo) End Sub End Class

Try ByteScout PDF SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

app.config
      
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.diagnostics> <sources> <!-- This section defines the logging configuration for My.Application.Log --> <source name="DefaultSource" switchName="DefaultSwitch"> <listeners> <add name="FileLog"/> <!-- Uncomment the below section to write to the Application Event Log --> <!--<add name="EventLog"/>--> </listeners> </source> </sources> <switches> <add name="DefaultSwitch" value="Information"/> </switches> <sharedListeners> <add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/> <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log --> <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> --> </sharedListeners> </system.diagnostics> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

Try ByteScout PDF SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

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

Try ByteScout PDF SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Get ByteScout PDF SDK Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Tutorials:

prev
next