Menu Close

Command Line Syntax and Examples

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

1. Press “Win+R” on your keyboard, type cmd and click OK to open the Command Prompt (CMD).

2. 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 -help

3. 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 options

The basic command line structure is setting the source and the destination paths and adding optional parameters using -oper and -options attributes.

Switches

-src The source path to a file or files within a folder that should be converted. Can contain a search mask (to allow processing any files use *.*). Example: 
2PDF.exe -src “C:\Incoming\Overview.docx” -dst “C:\Output”
2PDF.exe -src “C:\Incoming\*.*” -dst “C:\Output”

If you have a list of files to convert, it should be saved as a text file. To set a list of files as a source, use @ before the file path. Example: 
2PDF.exe -src “@C:\Incoming\list.txt” -dst “C:\Output”
-dst The destination folder for the output PDF file(s). Example: 
2PDF.exe -src “C:\Incoming\*.*” -dst “C:\Output”
-oper Operation attribute which determines parameters applied to the files. Refers to the section <Operations>
-options Option attribute which determines common 2PDF options. Refers to the section <Common options>
-about View license key and software version. Example:
2PDF.exe -about

Common options

To use these options, don’t forget to add -options before one or several following attributes. Options which are marked bold below are set by default (if the feature is enabled).

Attribute Description Options*
pages:  Set page range, for example, pages:1,3,5-12 all, 1,3,5-12
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
overwrite: Overwrite existing files or skip them no, yes, skip
delsrc: Delete source files no, yes
keep_outfile: Keep the output file in case of an error yes, no
break_on_error: Break on error (stop the program in case of an error) no, yes
template: Add output file name template. By default, page counter appears only for multipage files.
*SFNAME* – source file name
*WSNAME* – worksheet file name (for Excel and CAD files only)
*SFMPAGENO* – source file page number
*DFEXT* – destination file extension
*SFNAME**WSNAME**SFMPAGENO*.*DFEXT*
srcpwd: Input password for the source file or files (if they are password-protected). Example: srcpwd:123456

If the input folder contains several files secured with different passwords, you can specify them too, each attribute and value separated by space. Example: srcpwd:password1 srcpwd:password2 srcpwd:password3
(The order is not important)

Please note: this option unlocks secure files – it removes the source files’ password protection.
Enter password(s) for source file(s)
dstpwd: Input password for the destination file or files to password-protect them. This way, you can protect one or multiple files at once with a password. Only a single password can be used for each command. Example:
dstpwd:123456
Enter password for output file(s)
attachments:  Set processing of file attachments. Can be saved separately, ignored or combined with the file itself separate, ignore, combine
sort: Sort output files. Can be sorted by different parameters like name, date, file type, and more 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

Formats

To use these options, don’t forget to add -pdf before one or several following attributes.

pdf_a: Convert to PDF/A no, yes
min_size: Compress output PDF to minimize the file size no, yes
multipage: Create a multipage PDF. Possible options:
– as is – keeps the original file structure
– split – splits multipage files into separate PDF pages
– append – adds new files as pages to the end
– prepend – adds new files as pages to the beginning
asis, split, append, prepend
combine: Set file name for a combined multipage file combined.pdf, mymultipage.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, Hebrew, Japanese, Russian, Spanish, German Fraktur. You can select more than one, if your documents are in several languages, e.g., ocr_lang: 24,20 24 = English
20 = German
40 = Hebrew
50 = Japanese
79 = Russian
85 = Spanish
21 = German Fraktur

Operations

To use these options, don’t forget to add -auto_rotate, -rotate, -textwatermark, or -watermark before one or several following parameters.

Page autorotation parameters

-auto_rotate

orientation: Set page or image orientation (portrait, landscape). Once enabled, this option will apply portrait or landscape orientation to all filesportrait, landscape
direction: Set rotation direction (clockwise or counterclockwise)ccw, cw

Page rotation parameters

-rotate

angle:Set angle of rotation (0-360°)0, 45
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

Text watermark parameters

-textwatermark

pages:Set page range for the watermark, for example, 1,3,5-12all, 1,3,5-12
text: Input watermark textType any text
font: Set font name, the default font is ArialArial, Tahoma
fontsize: Set font size12
fs_units:Set font size units: points, percents (percent of image height)points
bold: Make font boldno, yes
italic: Make font italicno, yes
underline:Make font underlinedno, yes
halign:Set horizontal alignmentleft, center, right
valign:Set vertical alignmenttop, center, bottom
units:Set horizontal and vertical offset units pixels, percents
offx:Set horizontal offset value0, 30
offy:Set vertical offset value0, 30
color:Set text color using RGB color model – “r:(0-255),g:(0-255),b:(0-255)”“r:0,g:0,b:0,a:255”, “r:10,g:20,b:0,a:255”
bkcolor:Set text background color using RGB color model – “r:(0-255),g:(0-255),b:(0-255)”“r:255,g:255,b:0,a:255”, “r:10,g:20,b:0,a:255”
angle:Set angle of rotation (0-360°)0, 30
direction:Set direction for watermark rotation (clockwise or counterclockwise)ccw, cw
border:Draw borderno, yes
fit:Fit into image no, yes
method:Set a blending method for watermark – AlphaBlend or Overdrawalphablend, overdraw

Image watermark parameters

-watermark

pages:Set page range for the watermark, for example, “1,3,5-12”all, 1,3,5-12
image:Set path to watermark image e.g., “C:\Watermark.png”
halign:Set horizontal alignmentleft, center, right
valign:Set vertical alignmenttop, center, bottom
units:Set horizontal and vertical offset units pixels, percents
offx:Set horizontal offset value0, 30
offy:Set vertical offset value0, 30
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
method:Set a blending method for watermark – AlphaBlend or Overdrawalphablend, overdraw

*Options marked bold are set by default (if the feature is enabled)

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:En

Convert to PDF all files, listed in a text file “C:\tests\list.txt”

2PDF.exe -src “@C:\tests\list.txt” -dst “C:\Out”

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