-
Notifications
You must be signed in to change notification settings - Fork 67
Getting Started
Andrea Vacondio edited this page Jan 20, 2020
·
20 revisions
# Install a Java Runtime Environment version 8
# Download sejda-console-pro
# Unzip
unzip sejda-console-pro-*-bin.zip
# List all available tasks
./sejda-console-*/bin/sejda-console-pro
# See command line options for a task (eg: split by pages)
./sejda-console-*/bin/sejda-console-pro -h splitbypages
# Merge 2 PDF documents
./sejda-console-*/bin/sejda-console-pro merge --files /Users/edi/Desktop/test.pdf /Users/edi/Desktop/test1.pdf --output /Users/edi/Desktop/merged.pdf
Next: Have a look at all the available tasks.
Add the Sejda SDK PRO dependency to your Maven project:
<properties>
<sejda.version>4.0.0</sejda.version>
</properties>
<repositories>
<!-- sejda PRO -->
<!-- Add credentials to your ~/.m2/settings.xml -->
<!--
<server>
<id>mvn.sejda.com</id>
<username>your-sejda-pro-username</username>
<password>your-sejda-pro-password</password>
</server>
-->
<repository>
<id>mvn.sejda.com</id>
<url>http://mvn.sejda.com/artifactory/libs-release</url>
</repository>
<repository>
<id>sejda OSS</id>
<url>http://dl.bintray.com/sejdapdf/maven</url>
</repository>
</repositories>
<!-- sejda PRO -->
<dependency>
<groupId>org.sejda</groupId>
<artifactId>sejda-core-pro</artifactId>
<version>${sejda.version}</version>
</dependency>
<dependency>
<groupId>org.sejda</groupId>
<artifactId>sejda-sambox-pro</artifactId>
<version>${sejda.version}</version>
</dependency>
Add the Sejda SDK OSS dependency to your Maven project:
<properties>
<sejda.version>3.2.85</sejda.version>
</properties>
<repositories>
<!-- sejda OSS -->
<repository>
<id>sejda OSS</id>
<url>http://dl.bintray.com/sejdapdf/maven</url>
</repository>
</repositories>
<!-- sejda OSS -->
<dependency>
<groupId>org.sejda</groupId>
<artifactId>sejda-core</artifactId>
<version>${sejda.version}</version>
</dependency>
<dependency>
<groupId>org.sejda</groupId>
<artifactId>sejda-sambox</artifactId>
<version>${sejda.version}</version>
</dependency>
We'll next write a simple class that splits a PDF document by text.
public final class SampleCode {
public static void main(String[] args) {
// configure the split by text task
// text area boundaries
TopLeftRectangularBox textArea = new TopLeftRectangularBox(10, 20, 100, 200);
SplitByTextContentParameters taskParameters = new SplitByTextContentParameters(textArea);
// inputs
taskParameters.addSource(PdfFileSource.newInstanceNoPassword(new File("/Users/edi/Desktop/test.pdf")));
// where to output PDF document results
taskParameters.setExistingOutputPolicy(ExistingOutputPolicy.OVERWRITE);
taskParameters.setOutput(new FileOrDirectoryTaskOutput(new File("/tmp/output2")));
TaskExecutionService executionService = new DefaultTaskExecutionService();
executionService.execute(params);
}
}
A complete sample project can be found in GitHub https://github.com/ediweissmann/sejda-java-api-example