Skip to content

Commit

Permalink
Added PDFBox 3.x dependency
Browse files Browse the repository at this point in the history
Issue: #4449
  • Loading branch information
buchen committed Jan 3, 2025
1 parent e3abc4f commit ebcc63e
Show file tree
Hide file tree
Showing 15 changed files with 614 additions and 0 deletions.
8 changes: 8 additions & 0 deletions name.abuchen.portfolio.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ For purposes of the EPL, "Program" will mean the Content.
version="0.0.0"
unpack="false"/>

<plugin
id="name.abuchen.portfolio.pdfbox3"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

<plugin
id="name.abuchen.portfolio"
download-size="0"
install-size="0"
Expand Down
10 changes: 10 additions & 0 deletions name.abuchen.portfolio.pdfbox3/.checkstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<local-check-config name="Portfolio Performance Checkstyle Configuration" location="/portfolio-app/portfolioCheckstyle.xml" type="project" description="">
<additional-data name="protect-config-file" value="false"/>
</local-check-config>
<fileset name="all" enabled="true" check-config-name="Portfolio Performance Checkstyle Configuration" local="true">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>
11 changes: 11 additions & 0 deletions name.abuchen.portfolio.pdfbox3/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions name.abuchen.portfolio.pdfbox3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
44 changes: 44 additions & 0 deletions name.abuchen.portfolio.pdfbox3/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>name.abuchen.portfolio.pdfbox3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.sonarlint.eclipse.core.sonarlintBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
411 changes: 411 additions & 0 deletions name.abuchen.portfolio.pdfbox3/.settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
formatter_profile=_portfolio
formatter_settings_version=23
13 changes: 13 additions & 0 deletions name.abuchen.portfolio.pdfbox3/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: name.abuchen.portfolio.pdfbox3
Bundle-Version: 0.73.1.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-21
Export-Package: name.abuchen.portfolio.pdfbox3
Import-Package: org.osgi.framework
Require-Bundle: org.apache.pdfbox;bundle-version="[3.0.3,4.0.0)"
Bundle-ClassPath: .
Bundle-Vendor: %Bundle-Vendor
Automatic-Module-Name: name.abuchen.portfolio.pdfbox3
Bundle-ActivationPolicy: lazy
4 changes: 4 additions & 0 deletions name.abuchen.portfolio.pdfbox3/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = target/classes/
bin.includes = META-INF/,\
.
42 changes: 42 additions & 0 deletions name.abuchen.portfolio.pdfbox3/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>name.abuchen.portfolio</groupId>
<artifactId>portfolio-app</artifactId>
<version>0.73.1-SNAPSHOT</version>
<relativePath>../portfolio-app</relativePath>
</parent>

<artifactId>name.abuchen.portfolio.pdfbox3</artifactId>
<packaging>eclipse-plugin</packaging>

<properties>
<sonar.coverage.jacoco.xmlReportPaths>../name.abuchen.portfolio.tests/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-versions</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package name.abuchen.portfolio.pdfbox3;

import java.io.File;
import java.io.IOException;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.osgi.framework.FrameworkUtil;

public class PDFBox3
{
public String convertToText(File file) throws IOException
{
try (PDDocument document = Loader.loadPDF(file))
{
PDFTextStripper textStripper = new PDFTextStripper();
textStripper.setSortByPosition(true);
var text = textStripper.getText(document);

// replace horizontal whitespace characters by normal whitespace
text = text.replaceAll("\\h", " "); //$NON-NLS-1$ //$NON-NLS-2$

// without carriage returns
return text.replace("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$

}
}

public String getPDFBoxVersion()
{
return FrameworkUtil.getBundle(PDDocument.class).getVersion().toString();
}

}
1 change: 1 addition & 0 deletions name.abuchen.portfolio/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Require-Bundle: org.eclipse.core.runtime,
com.google.gson,
org.osgi.service.component,
name.abuchen.portfolio.pdfbox1;bundle-version="0.73.1",
name.abuchen.portfolio.pdfbox3;bundle-version="0.73.1"
Automatic-Module-Name: name.abuchen.portfolio
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/name.abuchen.portfolio.util.ImageioSpiRegistration.xml
Expand Down
1 change: 1 addition & 0 deletions portfolio-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<modules>
<module>../portfolio-target-definition</module>
<module>../name.abuchen.portfolio.pdfbox1</module>
<module>../name.abuchen.portfolio.pdfbox3</module>
<module>../name.abuchen.portfolio</module>
<module>../name.abuchen.portfolio.junit</module>
<module>../name.abuchen.portfolio.tests</module>
Expand Down
28 changes: 28 additions & 0 deletions portfolio-target-definition/portfolio-target-definition.target
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@
</dependency>
</dependencies>
</location>
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" label="Apache PDFBox 3.x" missingManifest="generate" type="Maven">
<dependencies>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
<version>3.0.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-io</artifactId>
<version>3.0.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.3</version>
<type>jar</type>
</dependency>
</dependencies>
</location>
<location includeDependencyDepth="none" includeDependencyScopes="compile" label="XStream" missingManifest="generate" type="Maven">
<dependencies>
<dependency>
Expand All @@ -107,6 +129,12 @@
<version>1.12.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.4</version>
<type>jar</type>
</dependency>
</dependencies>
</location>
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" label="SWT Treemap" missingManifest="generate" type="Maven">
Expand Down

0 comments on commit ebcc63e

Please sign in to comment.