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.
Contents
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".
4. Press Enter to execute the command.
Command line options
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 and output destination for converted files. You can also rotate document pages using -oper autorotate, -oper rotate; add a watermark using -oper textwatermark and -oper watermark switches. Use -options to set common parameters.
Switch | Description |
-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" |
Sets PDF format options, such as multipage and 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. |
-options | Sets up file processing and common 2PDF options. |
-about | Shows license key and software version. Example: 2PDF.exe -about |
Common options with parameters
General file conversion options are controlled by the -options switch.Values that are marked bold below are set by default.
-options
Attribute | Description | Value (values in bold are set by default) |
pages: | Set page range. Example: 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 |
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 split into pages. {*SrcFilename} – source file name; {*WorksheetName} – worksheet file name (for Excel and CAD files only); {*SrcFileMPageNo} – source file page number; {*DstFileExt} – destination file extension. Example: template:"Document-{*SrcFileMPageNo}.{*DstFileExt} | "{*SrcFilename}{*WorksheetName}{*SrcFileMPageNo}.{*DstFileExt}" |
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 and 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 |
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: fast_combine:10000 |
Enter the number of source files |
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
You can control different parameters related to the PDF format using the -pdf switch.
Attribute | Description | Value (values in bold are set by default) |
pdf_a: | Convert to PDF/A | no, yes |
min_size: | Compress output PDF to minimize the file size. This feature works for .doc and .docx files. | 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 fileIf you want to set a filename with spaces, type it within double quotation marks. Example: "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: ocr_lang:English, ocr_lang:German | English German French Hebrew Japanese Russian Spanish |
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
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 attributes.
Page autorotation parameters
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
Attribute | Description | Value (values in bold are set by default) |
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 rotation direction (clockwise or counterclockwise) | ccw, cw |
Example:
2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper autorotate orientation:portrait direction:ccw
Page rotation parameters
Use this switch to rotate document pages or images.
-oper rotate
Attribute | Description | Value (values in bold are set by default) |
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 parameters
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
Attribute | Description | Value (values in bold are set by default) |
pages: | Set page range for the watermark. Example: 1,3,5-12 | all |
text: | Input watermark text. Example: "Top secret" | Type any text |
font: | Set font name, the default font is Arial. Example: Verdana | Arial |
fontsize: | Set font size. Example: 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 |
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 parameters
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
Attribute | Description | Value (values in bold are set by default) |
pages: | Set page range for the watermark. Example, "1,3,5-12" | all |
image: | Set path to watermark image. Example: "C:\Watermark.png" | |
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 |
method: | Set a blending method for watermark – AlphaBlend or Overdraw | alphablend, overdraw |
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
Advanced settings
Some advanced settings are available in the Ini File Editor. To access it, use this command:
2PDF.exe -ini
Use it with caution! Changing these settings may affect 2PDF's stability and performance. You should only change them if you are sure of what you are doing. If you are not sure, 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"
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