-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored PDFBox 1.8 into separate bundle
Issue: #4449
- Loading branch information
Showing
16 changed files
with
697 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.pdfbox1</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> |
2 changes: 2 additions & 0 deletions
2
name.abuchen.portfolio.pdfbox1/.settings/org.eclipse.core.resources.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
411
name.abuchen.portfolio.pdfbox1/.settings/org.eclipse.jdt.core.prefs
Large diffs are not rendered by default.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
name.abuchen.portfolio.pdfbox1/.settings/org.eclipse.jdt.ui.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.pdfbox1 | ||
Bundle-Version: 0.73.1.qualifier | ||
Bundle-RequiredExecutionEnvironment: JavaSE-21 | ||
Export-Package: name.abuchen.portfolio.pdfbox1 | ||
Import-Package: org.osgi.framework | ||
Require-Bundle: org.apache.pdfbox;bundle-version="[1.8.17,2.0.0)" | ||
Bundle-ClassPath: . | ||
Bundle-Vendor: %Bundle-Vendor | ||
Automatic-Module-Name: name.abuchen.portfolio.pdfbox1 | ||
Bundle-ActivationPolicy: lazy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/ | ||
output.. = target/classes/ | ||
bin.includes = META-INF/,\ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.pdfbox1</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> |
45 changes: 45 additions & 0 deletions
45
name.abuchen.portfolio.pdfbox1/src/name/abuchen/portfolio/pdfbox1/PDFBox1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package name.abuchen.portfolio.pdfbox1; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.apache.pdfbox.exceptions.CryptographyException; | ||
import org.apache.pdfbox.pdmodel.PDDocument; | ||
import org.apache.pdfbox.util.PDFTextStripper; | ||
import org.osgi.framework.FrameworkUtil; | ||
|
||
public class PDFBox1 | ||
{ | ||
public String convertToText(File file) throws IOException | ||
{ | ||
try (PDDocument document = PDDocument.load(file)) | ||
{ | ||
boolean isProtected = document.isEncrypted(); | ||
if (isProtected) | ||
{ | ||
document.decrypt(""); //$NON-NLS-1$ | ||
document.setAllSecurityToBeRemoved(true); | ||
} | ||
|
||
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$ | ||
|
||
} | ||
catch (CryptographyException e) | ||
{ | ||
throw new IOException(e); | ||
} | ||
} | ||
|
||
public String getPDFBoxVersion() | ||
{ | ||
return FrameworkUtil.getBundle(PDDocument.class).getVersion().toString(); | ||
} | ||
} |
Oops, something went wrong.