> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/cli/pdf2xps/usage.md).

# Common examples of command-line PDF to XPS conversion

Convert PDF documents to XPS files with Apryse PDF2XPS, a command-line tool offering control over resolution and quality. Learn basic usage and various options for efficient file conversion. The Aprys

Apryse PDF2XPS is a command-line application designed to convert PDF documents to XPS files while presenting several options to control resolution and quality. This section covers the basic usage of PDF2XPS explaining all of the available options.

## Basic Syntax

The basic command-line syntax is:

`pdf2xps [options] file1 file2 folder1 file3 ...`

See more options in [Command-Line Summary](/cli/pdf2xps/cmd-options.md) for PDF2XPS

## General Usage Examples

### Example 1. The simplest command line: Convert PDF to XPS.

Notes:

* Converts 'my.pdf' to 'my.xps' located in the current working folder.

`pdf2xps my.pdf`

### Example 2. Convert PDF to Open XPS.

Notes:

* The '-o' (or --output) parameter is used to specify the output folder. If this option was not specified, all images would be stored in the current working folder.
* The --openxps parameter specifies that the output should be an Open XPS file.
* The '--verb' option instructs PDF2XPS to output more feedback in the console window.

`pdf2xps --openxps --verb 2 -o ex1 my.pdf`

### Example 3. Preserve maximum editability of source PDF document.

Notes:

* The --norender parameter is used to prevent selective rasterization of PDF pages that may not accurately map to XPS due to use of specific blend modes or other PDF features without a direct XPS equivalent. Individual graphical elements on the page (such as certain types of shadings may still be rasterized).
* The '-p' (or --pass) parameter is used to specify the password (i.e. 'my pass') required to open the encrypted document.

`pdf2xps --norender --pass "my pass" -o outdir my.pdf`

### Example 4. Batch convert PDF to XPS.

Notes:

* The --a (or '--pages') option instructs PDF2XPS to convert only the first two pages in all PDF documents stored under 'dir1' and 'dir2' folders.
* The '--subfolders' option is used to recursively process all PDF documents stored in subfolders of dir1 and dir2.

`pdf2xps -a 1-2 --subfolders dir1 dir2`

## Batch Processing and the Use of Wildcards

PDF2XPS supports processing of multiple input documents in the same run. For example, it is possible to specify multiple PDF folders and PDF2XPS will automatically process all PDF documents matching a given file extension. For example, the following command-line will process all PDF documents in folders 'test1' and 'test2'

`c:\> pdf2xps -o c:/output_folder c:/test1 c:/test2`

Wildcard characters can also be used to process multiple input files.

For example, if a directory contains the following PDF documents:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
C:\test1 >dir
 Directory of C:\test1
 01/04/2007 03:35 PM <DIR> .
 01/04/2007 03:35 PM <DIR> ..
 05/21/2004 02:27 PM A1.pdf
 05/03/2005 09:38 AM A2.pdf
 05/20/2003 08:46 AM B1.pdf
 05/15/2003 12:50 PM B2.pdf
```

{% endcode %}
{% endtab %}
{% endtabs %}

To process all PDF documents in this folder, you could specify:

`pdf2xps -o c:/output_folder c:/test1/*.pdf`

To process all PDF documents starting with 'A', you could specify:

`pdf2xps -o c:/output_folder c:/test1/A*.pdf`

Or to process all PDF documents ending with '1', you could specify:

`pdf2xps -o c:/output_folder c:/test1/*1.pdf`

You can use either of the two standard wildcards --- the question mark (?) and the asterisk (\*) --- to specify filename and path arguments on the command line.

The wildcards are expanded in the same manner as operating system commands. (Please refer to your operating system user's guide if you are unfamiliar with wildcards). Enclosing an argument in double quotation marks (" ") suppresses the wildcard expansion. Within quoted arguments, you can represent quotation marks literally by preceding the double-quotation-mark character with a backslash (**\\**). If no matches are found for the wildcard argument, the argument is passed literally.\\

**Exit Codes**

To provide additional feedback, PDF2XPS returns exit codes after completing processing. The exit codes can be used to provide user feedback, for logging etc. This is particularly important for applications running in an unattended environment.

The following table lists possible exit codes and their description:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
Exit Code       Description
--------------- ------------------------------------------------------------------
0               All files converted successfully.
1               Unspecified error.
2               Document is secured. Need a valid password to open the document.
3               Bad license key
4               Failed to create or write the output file or directory
5               Bad input filename or path
```

{% endcode %}
{% endtab %}
{% endtabs %}

All codes other than '0' indicate that there was an error during the conversion process.

The following illustrates a sample Windows batch script that processes exit codes:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
@echo off
rem convert all PDF files in 'data' folder
pdf2xps ./data
if errorlevel 1 goto othererror
if errorlevel 5 goto inputerr
if errorlevel 0 goto exit

:inputerr
echo No input files specified.
goto exit

:othererror
echo An error encountered during processing.
goto exit

:exit
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/cli/pdf2xps/usage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
