Merge branch 'dependabot/maven/net.bull.javamelody-javamelody-core-2.0.1' of https://github.com/omaster395464gh/fop4apex into dependabot/maven/net.bull.javamelody-javamelody-core-2.0.1
This commit is contained in:
commit
902fdb468b
22
pom.xml
22
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>de.pdv.apex</groupId>
|
<groupId>de.pdv.apex</groupId>
|
||||||
<artifactId>fop4apex</artifactId>
|
<artifactId>fop4apex</artifactId>
|
||||||
<version>0.11.1-SNAPSHOT</version>
|
<version>0.12.1-SNAPSHOT</version>
|
||||||
<name>fop4apex</name>
|
<name>fop4apex</name>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<url>https://www.pdv.de</url>
|
<url>https://www.pdv.de</url>
|
||||||
@ -17,6 +17,7 @@
|
|||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<junit.version>5.10.0</junit.version>
|
<junit.version>5.10.0</junit.version>
|
||||||
<batik.version>1.16</batik.version>
|
<batik.version>1.16</batik.version>
|
||||||
|
<pdfbox.version>3.0.0</pdfbox.version>
|
||||||
<sonar.organization>omaster395464gh</sonar.organization>
|
<sonar.organization>omaster395464gh</sonar.organization>
|
||||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||||
</properties>
|
</properties>
|
||||||
@ -44,7 +45,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.pdfbox</groupId>
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
<artifactId>pdfbox</artifactId>
|
<artifactId>pdfbox</artifactId>
|
||||||
<version>2.0.29</version>
|
<version>${pdfbox.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
|
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
|
||||||
@ -94,23 +95,6 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Start: Security fixes -->
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/fontbox -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.pdfbox</groupId>
|
|
||||||
<artifactId>fontbox</artifactId>
|
|
||||||
<version>2.0.29</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
<version>1.2</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- End: Security fixes -->
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package de.pdv.apex;
|
package de.pdv.apex;
|
||||||
|
|
||||||
import org.apache.fop.apps.*;
|
import org.apache.fop.apps.*;
|
||||||
|
import org.apache.pdfbox.io.RandomAccessReadBufferedFile;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.apache.pdfbox.text.PDFTextStripper;
|
import org.apache.pdfbox.text.PDFTextStripper;
|
||||||
import org.apache.pdfbox.text.PDFTextStripperByArea;
|
import org.apache.pdfbox.text.PDFTextStripperByArea;
|
||||||
@ -17,6 +18,7 @@ import javax.xml.transform.stream.StreamSource;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.pdfbox.Loader;
|
||||||
|
|
||||||
class ExampleFO2PDFTest {
|
class ExampleFO2PDFTest {
|
||||||
|
|
||||||
@ -110,8 +112,8 @@ class ExampleFO2PDFTest {
|
|||||||
if (!pdfFile.exists())
|
if (!pdfFile.exists())
|
||||||
throw new Exception("result file missing");
|
throw new Exception("result file missing");
|
||||||
|
|
||||||
try (PDDocument document = PDDocument.load(pdfFile)) {
|
try (PDDocument document = Loader.loadPDF(new RandomAccessReadBufferedFile(pdfFile)))
|
||||||
//document.getClass();
|
{
|
||||||
if (!document.isEncrypted()) {
|
if (!document.isEncrypted()) {
|
||||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||||
stripper.setSortByPosition(true);
|
stripper.setSortByPosition(true);
|
||||||
@ -124,6 +126,11 @@ class ExampleFO2PDFTest {
|
|||||||
System.out.println("Pages: " + document.getNumberOfPages());
|
System.out.println("Pages: " + document.getNumberOfPages());
|
||||||
Assertions.assertEquals(Integer.valueOf(1).intValue(), document.getNumberOfPages());
|
Assertions.assertEquals(Integer.valueOf(1).intValue(), document.getNumberOfPages());
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
for (PDPage page : document.getPages())
|
||||||
|
{
|
||||||
|
....
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
System.out.println("Filesize (Bytes): " + Files.size(pdfFile.toPath()));
|
System.out.println("Filesize (Bytes): " + Files.size(pdfFile.toPath()));
|
||||||
System.out.println("Success!");
|
System.out.println("Success!");
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import org.apache.fop.apps.FOUserAgent;
|
|||||||
import org.apache.fop.apps.Fop;
|
import org.apache.fop.apps.Fop;
|
||||||
import org.apache.fop.apps.FopFactory;
|
import org.apache.fop.apps.FopFactory;
|
||||||
import org.apache.fop.apps.MimeConstants;
|
import org.apache.fop.apps.MimeConstants;
|
||||||
|
import org.apache.pdfbox.Loader;
|
||||||
|
import org.apache.pdfbox.io.RandomAccessReadBufferedFile;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -19,6 +21,7 @@ import java.io.File;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
class ExampleXML2PDFTest {
|
class ExampleXML2PDFTest {
|
||||||
|
|
||||||
@ -53,8 +56,7 @@ class ExampleXML2PDFTest {
|
|||||||
// configure foUserAgent as desired
|
// configure foUserAgent as desired
|
||||||
|
|
||||||
// Setup output
|
// Setup output
|
||||||
OutputStream out = new java.io.FileOutputStream(pdfFile);
|
OutputStream out = Files.newOutputStream(Paths.get(pdfFile.toURI()));
|
||||||
out = new java.io.BufferedOutputStream(out);
|
|
||||||
|
|
||||||
// Construct fop with desired output format
|
// Construct fop with desired output format
|
||||||
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
|
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
|
||||||
@ -84,11 +86,11 @@ class ExampleXML2PDFTest {
|
|||||||
|
|
||||||
if (!pdfFile.exists())
|
if (!pdfFile.exists())
|
||||||
throw new Exception("result file missing");
|
throw new Exception("result file missing");
|
||||||
|
try (PDDocument document = Loader.loadPDF(new RandomAccessReadBufferedFile(pdfFile))) {
|
||||||
PDDocument document = PDDocument.load(pdfFile);
|
System.out.println("Pages: " + document.getNumberOfPages());
|
||||||
System.out.println("Pages: " + document.getNumberOfPages());
|
System.out.println("Filesize (Bytes): " + Files.size(pdfFile.toPath()));
|
||||||
System.out.println("Filesize (Bytes): " + Files.size(pdfFile.toPath()));
|
Assertions.assertEquals(Integer.valueOf(1).intValue(), document.getNumberOfPages());
|
||||||
Assertions.assertEquals(Integer.valueOf(1).intValue(), document.getNumberOfPages());
|
System.out.println("Success!");
|
||||||
System.out.println("Success!");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user