Menu Close

Command Line Software for PDF Conversion

2PDF is a command line utility that converts popular office documents and images to the PDF or PDF/A format. It supports batch conversion and provides various options and parameters for optimal results. It can be used regularly or run continuously 24/7 using the command line interface.

With 2PDF, you can convert entire folders (including subfolders) and archives with files. It also allows you to select specific pages, delete source files, sort output files, handle attachments, and perform silent conversions without any alerts.

2PDF compatibility

2PDF can work through: 

  • Command-line application (cmd.exe, PowerShell)
  • Windows Task Scheduler
  • BAT (batch) file or VB script
  • your own software or existing source code

Supported Formats

2PDF supports a wide variety of 100+ types of documents and images (over 275 file extensions) as input files.

See all supported filetypes→

Batch convert to PDF from Command Line

Simple Command Line Syntax

Set up automated folder-to-folder file conversion using simple command line syntax. After opening the command-line application, type the basic command starting with 2PDF.exe. You can use 2PDF with Command Prompt, Windows PowerShell, Windows Terminal, or any similar command line interface.

Features Overview

Use different sources for files

2PDF allows various sources for files. Within a single command, you can specify the source for files: a file path, a folder path, a web address, or a list of files. You can even use multiple sources together! For example: -src "C:\In\*.*" "E:\Files\*.pdf" "@C:\Lists\list.txt"

The following types of sources are available:

  • Path to a single file
  • Folder path where files are located
  • List of files (TXT, XLS, XLSX, CSV)
  • Web address (URL)

See examples

Merge various files into multipage PDF files 

Using the -pdf switch, you can split and merge files into a multipage PDF. This way, you can create large documents by adding more pages to an existing PDF. 2PDF lets you combine files in different ways: append (add to the end), prepend (add to the beginning), keep files "as is", or split them.

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -pdf multipage:append combine:"my multipage.pdf"

Split multipage documents into pages or page ranges

If you set -pdf multipage:split in the command line, 2PDF would split documents into single pages. However, you can also split into separate files with a specified number of pages – via the -pdf split_step parameter. For example, file one: pages 1, 2, 3, file two: pages 4, 5, 6, file three: 7, 8, 9, and so on.

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -pdf multipage:split split_step:3

Read more about merging files to PDF

Rotate and auto-rotate PDF pages

Special parameters -oper autorotate and -oper rotate let you automatically or manually rotate pages within output PDFs. You can select page range, page orientation (portrait/landscape), rotation direction (clockwise or counterclockwise), and background color. 

Besides, you can set rotation or autorotation as a default setting for all files – by adding a Rotate or Auto rotate operation in 2PDF Settings (2pdf.exe -ini).

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper autorotate orientation:portrait direction:ccw

Watermark images and documents

Add watermark to each document page or specific pages using -oper watermark, -oper text annotation, or -oper textwatermark switches. You can set font and font-related options, text size (for text watermark or annotation), alignment, color, blending method, rotation, and more.

What's the difference between Text watermark and Text annotation?
Both of these operations have similar functionality. However, text annotation is newer and may work faster since it doesn't require re-rendering the content of PDF pages when inserting the text. If you're unsure which one to choose, we suggest using Text annotation.

Add a clickable URL to text or image watermark

You can add any web link (URL) to any watermark created by 2PDF. As a result, the watermark will be clickable in the output PDF file and will open the web page you specified. You can do it with the url parameter, for example, -oper textannotation url:https://www.mywebsite.com. This works for text watermark, text annotation, and image watermark.

Examples:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper watermark image:"C:\Watermark.png"

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper textannotation text:"Confidential" halign:left valign:top

Compress PDF file when converting Word files

Forget about an issue when a PDF is larger than the original Word document! Using 2PDF as a PDF compressor, you can save files to minimum size and reduce the size of output PDFs. This min_size feature works when converting DOC and DOCX files only. It can make the file size smaller approximately by 30-40% (depending on the document contents) without much loss in quality. 

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -pdf min_size:yes

Rasterize PDF pages to reduce file size

Additionally, you can optimize the file size of a PDF by rasterizing its pages into JPEG format. To do this, use the -oper rasterize command. This works with all types of source files that contain bitmap images.

Crop PDF pages automatically or manually

There are multiple ways to crop a document with 2PDF. One option is to manually set the size of page margins that need removal. Another option is to specify a rectangle in the center of the page that you want to keep, while cutting off everything else. Another option is to set up automatic cropping (-oper crop method:autocrop) which would remove margins based on color detection. In this case, you can configure parameters such as color sample and tolerance value.

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper crop method:margins left:10 top:5 right:10 bottom:5 units:mm

Create searchable PDF files with OCR

If you have raster (bitmap) images or document scans such as TIFF, PNG, JPEG, you can use 2PDF to recognize text. This way, you can create searchable PDF files. Built-in OCR component can be enabled by the parameter -pdf ocr. Different languages are available: English, French, German, Hebrew, Japanese, Russian, Spanish. Choose only those languages that are present in your input files. 

Please note that if your source files already contain text that can be selected, copied, etc., enabling the OCR feature is not needed. The original text will be preserved in the output PDF files by default.

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" ocr:yes ocr_lang:German

Batch Protect & Unlock Password-Protected PDF

2PDF can handle many password-protected files in bulk. Using the dstpwd parameter, you can make output files secured with a single password. 

If you have a bunch of password-protected PDF files and you want to remove the password from them, you can use srcpwd to unlock these secured PDF files. In the latter case, it is possible to unencrypt files with several passwords.

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -options dstpwd:123456

Add a rectangular frame to output PDF pages

Add a rectangular frame to output PDF pages

Using the -oper paint switch, you can add a rectangular frame to output PDF pages. Or, add a solid rectangle with or without a border. Both can be configured according to your needs. You can set: page range, "fill" or "draw" coloring mode, width and height, brush and pen color, thickness of the frame, background or foreground position, and more.

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -oper paint cmd:drawrect rect:"150 200 500 500" pen_color:"r:0,g:0,b:0,a:255" brush_color:"r:0,g:0,b:0,a:0" pen_width:4

Move, copy, or delete files automatically after conversion

Move, copy, or delete files automatically after conversion

Want to move, copy, or delete the source files after conversion? 2PDF has the -postproc switch for this job. It will automatically copy or move the original source files to a specified folder or delete them when the batch conversion session is complete.

This feature can be enabled both from the 2PDF Settings or command line syntax.

Example:

2PDF.exe -src "C:\In\*.*" -dst "C:\Out" -postproc passed:copy passed_dir:"C:\Done"

Add QR codes or barcodes to PDF

Add QR codes or barcodes to PDF

2PDF can automatically add a user-specified Barcode watermark to all or selected output PDF pages. Add QR Code, Code 128, Code 39, UPC-A, and other barcode types. For each barcode, you can adjust size, position, alignment, offset, page range, and other parameters. You can either enter values from a barcode generator or, for example, type any text that you wish to create a QR-code from.

This feature can be accessed from 2PDF Settings (2pdf.exe -ini) > Edit operations > Barcode watermark.

Configure default settings with GUI controls

Configure default settings with GUI controls

With the 2PDF Settings control panel, you can easily change the default settings of the program. This panel allows you to set up everything only once – so you won't need to add many switches & parameters to the command line every time.

To access 2PDF Settings, run the command:

2PDF.exe -ini

Save & load 2PDF Settings profiles

You have the option to save and load 2PDF Settings. This allows you to customize the program's behavior for specific tasks. To save or load settings, you can use the Export and Import buttons in the top menu.

Once you have a Settings file (.ini) saved on your computer, you can load it by clicking the Import button or include it in the command line using the -inipath switch.

What else you can do with 2PDF

Save any web page as PDF

2PDF can convert not only files, but web pages, too. To create a PDF from any web page (https://…), you just need to enter the URL address to be used as a source when setting the source switch.

Control processing of attachments

You can set the way of processing file attachments: place attachments before or after the main document, save the main document and its attachments as separate files or, for example, ignore attachments. If the attachments are "unknown", 2PDF can replace them with a placeholder.

Keep PDF bookmarks

Using the keep_bookmarks parameter, you can enable/disable keeping bookmarks of source files after conversion. By default, the bookmarks will remain the same as in the source files.

Use source file names as PDF bookmarks

You can optionally use source file names as PDF bookmarks so that you can navigate to different sections named as source files inside the merged PDF. To do it, find the New file bookmarks title template in 2PDF Settings and set it to {srcfilename}.{srcfileext}.

Remove blank pages automatically

2PDF allows you to automatically remove blank pages before conversion to PDF (-oper removeblankpages) if they are not necessary. You can additionally set up page range, pixel threshold and channel threshold to detect blank pages.

Embed ICC color profile when processing image files

If you want to maintain the most accurate color representation for your image files, you can include the path to your ICC profile (-fls iccprofile) and it will be applied during the processing.

Run several commands sequentially

With the -cmdlines switch, 2PDF can execute multiple commands consecutively. To utilize this feature, create a TXT file containing the desired commands, each on a separate line.

Convert Word, Outlook, and Excel files without Microsoft Office installed

Though some file types require additional software, 2PDF can convert most of them on its own. For example, it can handle popular Office documents using the internal engine only: Excel XLS, XLSX files, Word DOC, DOCX, RTF files, Outlook MSG, EML files.

Q&A

How to convert files using the default settings?

  1. Download and install 2PDF
  2. Use Win+R hotkey or click Start button on the bottom-left corner of your Windows Desktop
  3. Type cmd to open the Command Prompt and press Enter
  4. Enter the command line:
    2PDF.exe -src "C:\Input\*.*" -dst "C:\Output"
  5. Press Enter

For more options, please see the complete description of 2PDF syntax and examples.

How to start 2PDF from a VB Script?

  1. Open Notepad and create a new text file in it
  2. Enter Visual Basic Script code like this:
    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run """2PDF.exe"" -src ""C:\In\*.*"" -dst ""C:\Out""", 1, True
    Set objShell = Nothing
  3. Save this file as a Unicode text file. For example: Test.txt
  4. Rename Test.txt file to Test.vbs
  5. Double click Test.vbs file to start the conversion

How to install 2PDF silently?

Download the installation file and save it on your hard drive. Run this command line to silently install the trial version of 2PDF:

"C:\Distr\2PDF-trial-setup.exe" /SILENT

Add a serial number to the command line to install the commercial version of 2PDF silently:

"C:\Distr\2PDF30-commerc-setup.exe" /SILENT /SN=AAAAAA-BBBBBB-CCCCCC-DDDDDD

I need a certain feature. Can you help? 

We continuously improve our products based on your suggestions. Please send us your feature requests, any feedback, or ask questions via the contact page.