In this article, I will show you how to convert PDF to XPS and specify conversion page range from C# code template. The software I use is named as VeryDOC PDF to Vector Converter, which is a professional tool for converting PDF files to vector image no matter in batch or singly. As command line software, you can call it together with any programming languages such as Visual Basic, C/C++, Delphi, ASP, PHP, C#, .NET, etc. If you need to use DLL Library for further developing, there is also COM version available for you. Please check more detail information of this software on homepage, in the following part, let us check how to use this software.
Step 1. Free trial PDF to Vector Converter Command Line
- Here I will take the command line version for example. If you need to use the COM developer version, please download from corresponding downloading link.
- When downloading finishes, there will be a zip file. Please extract it to some folder then you can check help document, executable file and other files.
Step 2. Convert PDF to XPS and specify conversion page range from C#.
- When you use this software, please refer to the usage and examples.
- Here is the usage for your reference:pdf2vec.exe [options] [Options] <PDF Files>
- By this software, you can not only specify conversion page range, but also specify other limitations. Please check related functions from the following parameters.
- Now let us check how to call this software from C# for converting PDF to XPS.
-firstpage <int> : first page to print, from 1 to max page
-lastpage <int> : last page to print, from 1 to max page
-scale <int> : specify the factor by which the printed output is to be scaled, The apparent page size is scaled from the physical page size by a factor of scale/100. This option is available for PCL, HPGL, XPS, PS and EPS formats.
Make use of the PROCESS class available in SYSTEM.DIOGNOSTICS namaspace, use the following piece of code to execute the pdf2vec.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:\\pdf2vec.exe";
string strArguments = "";
strArguments += "—firstpage 1 –lastpage 2";
strArguments += " D:\\temp\\sample.pdf D:\\temp\\out.xps";
Console.WriteLine(strArguments);
proc.StartInfo.Arguments = @strArguments;
proc.Start();
proc.WaitForExit();
}
}
}
~~~~~~~~~~~~~~~~~
During the using, if you have any question, please contact us as soon as possible.