Tutorial

Sejda shell interface tutorial

Contents

Requirements

The shell interface requires Java runtime 1.5 or older to be installed. It works on Linux, Windows and Mac.

Running the shell interface

After you dowloaded the sejda-console binaries and extracted the files, you should have the following directory structure:

./lib
./lib/[...].jar
./bin
./bin/sejda-console.bat
./bin/sejda-console
./etc
./etc/logback.xml

On linux and mac you might have to grant execution permission for the executable file first:

chmod +x bin/sejda-console

To run the console, simply execute the binary file in /bin folder. Choose the binary executable depending on your platform: windows – sejda-console.bat, linux and mac – sejda-console.

./bin/sejda-console

Detailed instructions can be found in this video tutorial.

Available commands

To list the available commands, run the console without any parameters, or with -h option.

> ./bin/sejda-console
16:32:55.534 Configuring Sejda 0.0.1-SNAPSHOT
16:32:56.094 Sejda Console

Basic commands:

 alternatemix         Given two pdf documents, creates a single output pdf
                      document taking pages alternatively from the two input.
                      Pages can be taken in straight or reverse order and using a
                      configurable step (number of pages before the process switch
                      from a document to the other).

 crop                 Given a pdf document and a set of rectangular boxes, creates
                      a single output pdf document where pages are cropped
                      according to the input rectangular boxes. Input boxes are
                      set as mediabox and cropbox on the resulting document pages
                      (see Pdf reference 1.7, chapter 3.6.2, TABLE 3.27).
                      Resulting document will have a number of pages that is the
                      the number of pages of the original document multiplied by
                      the number of rectangular boxes.

 decrypt              Given a collection of encrypted pdf documents and their
                      owner password, creates a decrypted version of each of them.

 encrypt              Given a collection of pdf documents, applies the selected
                      permission using the selected encryption algorithm and the
                      provided owner and user password.

 extractpages         Extract pages from a pdf document creating a new one
                      containing only the selected pages. Page selection can be
                      done using a predefined set of pages (odd, even) or as a set
                      of ranges (from page x to y).

 extracttext          Given a collection of pdf documents, creates a collection of
                      text files containing text extracted from them.

 merge                Given a collection of pdf documents, creates a single output
                      pdf document composed by the selected pages of each input
                      document taken in the given order.

 pdftomultipletiff    Converts a pdf document to multiple TIFF images (one image
                      per page).

 pdftosingletiff      Converts a pdf document to a single TIFF image (TIFF format
                      supports multiple images written to a single file).

 rotate               Apply page rotation to a collection of pdf documents.
                      Rotation can be applied to a specified set of pages or to a
                      predefined set (all, even pages, odd pages)

 setmetadata          Apply new metadata (title, author, subject, keywords) to an
                      input pdf document.

 setpagelabels        Given a collection of pdf documents, applies the selected
                      page labels as defined in the Pdf reference 1.7, chapter
                      8.3.1.

 setpagetransitions   Given a pdf document, applies the selected pages transitions
                      (to use the document as a slide show presentation) as
                      defined in the Pdf reference 1.7, chapter 8.3.3.

 setviewerpreferences Given a collection of pdf documents, applies the selected
                      viewer preferences.

 simplesplit          Splits a given pdf document at a predefined set of page
                      numbers (all, odd pages, even pages).

 splitbybookmarks     Splits a given pdf document at pages where exists a GoTo
                      action in the document outline (bookmarks) at the specified
                      level (optionally matching a provided regular expression), 

 splitbypages         Splits a given pdf document at a selected set of page
                      numbers.

 splitbysize          Splits a given pdf document in files of the selected size
                      (roughly).

 unpack               Unpacks all the attachments of a given collection of pdf
                      documents.

Use "sejda-console <command> -h" for help regarding a specific command

Command specific options

To get more details regarding one specific command, run sejda-console -h <command>

> ./bin/sejda-console -h decrypt
16:36:13.975 Configuring Sejda 0.0.1-SNAPSHOT
16:36:14.243 Given a collection of encrypted pdf documents and their owner password, creates a decrypted version of each of them.

Example usage: sejda-console decrypt -f /tmp/file1.pdf:secret123 -o /tmp -p decrypted_

Usage: sejda-console decrypt options
	[--compressed] : compress output file (optional)
	--files -f value... : pdf files to operate on: a list of existing pdf files (EX. -f /tmp/file1.pdf -f /tmp/password_protected_file2.pdf;secret123) (required)
	[--help -h] : prints usage information. Can be used to detail options for a command '-h command' (optional)
	--output -o value : output directory (required)
	--outputPrefix -p value : prefix for the output files name (optional)
	[--overwrite] : overwrite existing output file (optional)
	--pdfVersion -v value : pdf version of the output document/s {2, 3, 4, 5, 6 or 7}. Default is 6. (optional)

Configuring custom logging

By default, the sejda-console logs to STDOUT on level INFO.

Logging settings can be changed by editing the etc/logback.xml file

For example, in order to turn off logging completely, simply comment out the STDOUT appender

<root level="INFO">
	<!-- <appender-ref ref="STDOUT" /> -->
	<!-- <appender-ref ref="FILE" /> -->
</root>

Inside the logback.xml file there is an (commented out) example on how to configure the logging to a log file instead of STDOUT.

Configuring memory arguments

By default, the shell interface is configured to use 256Mb memory. If you encounter an OutOfMemoryError you can configure a higher value than the provided default.

On Linux/Mac edit bin/sejda-console

EXTRA_JVM_ARGUMENTS="-Xmx256M"

On Windows edit bin/sejda-console.bat

set EXTRA_JVM_ARGUMENTS=-Xmx256M