Skip to content
Commits on Source (9)
libsambox-java (1.1.53-1) unstable; urgency=medium
* New upstream version 1.1.53
* Switch to debhelper-compat = 12.
* Declare compliance with Debian Policy 4.4.0.
* Use canonical VCS-URI.
* Remove get-orig-source target.
-- Markus Koschany <apo@debian.org> Sun, 21 Jul 2019 17:36:48 +0200
libsambox-java (1.1.46-1) unstable; urgency=medium
* New upstream version 1.1.46.
......
......@@ -5,7 +5,7 @@ Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.or
Uploaders:
Markus Koschany <apo@debian.org>
Build-Depends:
debhelper (>= 11),
debhelper-compat (= 12),
default-jdk,
junit4,
libbcmail-java,
......@@ -15,9 +15,9 @@ Build-Depends:
libsejda-io-java (>= 1.1.3-2),
libslf4j-java (>= 1.7.25),
maven-debian-helper (>= 2.1)
Standards-Version: 4.2.1
Vcs-Git: https://anonscm.debian.org/git/pkg-java/libsambox-java.git
Vcs-Browser: https://anonscm.debian.org/git/pkg-java/libsambox-java.git
Standards-Version: 4.4.0
Vcs-Git: https://salsa.debian.org/java-team/libsambox-java.git
Vcs-Browser: https://salsa.debian.org/java-team/libsambox-java
Homepage: https://github.com/torakiki/sambox
Package: libsambox-java
......
......@@ -40,7 +40,7 @@ Copyright: 2007-2010, basICColor GmbH
License: zlib
Files: debian/*
Copyright: 2017-2018, Markus Koschany <apo@debian.org>
Copyright: 2017-2019, Markus Koschany <apo@debian.org>
License: Apache-2.0
License: Apache-2.0
......
......@@ -2,6 +2,3 @@
%:
dh $@
get-orig-source:
uscan --download-current-version --force-download
......@@ -5,7 +5,7 @@
<artifactId>sambox</artifactId>
<packaging>jar</packaging>
<name>sambox</name>
<version>1.1.46</version>
<version>1.1.53</version>
<description>An Apache PDFBox fork intended to be used as PDF processor for Sejda and PDFsam related projects</description>
<url>http://www.sejda.org</url>
......@@ -33,7 +33,7 @@
<connection>scm:git:git@github.com:torakiki/sambox.git</connection>
<developerConnection>scm:git:git@github.com:torakiki/sambox.git</developerConnection>
<url>scm:git:git@github.com:torakiki/sambox.git</url>
<tag>v1.1.46</tag>
<tag>v1.1.53</tag>
</scm>
<developers>
......@@ -52,6 +52,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
<bouncycastle.version>1.60</bouncycastle.version>
</properties>
<repositories>
......@@ -240,8 +241,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>-Xmx768m
-Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider</argLine>
<argLine>-Xmx768m</argLine>
<excludes>
<exclude>org/sejda/sambox/rendering/TestPDFToImage.java</exclude>
</excludes>
......@@ -256,6 +256,122 @@
<artifactId>download-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<id>PDFBOX-1031-1</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12481683/1.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-1031-1.pdf</outputFileName>
<sha512>f943df43cc2a6929caa484c79eafa44b06a5902e325139e19e1f1ebda7c5fd0c86cc221311659d68351c0ff56d921350ff61e97b9d2c425180d810842c963a5b</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-1031-2</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12481684/2.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-1031-2.pdf</outputFileName>
<sha512>8a9e836ad77c3e9e1e75476f4b46ff4b8958c099970bf57a0b4789fd37236b2bed7e1f14909fa0e3bbacf1a867c1a5c56cbe293383275c1b9c6c0396bec51085</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-1065-1</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12486525/1_testfile1.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-1065-1.pdf</outputFileName>
<sha512>6b44f363653a9c0cba049495d0ed67659f98b2622b25d647ae556dc4a708847f6c3e4428aa5de2fa0d67f5e8ba08183abf9e8e640e474c6b00c544782e3bba3e</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-1065-2</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12486526/2_testfile1.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-1065-2.pdf</outputFileName>
<sha512>3b19a2a4c35fbacb36774553bedc0b3f2caf60d96aa021a9151d1f18a248577f13229f101ed7ed4375f36b9f481c0488ceb5ac00e4669d6802cd7cee1b0b4ad7</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-1100-1</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12490774/a.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-1100-1.pdf</outputFileName>
<sha512>9e59c8eb5cde5823a78e8e773bab393ab52eb5ac3f3a576b5d665d0267dca9c677abe08bb3b503a8ebf43479b4e6f61725ad85affd95803e12009c0b1919111a</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-1100-2</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12490775/b.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-1100-2.pdf</outputFileName>
<sha512>f55ec23a9b7350410eef95e6bd6de3c3605fa3dc2e9f9c28dfd2f6007bd693da252787350ad6d1d49570ee07fbbfcaba1f8638c1d7e63d4a8875f44c39867e6f</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3208</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12784025/PDFBOX-3208-L33MUTT2SVCWGCS6UIYL5TH3PNPXHIS6.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<sha512>5aa19dff76b980ad43c873b7a47f089b3914468e0eaca320d67e18cbfa121c99b9e65bfb86d1b106b034bc6e6833f79c54b3d0c064695f5eac5a2797da687ef2</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3656</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12848122/SF1199AEG%20%28Complete%29.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-3656.pdf</outputFileName>
<sha512>031d958a84cbd9eb520e5af308f635b37c48b77f7df4e43ecbcdabd04f4ba8574fac71b62548594b0f26e9e4e7fa3c1c7679d66c2a8e4bf141157fb6e50df97d</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3682</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12852207/test.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-3682.pdf</outputFileName>
<sha512>b57628fc15898c1fbd5947c93659aa40b34071a2e8cf04e46ff787cb01687668456e59a13c3fba8b56ab0ef76c933408b3b0f3a781990bfd475cd8fa4325d730</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3703</id>
<phase>generate-test-resources</phase>
......@@ -282,6 +398,57 @@
<sha512>b7eb8e6f2a4549eb68280d0d8834b2a14f711f2d15ffe1420fde654f05dd939181c617bf51e11c44aededaa729966b49288b0a07a35b79aa73a08b8c48b72de0</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3940</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12888957/079977.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-3940-079977.pdf</outputFileName>
<sha512>f4a8875b03422af85a03ece2d46edffbb72e98b58c87584a936c2e80b0ef4c87e069b6f8e9237a61187e640f6a1059c4516beedcea50cd323f6788dc1e9f6482</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3783</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12867102/PDFBOX-3783-72GLBIGUC6LB46ELZFBARRJTLN4RBSQM.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<sha512>158ce94951c6166193065120023badf90e9d0f84a436583acabd59d9290a58eb1459c29dab2fd65f59368a9b39ee62b786771f92cc823df9b4f41d14448fcc81</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3785</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12867113/202097.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-3785-202097.pdf</outputFileName>
<sha512>5031db8cee73aa5199afb0c45dfec284fa6903a5ff31f27788893cfdf80474156f0d5d6feb7947323f874f37d15acfbccfecd4ca5a5cc9edc46d63c9e606a3eb</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3947</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12890031/670064.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-3947-670064.pdf</outputFileName>
<sha512>7005a6314ae625b7514f429d8ebe146c4d47f715cb8816403134ab047a1f78664c1e95c92413d52b87c4cfcfcb660265d6fe086e4bd3c44ee767151e3fee115e</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3948</id>
<phase>generate-test-resources</phase>
......@@ -347,6 +514,44 @@
<sha512>0457fd291a7f83f531fef205128929c8fa8147dd781ea7b7cd49d4d1287941989e72739329a7b172c6f53df0b54d991b514b9baa6145effa8ec7705ef273877b</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3977</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12893582/63NGFQRI44HQNPIPEJH5W2TBM6DJZWMI.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-3977-63NGFQRI44HQNPIPEJH5W2TBM6DJZWMI.pdf</outputFileName>
<sha512>42a47b7b800ec035895af73f6793b7155652ce7b06db28ff97939e52b4fbce321fc45064480359c3371e90a7a47f5e20843a9ba71d4597b9bc3516fa17cfbb32</sha512>
</configuration>
</execution>
<execution>
<id>Genko</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12867433/genko_oc_shiryo1.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<sha512>71888e06a0323ac6196c5942c5961f76f8a4d8c6913114aaa9e215f43112cfa5f1b741b7c801e794dc44e62c2d34bfaafe89267a4c7de753e4da1481b35820f3</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-3999</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12896905/GeneralForbearance.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-3999-GeneralForbearance.pdf</outputFileName>
<sha512>6ed5287342ec8a5459a86462d80917bb625d5973df96fdebd5e3c8bc2e9093e6c389f5c8151eb17472a24e1349386a3e7c1a0021e9a967761a554ac1ade557eb</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4022</id>
<phase>generate-test-resources</phase>
......@@ -414,6 +619,20 @@
<sha512>6fefc869dff9db8cd539db177d35beeacc62304173245742eaee8882dab330860a31cbbd4c4ec6cc724603cc453afc07ec61361fbc1e80a47f44b04ccfbaf40d</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4184</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12949710/032163.jpg</url>
<!-- 032163.jpg is from http://downloads.digitalcorpora.org/corpora/files/govdocs1/zipfiles/032.zip -->
<outputDirectory>${project.build.directory}/imgs</outputDirectory>
<outputFileName>PDFBOX-4184-032163.jpg</outputFileName>
<sha512>35241c979d3808ca9d2641b5ec5e40637132b313f75070faca8b8f6d00ddce394070414236db3993f1092fe3bc16995750d528b6d803a7851423c14c308ccdde</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4184-2</id>
<phase>generate-test-resources</phase>
......@@ -429,6 +648,97 @@
<sha512>45f148913590ea1a94c3ac17080969b74e579fe51967a5bf535caa3f7104ea81ee222b99deb8ee528b0a53640f97d87cf668633a1bdd61a62092246df1807471</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4308</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12938094/Quelldatei.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-4308.pdf</outputFileName>
<sha512>566346239d51f10b2ccfc435620e8f3b0281e91286983cb86660060a8d48777998eab46dfda93d35024e7e4b50b7ab6654f9a1002524163d228a5e41a80a1221</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4338</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12943502/ArrayIndexOutOfBoundsException%20COSParser</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-4338.pdf</outputFileName>
<sha512>130fa4b49345410b203613f3e67263f483f9a9797bef22322647655bb55cc55bcb1d1e0eb03c27f6f2855b3823675b27e8899d8eeb880d27a74fad5f60f23b47</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4339</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12943503/NullPointerException%20COSParser</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-4339.pdf</outputFileName>
<sha512>2e48aeae83ef6fc4c5f95aafdfe8c76dd8d2dcf3516701c70ffeb14f06ba246a17c21f2dadf8fa48bccef5b72daffdd30ed7c9aa7f5183ddf889968caa2ded6a</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4408</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12952086/form.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-4408.pdf</outputFileName>
<sha512>eaabebdc39eb9df2f96de4d322ce02478c61193311fdbabf310995cbab55d72e80047bd562d506c391f53a15b1cac9a5d225245b1c5d8a0745acd1b506f571f8</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4418-1</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12953423/000314.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-4418-000314.pdf</outputFileName>
<sha512>1e16476ff9cdf11fdcb8bfd7d1e6e434d85bce187164936d352846e6804694cd89c9f789da1b9fcae13b51058c1bab0cc4f50dd63e3544ab02050b00044cc5df</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4418-2</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12953421/000671.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-4418-000671.pdf</outputFileName>
<sha512>a0fc0cfd42cb7eb8d521db259f53723f1e8a1618e740e89c787157f85623ed3f8a85b1920933328dfef355c8a468f26c459f37eeeaf5cdafa86540b56fb46090</sha512>
</configuration>
</execution>
<execution>
<id>PDFBOX-4423</id>
<phase>generate-test-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://issues.apache.org/jira/secure/attachment/12953866/000746.pdf</url>
<outputDirectory>${project.build.directory}/pdfs</outputDirectory>
<outputFileName>PDFBOX-4423-000746.pdf</outputFileName>
<sha512>42a61d0061b0b3b0bcc92c9f3ddc78daca79e9d5ea56c19796270316fb7cf3858db9f51efafa3776e1fef17f85202b35c8eed0e88ba6b7ebc7bb05c6014b9fc8</sha512>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
......@@ -458,7 +768,7 @@
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
<version>2.0.12</version>
<version>2.0.15</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
......@@ -470,13 +780,13 @@
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<optional>true</optional>
<version>1.60</version>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<optional>true</optional>
<version>1.60</version>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
......
......@@ -53,6 +53,9 @@ import org.sejda.sambox.contentstream.operator.graphics.LineTo;
import org.sejda.sambox.contentstream.operator.graphics.MoveTo;
import org.sejda.sambox.contentstream.operator.graphics.ShadingFill;
import org.sejda.sambox.contentstream.operator.graphics.StrokePath;
import org.sejda.sambox.contentstream.operator.markedcontent.BeginMarkedContentSequence;
import org.sejda.sambox.contentstream.operator.markedcontent.BeginMarkedContentSequenceWithProperties;
import org.sejda.sambox.contentstream.operator.markedcontent.EndMarkedContentSequence;
import org.sejda.sambox.contentstream.operator.state.Concatenate;
import org.sejda.sambox.contentstream.operator.state.Restore;
import org.sejda.sambox.contentstream.operator.state.Save;
......@@ -86,8 +89,8 @@ import org.sejda.sambox.pdmodel.PDPage;
import org.sejda.sambox.pdmodel.graphics.image.PDImage;
/**
* PDFStreamEngine subclass for advanced processing of graphics.
* This class should be subclasses by end users looking to hook into graphics operations.
* PDFStreamEngine subclass for advanced processing of graphics. This class should be subclassed by end users looking to
* hook into graphics operations.
*
* @author John Hewson
*/
......@@ -165,10 +168,15 @@ public abstract class PDFGraphicsStreamEngine extends PDFStreamEngine
addOperator(new CurveToReplicateFinalPoint());
addOperator(new ShowTextLine());
addOperator(new ShowTextLineAndSpace());
addOperator(new BeginMarkedContentSequence());
addOperator(new BeginMarkedContentSequenceWithProperties());
addOperator(new EndMarkedContentSequence());
}
/**
* Returns the page.
*
* @return the page.
*
*/
protected final PDPage getPage()
{
......@@ -177,20 +185,29 @@ public abstract class PDFGraphicsStreamEngine extends PDFStreamEngine
/**
* Append a rectangle to the current path.
*
* @param p0 point P0 of the rectangle.
* @param p1 point P1 of the rectangle.
* @param p2 point P2 of the rectangle.
* @param p3 point P3 of the rectangle.
*
* @throws IOException if something went wrong.
*/
public abstract void appendRectangle(Point2D p0, Point2D p1,
Point2D p2, Point2D p3) throws IOException;
public abstract void appendRectangle(Point2D p0, Point2D p1, Point2D p2, Point2D p3)
throws IOException;
/**
* Draw the image.
*
* @param pdImage The image to draw.
*
* @throws IOException if something went wrong.
*/
public abstract void drawImage(PDImage pdImage) throws IOException;
/**
* Modify the current clipping path by intersecting it with the current path.
* The clipping path will not be updated until the succeeding painting operator is called.
* Modify the current clipping path by intersecting it with the current path. The clipping path will not be updated
* until the succeeding painting operator is called.
*
* @param windingRule The winding rule which will be used for clipping.
*/
......@@ -209,9 +226,8 @@ public abstract class PDFGraphicsStreamEngine extends PDFStreamEngine
/**
* Draws a curve from the current point to (x3,y3) using (x1,y1) and (x2,y2) as control points.
*/
public abstract void curveTo(float x1, float y1,
float x2, float y2,
float x3, float y3) throws IOException;
public abstract void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
throws IOException;
/**
* Returns the current point of the current path.
......
......@@ -37,6 +37,8 @@ import org.sejda.sambox.contentstream.operator.OperatorProcessor;
import org.sejda.sambox.contentstream.operator.state.EmptyGraphicsStackException;
import org.sejda.sambox.cos.COSArray;
import org.sejda.sambox.cos.COSBase;
import org.sejda.sambox.cos.COSDictionary;
import org.sejda.sambox.cos.COSName;
import org.sejda.sambox.cos.COSNumber;
import org.sejda.sambox.cos.COSString;
import org.sejda.sambox.filter.MissingImageReaderException;
......@@ -794,6 +796,25 @@ public abstract class PDFStreamEngine
}
}
/**
* Called when a marked content group begins
*
* @param tag content tag
* @param properties optional properties
*/
public void beginMarkedContentSequence(COSName tag, COSDictionary properties)
{
// overridden in subclasses
}
/**
* Called when a a marked content group ends
*/
public void endMarkedContentSequence()
{
// overridden in subclasses
}
/**
* This is used to handle an operation.
*
......
......@@ -22,7 +22,6 @@ import org.sejda.sambox.contentstream.operator.Operator;
import org.sejda.sambox.contentstream.operator.OperatorProcessor;
import org.sejda.sambox.cos.COSBase;
import org.sejda.sambox.cos.COSName;
import org.sejda.sambox.text.PDFMarkedContentExtractor;
/**
* BMC : Begins a marked-content sequence.
......@@ -42,10 +41,7 @@ public class BeginMarkedContentSequence extends OperatorProcessor
tag = (COSName) argument;
}
}
if (this.getContext() instanceof PDFMarkedContentExtractor)
{
((PDFMarkedContentExtractor) this.getContext()).beginMarkedContentSequence(tag, null);
}
this.getContext().beginMarkedContentSequence(tag, null);
}
@Override
......
......@@ -23,7 +23,6 @@ import org.sejda.sambox.contentstream.operator.OperatorProcessor;
import org.sejda.sambox.cos.COSBase;
import org.sejda.sambox.cos.COSDictionary;
import org.sejda.sambox.cos.COSName;
import org.sejda.sambox.text.PDFMarkedContentExtractor;
/**
* BDC : Begins a marked-content sequence with property list.
......@@ -48,11 +47,7 @@ public class BeginMarkedContentSequenceWithProperties extends OperatorProcessor
properties = (COSDictionary) argument;
}
}
if (this.getContext() instanceof PDFMarkedContentExtractor)
{
((PDFMarkedContentExtractor) this.getContext()).beginMarkedContentSequence(tag,
properties);
}
this.getContext().beginMarkedContentSequence(tag, properties);
}
@Override
......
......@@ -21,7 +21,6 @@ import java.util.List;
import org.sejda.sambox.contentstream.operator.Operator;
import org.sejda.sambox.contentstream.operator.OperatorProcessor;
import org.sejda.sambox.cos.COSBase;
import org.sejda.sambox.text.PDFMarkedContentExtractor;
/**
* EMC : Ends a marked-content sequence begun by BMC or BDC.
......@@ -33,10 +32,7 @@ public class EndMarkedContentSequence extends OperatorProcessor
@Override
public void process(Operator operator, List<COSBase> arguments)
{
if (this.getContext() instanceof PDFMarkedContentExtractor)
{
((PDFMarkedContentExtractor) this.getContext()).endMarkedContentSequence();
}
this.getContext().endMarkedContentSequence();
}
@Override
......
......@@ -564,6 +564,23 @@ public class COSDictionary extends COSBase
return getCOSName(key, null);
}
/**
* This is a convenience method that will get the dictionary object that is expected to be a COSArray. Null is
* returned if the entry does not exist in the dictionary.
*
* @param key The key to the item in the dictionary.
* @return The COSArray.
*/
public COSArray getCOSArray(COSName key)
{
COSBase array = getDictionaryObject(key);
if (array instanceof COSArray)
{
return (COSArray) array;
}
return null;
}
/**
* Convenience method that will get the dictionary object that is expected to be a name. Default is returned if the
* entry does not exist in the dictionary.
......
......@@ -20,6 +20,7 @@ import static org.sejda.util.RequireUtils.requireIOCondition;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.regex.Pattern;
/**
* This class represents a floating point number in a PDF document.
......@@ -30,6 +31,13 @@ import java.math.BigDecimal;
public class COSFloat extends COSNumber
{
private BigDecimal value;
private static final Pattern DOTS = Pattern.compile("\\.");
private static final Pattern EXP_END = Pattern.compile("[e|E]$");
private static final Pattern NUM1 = Pattern.compile("^(-)([-|+]+)\\d+\\.\\d+");
private static final Pattern NUM2 = Pattern.compile("^(-)([\\-|\\+]+)");
private static final Pattern NUM3 = Pattern.compile("^0\\.0*\\-\\d+");
private static final Pattern ZERO = Pattern.compile("^0\\-(\\.|\\d+)*");
private static final Pattern MINUS = Pattern.compile("\\-");
/**
* @param aFloat The primitive float object that this object wraps.
......@@ -54,10 +62,11 @@ public class COSFloat extends COSNumber
{
// 415.75.795 we replace additional dots with 0
aFloat = aFloat.substring(0, dot + 1)
+ aFloat.substring(dot + 1).replaceAll("\\.", "0");
+ DOTS.matcher(aFloat.substring(dot + 1)).replaceAll("0");
;
}
aFloat = aFloat.replaceAll("[e|E]$", "");
aFloat = EXP_END.matcher(aFloat).replaceAll("");
value = new BigDecimal(aFloat);
checkMinMaxValues();
}
......@@ -65,12 +74,12 @@ public class COSFloat extends COSNumber
{
try
{
if (aFloat.matches("^(-)([-|+]+)\\d+\\.\\d+"))
if (NUM1.matcher(aFloat).matches())
{
// PDFBOX-3589 --242.0
value = new BigDecimal(aFloat.replaceFirst("^(-)([\\-|\\+]+)", "-"));
value = new BigDecimal(NUM2.matcher(aFloat).replaceFirst("-"));
}
else if (aFloat.matches("^0\\-(\\.|\\d+)*"))
else if (ZERO.matcher(aFloat).matches())
{
// SAMBox 75
value = BigDecimal.ZERO;
......@@ -80,9 +89,9 @@ public class COSFloat extends COSNumber
// PDFBOX-2990 has 0.00000-33917698
// PDFBOX-3369 has 0.00-35095424
// PDFBOX-3500 has 0.-262
requireIOCondition(aFloat.matches("^0\\.0*\\-\\d+"),
requireIOCondition(NUM3.matcher(aFloat).matches(),
"Expected floating point number but found '" + aFloat + "'");
value = new BigDecimal("-" + aFloat.replaceFirst("\\-", ""));
value = new BigDecimal("-" + MINUS.matcher(aFloat).replaceFirst(""));
}
checkMinMaxValues();
}
......
......@@ -156,6 +156,7 @@ public final class COSName extends COSBase implements Comparable<COSName>
public static final COSName DECODE_PARMS = newCommonInstance("DecodeParms");
public static final COSName DEFAULT = newCommonInstance("default");
public static final COSName DEFAULT_CMYK = newCommonInstance("DefaultCMYK");
public static final COSName DEFAULT_CRYPT_FILTER = newCommonInstance("DefaultCryptFilter");
public static final COSName DEFAULT_GRAY = newCommonInstance("DefaultGray");
public static final COSName DEFAULT_RGB = newCommonInstance("DefaultRGB");
public static final COSName DESC = newCommonInstance("Desc");
......@@ -264,6 +265,7 @@ public final class COSName extends COSBase implements Comparable<COSName>
public static final COSName H = newCommonInstance("H");
public static final COSName HARD_LIGHT = newCommonInstance("HardLight");
public static final COSName HEIGHT = newCommonInstance("Height");
public static final COSName HELV = newCommonInstance("Helv");
public static final COSName HIDE_MENUBAR = newCommonInstance("HideMenubar");
public static final COSName HIDE_TOOLBAR = newCommonInstance("HideToolbar");
public static final COSName HIDE_WINDOWUI = newCommonInstance("HideWindowUI");
......@@ -558,6 +560,8 @@ public final class COSName extends COSBase implements Comparable<COSName>
public static final COSName Y_STEP = newCommonInstance("YStep");
public static final COSName YES = newCommonInstance("Yes");
public static final COSName ZA_DB = newCommonInstance("ZaDb");
private final String name;
/**
......
......@@ -20,6 +20,7 @@ import static org.sejda.util.RequireUtils.requireArg;
import static org.sejda.util.RequireUtils.requireNotNullArg;
import java.io.IOException;
import java.util.regex.Pattern;
/**
* This class represents an abstract number in a PDF document.
......@@ -49,6 +50,8 @@ public abstract class COSNumber extends COSBase
*/
public abstract long longValue();
private static Pattern NUMBER = Pattern.compile("(E|e|\\+|\\-|\\.|\\d)+");
/**
* This factory method will get the appropriate number object.
*
......@@ -59,7 +62,7 @@ public abstract class COSNumber extends COSBase
public static COSNumber get(String number) throws IOException
{
requireNotNullArg(number, "Number cannot be null");
requireArg(number.matches("(E|e|\\+|\\-|\\.|\\d)+"), "Invalid number " + number);
requireArg(NUMBER.matcher(number).matches(), "Invalid number " + number);
if (number.length() == 1)
{
char digit = number.charAt(0);
......
......@@ -16,11 +16,8 @@
*/
package org.sejda.sambox.filter;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.image.DataBufferUShort;
import java.awt.image.Raster;
import java.awt.color.ColorSpace;
import java.awt.image.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
......@@ -31,6 +28,7 @@ import javax.imageio.stream.MemoryCacheImageInputStream;
import org.sejda.sambox.cos.COSDictionary;
import org.sejda.sambox.cos.COSName;
import org.sejda.sambox.pdmodel.graphics.color.PDJPXColorSpace;
/**
* Decompress data encoded using the wavelet-based JPEG 2000 standard, reproducing the original data.
......@@ -47,6 +45,9 @@ import org.sejda.sambox.cos.COSName;
*/
public final class JPXFilter extends Filter
{
/**
* {@inheritDoc}
*/
@Override
public DecodeResult decode(InputStream encoded, OutputStream decoded, COSDictionary parameters,
int index) throws IOException
......@@ -72,6 +73,23 @@ public final class JPXFilter extends Filter
}
return result;
case DataBuffer.TYPE_INT:
// not yet used (as of October 2018) but works as fallback
// if we decide to convert to BufferedImage.TYPE_INT_RGB
int[] ar = new int[raster.getNumBands()];
for (int y = 0; y < image.getHeight(); ++y)
{
for (int x = 0; x < image.getWidth(); ++x)
{
raster.getPixel(x, y, ar);
for (int i = 0; i < ar.length; ++i)
{
decoded.write(ar[i]);
}
}
}
return result;
default:
throw new IOException(
"Data type " + raster.getDataBuffer().getDataType() + " not implemented");
......@@ -124,7 +142,21 @@ public final class JPXFilter extends Filter
// extract embedded color space
if (!parameters.containsKey(COSName.COLORSPACE))
{
// result.setColorSpace(new PDJPXColorSpace(image.getColorModel().getColorSpace()));
if (image.getSampleModel() instanceof MultiPixelPackedSampleModel &&
image.getColorModel().getPixelSize() == 1 &&
image.getRaster().getNumBands() == 1 &&
image.getColorModel() instanceof IndexColorModel)
{
// PDFBOX-4326:
// force CS_GRAY colorspace because colorspace in IndexColorModel
// has 3 colors despite that there is only 1 color per pixel
// in raster
result.setColorSpace(new PDJPXColorSpace(ColorSpace.getInstance(ColorSpace.CS_GRAY)));
}
else
{
result.setColorSpace(new PDJPXColorSpace(image.getColorModel().getColorSpace()));
}
}
return image;
......@@ -139,6 +171,9 @@ public final class JPXFilter extends Filter
}
}
/**
* {@inheritDoc}
*/
@Override
public void encode(InputStream input, OutputStream encoded, COSDictionary parameters)
{
......
......@@ -236,11 +236,11 @@ public class PDPage implements COSObjectable, PDContentStream
/**
* This will get the key of this Page in the structural parent tree.
*
* @return the integer key of the page's entry in the structural parent tree
* @return the integer key of the page's entry in the structural parent tree or -1 if there isn't any.
*/
public int getStructParents()
{
return page.getInt(COSName.STRUCT_PARENTS, 0);
return page.getInt(COSName.STRUCT_PARENTS);
}
/**
......@@ -371,7 +371,8 @@ public class PDPage implements COSObjectable, PDContentStream
if (base instanceof COSArray)
{
COSArray array = (COSArray) base;
if(inMediaBoxBounds(new PDRectangle(array))) {
if (inMediaBoxBounds(new PDRectangle(array)))
{
return new PDRectangle((COSArray) base);
}
}
......@@ -420,7 +421,7 @@ public class PDPage implements COSObjectable, PDContentStream
if (base instanceof COSArray)
{
COSArray array = (COSArray) base;
if(inMediaBoxBounds(new PDRectangle(array)))
if (inMediaBoxBounds(new PDRectangle(array)))
{
return new PDRectangle(array);
}
......@@ -470,7 +471,7 @@ public class PDPage implements COSObjectable, PDContentStream
if (base instanceof COSArray)
{
COSArray array = (COSArray) base;
if(inMediaBoxBounds(new PDRectangle(array)))
if (inMediaBoxBounds(new PDRectangle(array)))
{
return new PDRectangle(array);
}
......@@ -709,8 +710,8 @@ public class PDPage implements COSObjectable, PDContentStream
/**
* This will return a list of the annotations for this page.
*
* @return List of the PDAnnotation objects, never null. The returned list is backed by the
* annotations COSArray, so any adding or deleting in this list will change the document too.
* @return List of the PDAnnotation objects, never null. The returned list is backed by the annotations COSArray, so
* any adding or deleting in this list will change the document too.
*
*/
public List<PDAnnotation> getAnnotations()
......@@ -729,8 +730,8 @@ public class PDPage implements COSObjectable, PDContentStream
* This will return a list of the annotations for this page.
*
* @param annotationFilter the annotation filter provided allowing to filter out specific annotations
* @return List of the PDAnnotation objects, never null. The returned list is backed by the
* annotations COSArray, so any adding or deleting in this list will change the document too.
* @return List of the PDAnnotation objects, never null. The returned list is backed by the annotations COSArray, so
* any adding or deleting in this list will change the document too.
*
*/
public List<PDAnnotation> getAnnotations(AnnotationFilter annotationFilter)
......
......@@ -391,6 +391,7 @@ public final class PDPageContentStream implements Closeable
*
* @param text The Unicode text to show.
* @throws IOException If an io exception occurs.
* @throws IllegalArgumentException if a character isn't supported by the current font
*/
public void showText(String text) throws IOException
{
......@@ -1643,6 +1644,10 @@ public final class PDPageContentStream implements Closeable
@Override
public void close() throws IOException
{
if (inTextMode)
{
LOG.warn("You did not call endText(), some viewers won't display your text");
}
IOUtils.close(writer);
}
......
......@@ -27,13 +27,13 @@ public enum PageLayout
/** Display one page at a time. */
SINGLE_PAGE("SinglePage"),
/** Display the pages in one column. */
/** Display the pages in one column. */
ONE_COLUMN("OneColumn"),
/** Display the pages in two columns), with odd numbered pages on the left. */
TWO_COLUMN_LEFT("TwoColumnLeft"),
/** Display the pages in two columns), with odd numbered pages on the right. */
/** Display the pages in two columns), with odd numbered pages on the right. */
TWO_COLUMN_RIGHT("TwoColumnRight"),
/** Display the pages two at a time), with odd-numbered pages on the left. */
......@@ -44,28 +44,12 @@ public enum PageLayout
public static PageLayout fromString(String value)
{
if (value.equals("SinglePage"))
for (PageLayout instance : PageLayout.values())
{
return SINGLE_PAGE;
}
else if (value.equals("OneColumn"))
{
return ONE_COLUMN;
}
else if (value.equals("TwoColumnLeft"))
{
return TWO_COLUMN_LEFT;
} else if(value.equals("TwoColumnRight"))
{
return TWO_COLUMN_RIGHT;
}
else if (value.equals("TwoPageLeft"))
{
return TWO_PAGE_LEFT;
}
else if (value.equals("TwoPageRight"))
{
return TWO_PAGE_RIGHT;
if (instance.value.equals(value))
{
return instance;
}
}
throw new IllegalArgumentException(value);
}
......
......@@ -44,29 +44,12 @@ public enum PageMode
public static PageMode fromString(String value)
{
if (value.equals("UseNone"))
for (PageMode instance : PageMode.values())
{
return USE_NONE;
}
else if (value.equals("UseOutlines"))
{
return USE_OUTLINES;
}
else if (value.equals("UseThumbs"))
{
return USE_THUMBS;
}
else if (value.equals("FullScreen"))
{
return FULL_SCREEN;
}
else if (value.equals("UseOC"))
{
return USE_OPTIONAL_CONTENT;
}
else if (value.equals("UseAttachments"))
{
return USE_ATTACHMENTS;
if (instance.value.equals(value))
{
return instance;
}
}
throw new IllegalArgumentException(value);
}
......