How to convert image to XPS file from C#?

         In this article, I will show you how to convert image to XPS from C# programming language. The software I will use is named as VeryDOC Image to XPS Converter Command Line, by which you can also call it together with any programming or scripting languages, such as Visual Basic, C/C++, Delphi, ASP, PHP, C#, .NET, etc.

Supported image file formats:TIF, TIFF, JPG, JPEG, GIF, PNG, BMP, TGA, WMF, EMF, PCX
Supported system: all the Window platforms both of 32-bit and 64-bit.

When you use this software, you are able to specify any other printer name to instead of "Microsoft XPS Document Writer" printer; after converting, you can add watermark to output XPS file at any place in any kind of forms. Please check more functions of this application on homepage, in the following part, I will show you how to call it from C#.

Step 1. Free download Image to XPS Converter Command Line

  • You can download it to your computer and have a free trial then decide whether this software is good for you or not.
  • When downloading finishes, you will get a zip file. Please extract it to some folder then you can call it normally.
  • When you use this software, please refer to the usage and following examples.

Step 2. Convert image to XPS from C#

  • Here is the usage for your reference:img2xps.exe [options] <Image files> [XPS files]
  • When call it from C#, please refer to the following code template:
  • Make use of the PROCESS class available in SYSTEM.DIOGNOSTICS namaspace, use the following piece of code to execute the img2xps.exe file,
    ~~~~~~~~~~~~~~~~~
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;

    namespace ConsoleApplication1
    {
        class Program
    {
    static void Main(string[] args)
    {
    Process proc = new Process();
    proc.StartInfo.FileName = @"C:\\img2xps.exe";
    string strArguments = "";
    strArguments += " D:\\temp\\sample.tif D:\\temp\\out.xps";
    Console.WriteLine(strArguments);
    proc.StartInfo.Arguments = @strArguments;
    proc.Start();
    proc.WaitForExit();
    }
    }
    }
    ~~~~~~~~~~~~~~~~~

  • Here are some parameters for your reference:
  • -printer <string> : set printer name to create XPS file
    -paper <string>   : set paper size to XPS format
      auto   : retrieve paper size from image file
      number : standard paper size
      others : user defined paper size
    -xoffset <int>  : specify left offset for output image
    -yoffset <int>  : specify top offset for output image
    -width <int>    : specify width for output image
    -height <int>   : specify height for output image
    -getpagecount   : read page count from input image file
    -wtext <string> : set watermark on output XPS pages
    -wtype <int>    : type of watermark
      0 : normal watermark
      1 : watermark on header
      2 : watermark on footer
    -wf <string> : font name of watermark
    -wh <int> : font height of watermark
    -ww <int> : font width of watermark
    -wb : specify bold font
    -wi : specify an italic font
    -wu : specify an underlined font
    -ws : specify a strikeout font
    -wo <int> : opacity of watermark, from 0 to 100
    -wa <int> : angle of watermark
    -wc <string> : color of watermark,

During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!