The 2PDF Command Line Syntax and Examples page shows the conversion settings that you can specify to adjust your file conversion with 2PDF. The command line syntax parameters determine how files are converted as well as the structure and features of resultant PDF documents.
- Quick start
- Command line structure
- Switches
- Advanced settings
- Examples
Quick start
- Press Win+R on your keyboard, type cmd and click OK to open the Command Prompt (CMD).
- To call 2PDF, type in 2PDF.exe and press Enter. You can get an entire list of available operations and options by using this command line:
2PDF.exe
- The command lines have arguments with values, which are typed after the command itself. In general, the basic syntax is as follows:
2PDF.exe -src "C:\In\*.*" -dst "C:\Out"
- -src should be followed by the source folder path with files to be converted or path to input file;
- Asterisk (star, *) is a wildcard character which stands for any string of characters (or no characters at all). *.* stands for any filename – point – any file extension;
- -dst should be followed by the destination folder path for output files;
- When specifying the source folder path (or source file) and destination path (output folder) – enclose them in double quotation marks. Example: -src "C:\Incoming files\For conversion\Invoice.docx".
- Press Enter to execute the command.
Command line structure
The basic command line structure sets the source for files and the destination path. After them you can add optional parameters for output PDF files such as file structure, handling attachments, page autorotation, and more.
2PDF command line structure looks like:
2PDF.exe -<switch1> [param1:value paramN:value] -<switchN> [parameters]

Switches
Use switches -src and -dst to set source for input files and output destination for converted files. You can also:
- Rotate document pages using -oper autorotate, -oper rotate switches;
- Add a watermark using -oper textwatermark or -oper watermark switches;
- Move, copy, or delete source files with -postproc switch;
- Set common parameters with -options and -pdf switches.
Switch | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
-src | Sets a location of files that should be converted.
| ||||||||||
-dst | Sets the destination folder for the output PDF file(s). Example: -dst "C:\Output" | ||||||||||
-options | Sets up file processing and common 2PDF options. | ||||||||||
Sets PDF format options, such as multipage or OCR. | |||||||||||
-oper autorotate | Sets landscape or portrait orientation for output files. | ||||||||||
-oper rotate | Rotates document pages at a specific angle. | ||||||||||
-oper textwatermark | Adds a text watermark to document pages. | ||||||||||
-oper watermark | Adds an image watermark to document pages. | ||||||||||
-postproc | Performs additional post-processing actions: copy, move, or delete source or output files | ||||||||||
-about | Shows license key and software version. Example: 2PDF.exe -about | ||||||||||
cmdline | Allows to run the 2PDF command from a TXT file. Example: 2PDF.exe -cmdline "C:\Scripts\Command.txt" |
Common options (-options)
General file conversion options are controlled by the -options switch. Values that are marked bold below are set by default.
-options
Parameter | Description | Value (values in bold are set by default) |
---|---|---|
pages: | Set page range. Example: -options pages:1,3,5-12 | all |
scansf: | Convert files within subfolders too (if you specify a folder as a source) | yes, no |
keepsf: | Keep the same subfolder structure as in the input folder (if you specify a folder as a source) | yes, no |
mswildc: |
Enable/disable Microsoft DOS/Win32 wildcard matching algorithm. This algorithm is a bit different from the "expected" behavior, since some wildcards work in a different way in Windows (compared to Linux, for example). Suppose, you want to convert DOC files only. It would seem that you should just use this command: 2PDF.exe -src "C:\In\*.doc" But as a result, both .DOC and .DOCX files will be converted, which is not needed. To convert only files that match the specified file extension, disable the Microsoft wildcard matching algorithm. To do that, use the command: 2PDF.exe -src "C:\In\*.doc" -options mswildc:no | yes, no |
overwrite: | Overwrite existing files or skip them | no, yes, skip |
break_on_error: | Break on error (stop the program in case of an error) | no, yes |
template: |
Adjust output file name template. You can enter your own file name and/or use macros:
By default, the page counter ({*SrcFileMPageNo}) appears only for multipage files split into pages. Example: | {*SrcFilename}{*WorksheetName}{*SrcFileMPageNo}.{*DstFileExt} |
srcpwd: |
Input password for the source file or files (if they are password-protected). Example: -options srcpwd:123456 If a password contains spaces, input it between double quotation marks. Example: -options srcpwd:"my password" If you have files secured with more than one password, you can enter multiple passwords too (the order is not important). Example: -options srcpwd:password1 srcpwd:password2 srcpwd:password3 | Enter password(s) for source file(s) |
dstpwd: | You can password-protect output PDF files. This way, you can protect one or multiple files at once with a single password. Only a single password can be used within a command. Example: -options dstpwd:123456 | Enter password for output file(s) |
res: | Change rasterization resolution (DPI) of the output files. This parameter may need changing only when the OCR feature is used which results in file's rasterization. The default value is 300 which is good for most scenarios, but you can change it for your needs. The rasterization resolution can be set within the range of 72-4096. | 300 |
attachments: | Set processing of file attachments. Attachments can be saved separately, ignored or combined with the file (append or prepend). Besides, you can convert attachments only, without the file(s). | ignore, separate, onlyatt, combine, combine_prepend |
sort: | Sort output files. Can be sorted by different parameters like name, date, file type, and more. To sort the files in descending order, use values ending with _d (name_d, date_d, etc.). | unsorted, name, date, type, size, path, name_d, date_d, type_d, size_d, path_d |
silent: | Suppress console output – do not show the conversion process and convert silently | no, yes |
alerts: | Display alert windows | yes, no |
fast_combine: | Set the number of files to quickly create a multipage PDF from them. Greatly increases file processing speed. Works with PDFs as source files only. The number of files is unlimited. Example: -options fast_combine:10000 | Enter the number of source files |
user: | Enter username (login) for converting a web page – when URL is set as a source and if password entry is required to access the web page. Don't forget to specify both credentials – user and password. | Enter username (login) |
password: | Enter password if password entry is required to access the web page you want to print (URL is set as a source). Don't forget to specify both credentials – user and password. | Enter password |
Example:
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -pdf multipage:split -options pages:"1,3,5-10" scansf:yes keepsf:no overwrite:yes template:"{*SrcFilename}{*SrcFileMPageNo}.{*DstFileExt}" sort:name attachments:combine dstpwd:123456 delsrc:yes silent:yes
In this example we also use -pdf multipage: split described in further section so that template:"{*SrcFilename}{*SrcFileMPageNo}.{*DstFileExt}" could take effect.
PDF format parameters for converted files (-pdf)
You can control different parameters related to the PDF format using the -pdf switch.
Parameter | Description | Value (values in bold are set by default) |
---|---|---|
filever: | Select PDF version for output files | 1.3, 1.4, 1.5, 1.6, 1.7 |
pdf_a: | Convert to PDF/A. This feature works for .doc and .docx as source files. | no, yes |
min_size: | Compress output PDF to minimize the file size. This feature works for .doc and .docx as source files. | no, yes |
multipage: | Create a multipage PDF. Possible options:
| asis, split, append, prepend |
combine: | Set file name for a combined multipage file. If you want to set a filename with spaces, type it within double quotation marks. Example: -pdf multipage:append combine:"my multipage.pdf" | Combined.pdf |
ocr: | Create searchable PDF using built-in OCR | no, yes |
ocr_lang: | Select language available for text recognition via OCR. By default, it is English. Other options: German, French, Hebrew, Japanese, Russian, Spanish. You can select more than one, if your documents are in several languages. Example: -pdf ocr_lang:English ocr_lang:German | English German French Hebrew Japanese Russian Spanish |
split_step: | Split multipage documents by page ranges. By default, multipage documents are split into single pages. But you can change the number of pages, for example, to 3, which will create:
| 1 |
keep_bookmarks: | Detect bookmarks that are present in the source files (usually PDFs) and display them in the output converted files. | yes, no |
Example:
2PDF.exe -src "C:\In\*.docx" -dst "C:\Out" -pdf pdf_a:yes min_size:yes multipage:append combine:my-multipage.pdf ocr:yes ocr_lang:English
Operations (-oper)
You can use additional operations and options for output PDFs, such as applying a text or image watermark, page rotation, and more. Below is a list of switches and their parameters.
Page autorotation (-oper autorotate)
The program recognizes the layout of input files and can set their page orientation according to the specified parameters. Use this switch if you want to make document pages or images landscape or portrait automatically.
-oper autorotate
Parameter | Description | Value (values in bold are set by default) |
---|---|---|
pages: | Select pages that need to be rotated automatically, for example "1,3,5-12" | all |
orientation: | Set page or image orientation (portrait, landscape). Once enabled, this option will apply portrait or landscape orientation to all files | portrait, landscape |
direction: | Set auto rotation direction (clockwise or counterclockwise) | ccw, cw |
Example:
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper autorotate orientation:portrait direction:ccw
Page rotation (-oper rotate)
Use this switch to rotate document pages or images.
-oper rotate
Parameter | Description | Value (values in bold are set by default) |
---|---|---|
pages: | Select pages that need to be rotated automatically, for example "1,3,5-12" | all |
angle: | Set angle of rotation. Please note that you can use only right or straight angles (90, 180, 270) | 0 |
direction: | Set direction for page rotation (clockwise or counterclockwise) | ccw, cw |
color: | Set background color using RGB color model – "r:(0-255),g:(0-255),b:(0-255)" | r:255,g:255,b:255 |
Example:
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper rotate angle:90 direction:cw color:"r:0,g:128,b:0"
Text watermark (-oper textwatermark)
Use this switch to add text as a watermark. You can fully customize it by selecting the right font, size, color, angle, and positioning.
-oper textwatermark
Parameter | Description | Value (values in bold are set by default) |
---|---|---|
pages: | Set page range for the watermark. Example: pages:"1,3,5-12" | all |
text: | Input watermark text.Example: "Confidential" | Type any text |
url: | Enter a URL for the watermark. You can add a clickable web link to the text watermark | Enter URL |
font: | Set font name, the default font is Arial. Example: Verdana | Arial |
fontsize: | Set font size. Example: fontsize:16 | 12 |
fs_units: | Set font size units: points, percents (percent of image height) | points, percents |
bold: | Make font bold | no, yes |
italic: | Make font italic | no, yes |
underline: | Make font underlined | no, yes |
halign: | Set horizontal alignment | left, center, right |
valign: | Set vertical alignment | top, center, bottom |
units: | Set horizontal and vertical offset units | pixels, percents |
offx: | Set horizontal offset value (points) | 0 |
offy: | Set vertical offset value (points) | 0 |
color: | Set text color using RGB color model – "r:(0-255),g:(0-255),b:(0-255)".Example: "r:0,g:128,b:0,a:255" | "r:0,g:0,b:0,a:255" |
bgcolor: | Set text background color using RGB color model – "r:(0-255),g:(0-255),b:(0-255)".Example: "r:0,g:255,b:0,a:128" | "r:255,g:255,b:0,a:255" |
angle: | Set angle of rotation in degrees (0-360) | 0 |
direction: | Set direction for watermark rotation (clockwise or counterclockwise) | ccw, cw |
border: | Draw border | no, yes |
fit: | Fit into image | no, yes |
method: | Set a blending method for watermark – AlphaBlend or Overdraw | alphablend, overdraw |
zorder: | Change z-order. You can insert the watermark behind (background) or in front (foreground) of the document's contents. | foreground, background |
Example:
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper textwatermark pages:"1,3-5,12" text:"(C) John Smith" font:"Verdana" fontsize:15 bold:yes italic:yes underline:yes halign:center valign:center offx:10 offy:15 color:"r:255,g:0,b:0,a:128" bgcolor:"r:0,g:255,b:0,a:128" angle:45 border:yes
Image watermark (-oper watermark)
Use this switch to place an image as a watermark. You can set a path to an image of a common format (PNG, JPG, BMP, GIF) and customize the watermark's parameters like size, positioning, and overlay method.
-oper watermark
Parameter | Description | Value (values in bold are set by default) |
---|---|---|
pages: | Set page range for the watermark. Example: pages:"1,3,5-12" | all |
image: | Set path to watermark image. Example: image:"C:\Watermark.png" | |
url: | Enter a URL for the watermark. You can add a clickable web link to the text watermark | Enter URL |
halign: | Set horizontal alignment | left, center, right |
valign: | Set vertical alignment | top, center, bottom |
offx: | Set horizontal offset value (points) | 0 |
offy: | Set vertical offset value (points) | 0 |
size: | Set watermark size as a percent of page width and height. It is possible to set original image size (as is) | -1, as is |
angle: | Set angle of rotation, by default it is 0° | 0 |
direction: | Set direction of rotation: clockwise or counterclockwise | ccw, cw |
method: | Set a blending method for watermark – AlphaBlend or Overdraw | alphablend, overdraw |
zorder: | Change z-order. You can insert the watermark behind (background) or in front (foreground) of the document's contents. | foreground, background |
Example:
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper watermark pages:"1,3-5" image:"C:\my logo.png" halign:right valign:top offx:10 offy:15
Draw rectangle (-oper paint)
Use the -paint switch to draw a rectangular border around the content of the output pages.
-oper paint
Parameter | Description | Value (values in bold are set by default) |
---|---|---|
pages: | Set page range for this operation. Example: pages:"1,3,5-12" | all |
cmd: | Select rectangle application: fill or draw | fillrect, drawrect |
rect: | Set rectangle dimensions in the format: "x0 y0 width height" | "0 0 -1 -1" |
pen_color: | Set draw color in the format: "r:(0-255),g:(0-255),b:(0-255),a:(0-255)" | "r:0,g:0,b:0,a:255" |
brush_color: | Set fill color in the format:"r:(0-255),g:(0-255),b:(0-255),a:(0-255)" | "r:255,g:255,b:255,a:255" |
pen_width: | Set thickness of rectangle's frame | 1 |
units: | Set draw units: pixels or percents | pixels, percents |
zorder: | Change z-order. You can insert the rectangle in the background or in the foreground of the document's contents. | foreground, background |
Post-processing actions (-postproc)
Use the -postproc switch to сopy, move, or delete files automatically after processing, if necessary.
-postproc
Parameter | Description | Value (values in bold are set by default) |
---|---|---|
passed: | Select action for successfully converted files: copy, move, or delete | none, copy, move, delete |
passed_dir: | Specify a folder where successfully convert files should be moved or copied to. For example:-postproc passed:copy passed_dir:"C:\Converted" | Enter path to folder |
passed_delsf: | Delete empty unused subfolders from the source folder | no, yes |
failed: | Select action to be performed with files that were not converted: do nothing, copy/move to another folder, or delete | none, copy, move, delete |
failed_dir: | Select action for files that failed to convert. For example:-postproc failed:move failed_dir:"C:\Failed" | Enter path to folder |
output: | Select action for output files: keep all, delete failed, or delete all if at least one failed | keep, delete, delete_all |
Advanced settings
The default settings are available in the editor with GUI controls. To access it, use this command:
2PDF.exe -ini
The Advanced Settings are the default settings of the program. So you can set up everything only once, and they will be applied every time you use 2PDF. If you are not sure about a specific setting, please contact our support for assistance.
Examples
Convert to PDF all files from folder "C:\In" with all subfolders
2PDF.exe -src "C:\In\*.*" -dst "C:\Out"
Combine all files from folder "C:\In" to a single multipage PDF file
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -pdf multipage:append combine:"my multipage.pdf"
Convert all files from folder "C:\In" to searchable PDF
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -pdf ocr:yes ocr_lang:English
Convert to PDF all files, listed in a text file "C:\tests\list.txt"
2PDF.exe -src "@C:\tests\list.txt" -dst "C:\Out"
Quickly combine a large number of PDFs (10000 files) from folder "C:\In" and save the output file as "C:\Out\output.pdf"
2pdf.exe -src "C:\in\*.pdf" -dst "C:\Out" -pdf multipage:append combine:"output.pdf" -options fast_combine:10000
Split multipage files into separate PDF pages
2pdf.exe -src "C:\in\*.*" -dst "C:\Out" -pdf multipage:split
Password-protect multiple documents (batch lock files)
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -options dstpwd:password
password – enter a password which will be applied to all source files
Remove password from multiple secured documents (batch unlock files)
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -options srcpwd:password1 srcpwd:password2 srcpwd:password3
password1, password2, password3 – if, e.g., files within a folder have 3 different passwords
Combine emails with attachment(s) to PDFs and keep the original file name
2PDF.exe -src "C:\Emails\*.*" -dst "C:\Out" -pdf multipage:append combine:{containername}.pdf