Command Line Interface

Installing groupdocs-parser-net also installs the groupdocs-parser command. It runs the same engine as the Python API, so you can pull text, metadata, images and annotations out of documents from a shell, a Make rule or a CI step without writing a script. If the Scripts (Windows) or bin (Linux, macOS) folder of your Python is not on PATH, run python -m groupdocs.parser instead; it takes the same arguments.

groupdocs-parser --version
groupdocs-parser 26.10.0

Commands

CommandWhat it does
text FILEPrints the text of the document, or of one page
info FILEPrints the format, extension, page count and size
metadata FILELists the metadata properties as name = value
images FILE --out DIRSaves the embedded images as image-001.png, image-002.jpeg, …
annotations FILELists the annotations (comments, notes) with their page, type and author
list-formatsLists every supported extension with its family and description

Run groupdocs-parser --help or groupdocs-parser <command> --help for the full list of flags.

Options

OptionCommandsMeaning
--page Ntext, images, annotationsOnly page N. Pages are counted from 1 on the command line; the Python API counts from 0
--format plain|markdown|htmltextPlain text (default), Markdown or HTML
--ocrtextRecognize the text of scanned pages and images (plain text only)
--include-annotationstextAdd the annotations’ text to the output (plain text only)
-o FILE, --output FILEtextWrite the text to a UTF-8 file instead of the console
--jsoninfo, metadata, annotationsPrint JSON instead of text
--out DIRimagesFolder for the extracted images; created if missing
--password PASSWORDevery command that opens a filePassword of a protected document
--license PATHall (before the command)Apply a license file first. Without it, GROUPDOCS_LIC_PATH is used if set

Examples

groupdocs-parser text report.pdf                        # plain text to the console
groupdocs-parser text report.pdf --page 2 -o page2.txt  # one page, to a UTF-8 file
groupdocs-parser text report.docx --format markdown     # Markdown, or html
groupdocs-parser text scan.pdf --ocr                    # recognize text in scanned pages
groupdocs-parser text reviewed.docx --include-annotations
groupdocs-parser info report.pdf --json                 # format, pages, size
groupdocs-parser metadata report.docx                   # name = value
groupdocs-parser images report.pdf --out images/        # writes image-001.png, ...
groupdocs-parser annotations reviewed.docx --json       # comments with page, author and time
groupdocs-parser list-formats                           # every supported extension and family

groupdocs-parser --license license.lic text protected.pdf --password secret

info on a two-page PDF prints:

format:    Portable Document Format File
extension: .pdf
pages:     2
size:      150567

and with --json:

{
  "format": "Portable Document Format File",
  "extension": ".pdf",
  "pages": 2,
  "size": 150567
}

list-formats prints one line per file type:

.7z      ARCHIVE          7z Archive File
.azw3    EBOOK            AZW3
.bmp     IMAGE            Bitmap Image File
.bz2     ARCHIVE          Bzip2 Archive File
.chm     EBOOK            Compiled HTML Help File
...

metadata, images and annotations print a count such as # 9 properties to standard error, so standard output carries only the data and can be piped.

Exit codes

CodeMeaning
0Success
2A user error: the file does not exist, or an option is wrong (for example --page 0)
1An engine error, or a format that does not support the operation (for example annotations on a spreadsheet)

Errors are printed to standard error as one line, for example error: no such file: missing.pdf. A protected document opened without --password adds the hint -- pass --password.

Licensing

Without a license the command runs in evaluation mode: text stops after about 20 lines and metadata returns the first 5 properties (see Licensing and evaluation limitations). Pass --license PATH or set the GROUPDOCS_LIC_PATH environment variable.

When to use Python instead

The command covers the common one-document tasks. Use the Python API for:

  • template-based parsing (parse_by_template) and form data (parse_form);
  • search, highlights, text areas, tables, hyperlinks, barcodes and the table of contents;
  • documents in memory (streams) and documents inside archives and emails (get_container);
  • logging and the external-resource handler (Logging, Handle loading of external resources);
  • processing many documents in one process: the first document a process opens takes 20-30 seconds while the engine loads, and every groupdocs-parser run is a new process.
Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.