diff --git a/pom.xml b/pom.xml
index 078855ac..7aafd310 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,7 +78,7 @@
- * This strategy implements the {@link IStreamCompressionStrategy} interface - * and provides {@code ASCII85Decode} encoding. - * - *
- * The strategy ensures, that streams are saved using just 7-bit ASCII - * characters, but it typically increases sizes of streams by 25% compared to - * just saving them as-is. So calling this a "compression strategy" is a - * misnomer. - */ -public class ASCII85CompressionStrategy implements IStreamCompressionStrategy { - /** - * Constructs a new {@link ASCII85CompressionStrategy} instance. - */ - public ASCII85CompressionStrategy() { - // empty constructor - } - - /** - * Returns the name of the compression filter. - * - * @return {@link PdfName#ASCII85Decode} representing the {@code ASCII85Decode} filter - */ - @Override - public PdfName getFilterName() { - return PdfName.ASCII85Decode; - } - - /** - * Returns the decode parameters for the {@code ASCII85Decode} filter. - *
- * This implementation returns {@code null} as no special decode parameters - * are required for standard ASCII85 compression. - * - * @return {@code null} as no decode parameters are needed - */ - @Override - public PdfObject getDecodeParams() { - return null; - } - - /** - * Creates a new output stream with ASCII85 compression applied. - *
- * This method wraps the original output stream in a {@link ASCII85OutputStream} - * that applies ASCII85 compression. - * - * @param original the original output stream to wrap - * @param stream the PDF stream containing compression configuration - * - * @return a new {@link ASCII85OutputStream} that compresses data using the ASCII85 algorithm - */ - @Override - public OutputStream createNewOutputStream(OutputStream original, PdfStream stream) { - return new ASCII85OutputStream(original); - } -} diff --git a/src/main/java/com/itextpdf/rups/io/encoders/ASCII85OutputStream.java b/src/main/java/com/itextpdf/rups/io/encoders/ASCII85OutputStream.java deleted file mode 100644 index 63b556ba..00000000 --- a/src/main/java/com/itextpdf/rups/io/encoders/ASCII85OutputStream.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2026 Apryse Group NV - Authors: Apryse Software. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License version 3 - as published by the Free Software Foundation with the addition of the - following permission added to Section 15 as permitted in Section 7(a): - FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY - APRYSE GROUP. APRYSE GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT - OF THIRD PARTY RIGHTS - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program; if not, see http://www.gnu.org/licenses or write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA, 02110-1301 USA, or download the license from the following URL: - http://itextpdf.com/terms-of-use/ - - The interactive user interfaces in modified source and object code versions - of this program must display Appropriate Legal Notices, as required under - Section 5 of the GNU Affero General Public License. - - In accordance with Section 7(b) of the GNU Affero General Public License, - a covered work must retain the producer line in every PDF that is created - or manipulated using iText. - - You can be released from the requirements of the license by purchasing - a commercial license. Buying such a license is mandatory as soon as you - develop commercial activities involving the iText software without - disclosing the source code of your own applications. - These activities include: offering paid services to customers as an ASP, - serving PDFs on the fly in a web application, shipping iText with a closed - source product. - - For more information, please contact iText Software Corp. at this - address: sales@itextpdf.com - */ -package com.itextpdf.rups.io.encoders; - -import com.itextpdf.io.source.IFinishable; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * An output stream that encodes data according to the {@code ASCII85Decode} - * filter from the PDF specification. - */ -public class ASCII85OutputStream extends FilterOutputStream implements IFinishable { - private static final int BASE = 85; - /** - * Offset to the first base-85 output char. - */ - private static final int OFFSET = 33; - /** - * Size of the encoding block. After this amount of bytes data is converted - * and flush to the backing stream. - */ - private static final int INPUT_LENGTH = 4; - /** - * Amount of bytes produced from a block of input bytes. - */ - private static final int OUTPUT_LENGTH = 5; - /** - * Marker written, when all input bytes are zero. Not used for partial - * blocks. - */ - private static final byte ALL_ZEROS_MARKER = 'z'; - /** - * End Of Data marker. - */ - private static final byte[] EOD = new byte[]{'~', '>'}; - - /** - * Encoding block buffer. Reused for encoding output, when flushing. - */ - private final byte[] buffer = new byte[OUTPUT_LENGTH]; - /** - * Bitwise OR of all bytes within the encoding block. Used to quickly - * check, whether the encoding block contains only zeros. - */ - private int inputOr = 0; - /** - * Input bytes cursor within the buffer. - */ - private int inputCursor = 0; - - /** - * Flag for detecting, whether {@link #finish} has been called. - */ - private final AtomicBoolean finished = new AtomicBoolean(false); - - /** - * Creates a new {@code ASCIIHexDecode} encoding stream. - * - * @param out the output stream to write encoded data to - */ - public ASCII85OutputStream(OutputStream out) { - super(out); - } - - /** - * {@inheritDoc} - */ - @Override - public void write(int b) throws IOException { - int value = b & 0xFF; - buffer[inputCursor] = (byte) value; - inputOr |= value; - ++inputCursor; - writeBufferIfFull(); - } - - /** - * {@inheritDoc} - */ - @Override - public void close() throws IOException { - finish(); - super.close(); - } - - /** - * {@inheritDoc} - */ - @Override - public void finish() throws IOException { - if (finished.getAndSet(true)) { - return; - } - // Writing the remainder - if (inputCursor > 0) { - if (inputOr == 0) { - // If all zeros, output is just n + 1 exclamation points - Arrays.fill(buffer, 0, inputCursor + 1, (byte) '!'); - } else { - Arrays.fill(buffer, inputCursor, INPUT_LENGTH, (byte) 0); - convertBuffer(); - } - out.write(buffer, 0, inputCursor + 1); - resetBuffer(); - } - out.write(EOD); - flush(); - } - - private void writeBufferIfFull() throws IOException { - if (inputCursor < INPUT_LENGTH) { - return; - } - if (inputOr == 0) { - // Special case, if all zeros - out.write(ALL_ZEROS_MARKER); - } else { - convertBuffer(); - out.write(buffer); - } - resetBuffer(); - } - - private void resetBuffer() { - inputOr = 0; - inputCursor = 0; - } - - private void convertBuffer() { - long num = ((buffer[0] & 0xFFL) << 24) - | ((buffer[1] & 0xFFL) << 16) - | ((buffer[2] & 0xFFL) << 8) - | (buffer[3] & 0xFFL); - for (int i = OUTPUT_LENGTH - 1; i >= 0; --i) { - buffer[i] = (byte) (OFFSET + (num % BASE)); - num /= BASE; - } - } -} diff --git a/src/main/java/com/itextpdf/rups/io/encoders/ASCIIHexCompressionStrategy.java b/src/main/java/com/itextpdf/rups/io/encoders/ASCIIHexCompressionStrategy.java deleted file mode 100644 index 8a1cb822..00000000 --- a/src/main/java/com/itextpdf/rups/io/encoders/ASCIIHexCompressionStrategy.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2026 Apryse Group NV - Authors: Apryse Software. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License version 3 - as published by the Free Software Foundation with the addition of the - following permission added to Section 15 as permitted in Section 7(a): - FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY - APRYSE GROUP. APRYSE GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT - OF THIRD PARTY RIGHTS - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program; if not, see http://www.gnu.org/licenses or write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA, 02110-1301 USA, or download the license from the following URL: - http://itextpdf.com/terms-of-use/ - - The interactive user interfaces in modified source and object code versions - of this program must display Appropriate Legal Notices, as required under - Section 5 of the GNU Affero General Public License. - - In accordance with Section 7(b) of the GNU Affero General Public License, - a covered work must retain the producer line in every PDF that is created - or manipulated using iText. - - You can be released from the requirements of the license by purchasing - a commercial license. Buying such a license is mandatory as soon as you - develop commercial activities involving the iText software without - disclosing the source code of your own applications. - These activities include: offering paid services to customers as an ASP, - serving PDFs on the fly in a web application, shipping iText with a closed - source product. - - For more information, please contact iText Software Corp. at this - address: sales@itextpdf.com - */ -package com.itextpdf.rups.io.encoders; - -import com.itextpdf.kernel.pdf.IStreamCompressionStrategy; -import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.kernel.pdf.PdfObject; -import com.itextpdf.kernel.pdf.PdfStream; - -import java.io.OutputStream; - -/** - * A compression strategy that uses the {@code ASCIIHexDecode} filter for PDF - * streams. - * - *
- * This strategy implements the {@link IStreamCompressionStrategy} interface - * and provides {@code ASCIIHexDecode} encoding. - * - *
- * The strategy ensures, that streams are saved using just 7-bit ASCII - * characters, but it doubles the sizes of streams compared to just saving - * them as-is. So calling this a "compression strategy" is a misnomer. - */ -public class ASCIIHexCompressionStrategy implements IStreamCompressionStrategy { - /** - * Constructs a new {@link ASCIIHexCompressionStrategy} instance. - */ - public ASCIIHexCompressionStrategy() { - // empty constructor - } - - /** - * Returns the name of the compression filter. - * - * @return {@link PdfName#ASCIIHexDecode} representing the {@code ASCIIHexDecode} filter - */ - @Override - public PdfName getFilterName() { - return PdfName.ASCIIHexDecode; - } - - /** - * Returns the decode parameters for the {@code ASCIIHexDecode} filter. - *
- * This implementation returns {@code null} as no special decode parameters - * are required for standard ASCIIHex compression. - * - * @return {@code null} as no decode parameters are needed - */ - @Override - public PdfObject getDecodeParams() { - return null; - } - - /** - * Creates a new output stream with ASCIIHex compression applied. - *
- * This method wraps the original output stream in a {@link ASCIIHexOutputStream} - * that applies ASCIIHex compression. - * - * @param original the original output stream to wrap - * @param stream the PDF stream containing compression configuration - * - * @return a new {@link ASCIIHexOutputStream} that compresses data using the ASCIIHex algorithm - */ - @Override - public OutputStream createNewOutputStream(OutputStream original, PdfStream stream) { - return new ASCIIHexOutputStream(original); - } -} diff --git a/src/main/java/com/itextpdf/rups/io/encoders/ASCIIHexOutputStream.java b/src/main/java/com/itextpdf/rups/io/encoders/ASCIIHexOutputStream.java deleted file mode 100644 index bf9838df..00000000 --- a/src/main/java/com/itextpdf/rups/io/encoders/ASCIIHexOutputStream.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2026 Apryse Group NV - Authors: Apryse Software. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License version 3 - as published by the Free Software Foundation with the addition of the - following permission added to Section 15 as permitted in Section 7(a): - FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY - APRYSE GROUP. APRYSE GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT - OF THIRD PARTY RIGHTS - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program; if not, see http://www.gnu.org/licenses or write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA, 02110-1301 USA, or download the license from the following URL: - http://itextpdf.com/terms-of-use/ - - The interactive user interfaces in modified source and object code versions - of this program must display Appropriate Legal Notices, as required under - Section 5 of the GNU Affero General Public License. - - In accordance with Section 7(b) of the GNU Affero General Public License, - a covered work must retain the producer line in every PDF that is created - or manipulated using iText. - - You can be released from the requirements of the license by purchasing - a commercial license. Buying such a license is mandatory as soon as you - develop commercial activities involving the iText software without - disclosing the source code of your own applications. - These activities include: offering paid services to customers as an ASP, - serving PDFs on the fly in a web application, shipping iText with a closed - source product. - - For more information, please contact iText Software Corp. at this - address: sales@itextpdf.com - */ -package com.itextpdf.rups.io.encoders; - -import com.itextpdf.io.source.IFinishable; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * An output stream that encodes data according to the {@code ASCIIHexDecode} - * filter from the PDF specification. - */ -public class ASCIIHexOutputStream extends FilterOutputStream implements IFinishable { - /** - * End Of Data marker. - */ - private static final byte EOD = '>'; - /** - * Array for mapping nibble values to the corresponding lowercase - * hexadecimal characters. - */ - private static final byte[] CHAR_MAP = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' - }; - - /** - * Buffer for storing the output hex char pair. - */ - private final byte[] buffer = new byte[2]; - - /** - * Flag for detecting, whether {@link #finish} has been called. - */ - private final AtomicBoolean finished = new AtomicBoolean(false); - - /** - * Creates a new {@code ASCIIHexDecode} encoding stream. - * - * @param out the output stream to write encoded data to - */ - public ASCIIHexOutputStream(OutputStream out) { - super(out); - } - - /** - * {@inheritDoc} - */ - @Override - public void write(int b) throws IOException { - int value = (b & 0xFF); - // Writing via a 2-elem buffer, in case `write(byte[])` on the - // underlying stream is more performant - buffer[0] = CHAR_MAP[value >> 4]; - buffer[1] = CHAR_MAP[value & 0x0F]; - out.write(buffer); - } - - /** - * {@inheritDoc} - */ - @Override - public void close() throws IOException { - finish(); - super.close(); - } - - /** - * {@inheritDoc} - */ - @Override - public void finish() throws IOException { - if (finished.getAndSet(true)) { - return; - } - out.write(EOD); - flush(); - } -} diff --git a/src/main/java/com/itextpdf/rups/io/encoders/RunLengthCompressionStrategy.java b/src/main/java/com/itextpdf/rups/io/encoders/RunLengthCompressionStrategy.java deleted file mode 100644 index a31e6e2d..00000000 --- a/src/main/java/com/itextpdf/rups/io/encoders/RunLengthCompressionStrategy.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2026 Apryse Group NV - Authors: Apryse Software. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License version 3 - as published by the Free Software Foundation with the addition of the - following permission added to Section 15 as permitted in Section 7(a): - FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY - APRYSE GROUP. APRYSE GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT - OF THIRD PARTY RIGHTS - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program; if not, see http://www.gnu.org/licenses or write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA, 02110-1301 USA, or download the license from the following URL: - http://itextpdf.com/terms-of-use/ - - The interactive user interfaces in modified source and object code versions - of this program must display Appropriate Legal Notices, as required under - Section 5 of the GNU Affero General Public License. - - In accordance with Section 7(b) of the GNU Affero General Public License, - a covered work must retain the producer line in every PDF that is created - or manipulated using iText. - - You can be released from the requirements of the license by purchasing - a commercial license. Buying such a license is mandatory as soon as you - develop commercial activities involving the iText software without - disclosing the source code of your own applications. - These activities include: offering paid services to customers as an ASP, - serving PDFs on the fly in a web application, shipping iText with a closed - source product. - - For more information, please contact iText Software Corp. at this - address: sales@itextpdf.com - */ -package com.itextpdf.rups.io.encoders; - -import com.itextpdf.kernel.pdf.IStreamCompressionStrategy; -import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.kernel.pdf.PdfObject; -import com.itextpdf.kernel.pdf.PdfStream; - -import java.io.OutputStream; - -/** - * A compression strategy that uses the {@code RunLengthDecode} filter for PDF - * streams. - * - *
- * This strategy implements the {@link IStreamCompressionStrategy} interface - * and provides {@code RunLengthDecode} encoding. - * - *
- * Run-length encoding works best, when input data has long sequences of - * identical bytes. This is, usually, not the case for PDF content streams, so - * using this strategy will often cause a marginal size increase instead. - */ -public class RunLengthCompressionStrategy implements IStreamCompressionStrategy { - /** - * Constructs a new {@link RunLengthCompressionStrategy} instance. - */ - public RunLengthCompressionStrategy() { - // empty constructor - } - - /** - * Returns the name of the compression filter. - * - * @return {@link PdfName#RunLengthDecode} representing the {@code RunLengthDecode} filter - */ - @Override - public PdfName getFilterName() { - return PdfName.RunLengthDecode; - } - - /** - * Returns the decode parameters for the {@code RunLengthDecode} filter. - *
- * This implementation returns {@code null} as no special decode parameters - * are required for standard run length compression. - * - * @return {@code null} as no decode parameters are needed - */ - @Override - public PdfObject getDecodeParams() { - return null; - } - - /** - * Creates a new output stream with run length compression applied. - *
- * This method wraps the original output stream in a {@link RunLengthOutputStream} - * that applies run length compression. - * - * @param original the original output stream to wrap - * @param stream the PDF stream containing compression configuration - * - * @return a new {@link RunLengthOutputStream} that compresses data using the run length algorithm - */ - @Override - public OutputStream createNewOutputStream(OutputStream original, PdfStream stream) { - return new RunLengthOutputStream(original); - } -} diff --git a/src/main/java/com/itextpdf/rups/io/encoders/RunLengthOutputStream.java b/src/main/java/com/itextpdf/rups/io/encoders/RunLengthOutputStream.java deleted file mode 100644 index ae3b19f0..00000000 --- a/src/main/java/com/itextpdf/rups/io/encoders/RunLengthOutputStream.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2026 Apryse Group NV - Authors: Apryse Software. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License version 3 - as published by the Free Software Foundation with the addition of the - following permission added to Section 15 as permitted in Section 7(a): - FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY - APRYSE GROUP. APRYSE GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT - OF THIRD PARTY RIGHTS - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program; if not, see http://www.gnu.org/licenses or write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA, 02110-1301 USA, or download the license from the following URL: - http://itextpdf.com/terms-of-use/ - - The interactive user interfaces in modified source and object code versions - of this program must display Appropriate Legal Notices, as required under - Section 5 of the GNU Affero General Public License. - - In accordance with Section 7(b) of the GNU Affero General Public License, - a covered work must retain the producer line in every PDF that is created - or manipulated using iText. - - You can be released from the requirements of the license by purchasing - a commercial license. Buying such a license is mandatory as soon as you - develop commercial activities involving the iText software without - disclosing the source code of your own applications. - These activities include: offering paid services to customers as an ASP, - serving PDFs on the fly in a web application, shipping iText with a closed - source product. - - For more information, please contact iText Software Corp. at this - address: sales@itextpdf.com - */ -package com.itextpdf.rups.io.encoders; - -import com.itextpdf.io.source.IFinishable; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * An output stream that encodes data according to the {@code RunLengthDecode} - * filter from the PDF specification. - */ -public class RunLengthOutputStream extends FilterOutputStream implements IFinishable { - /** - * Maximum length of a run. Applies to both "unique" and repeating ones. - */ - private static final int MAX_LENGTH = 128; - /** - * End Of Data marker. - */ - private static final byte EOD = (byte) 128; - - /** - * Buffer for storing the pending run. - */ - private final byte[] buffer = new byte[MAX_LENGTH]; - /** - * Value, that repeats in a repeating run. Set to {@code -1}, when the - * pending run is a "unique" one. - */ - private int repeatValue = -1; - /** - * Current length of the pending run. - */ - private int currentLength = 0; - - /** - * Flag for detecting, whether {@link #finish} has been called. - */ - private final AtomicBoolean finished = new AtomicBoolean(false); - - /** - * Creates a new {@code RunLengthDecode} encoding stream. - * - * @param out the output stream to write encoded data to - */ - public RunLengthOutputStream(OutputStream out) { - super(out); - } - - /** - * {@inheritDoc} - */ - @Override - public void write(int b) throws IOException { - int value = b & 0xFF; - // Case for continuing a repeating run - if (value == repeatValue) { - ++currentLength; - if (currentLength == MAX_LENGTH) { - writePending(); - } - return; - } - /* - * If there was a repeating run, but we got a different value, then we - * need to write the current repeating run we had and start a new - * "unique" run. - */ - if (repeatValue != -1) { - writePending(); - buffer[currentLength] = (byte) value; - ++currentLength; - return; - } - /* - * As soon as we detect a sequence of 3 or more bytes, which are the - * same, we need to switch to a repeating run. For this we will write - * the values before the repeated one as a "unique" run and start a - * new repeating run at length 3. - * - * Technically speaking we can switch to a repeating run at 2 bytes, - * but in the vast majority of cases this will make the compression - * ratio worse. - */ - if (currentLength >= 2 - && buffer[currentLength - 1] == (byte) value - && buffer[currentLength - 2] == (byte) value) { - currentLength -= 2; - writePending(); - repeatValue = value; - currentLength = 3; - return; - } - // Just continuing (or starting) a "unique" run - buffer[currentLength] = (byte) value; - ++currentLength; - if (currentLength == MAX_LENGTH) { - writePending(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void close() throws IOException { - finish(); - super.close(); - } - - /** - * {@inheritDoc} - */ - @Override - public void finish() throws IOException { - if (finished.getAndSet(true)) { - return; - } - writePending(); - out.write(EOD); - flush(); - } - - private void writePending() throws IOException { - if (currentLength <= 0) { - return; - } - if (repeatValue < 0) { - // Writing "unique" run - out.write(currentLength - 1); - out.write(buffer, 0, currentLength); - } else { - // Writing repeating run - out.write(257 - currentLength); - out.write(repeatValue); - } - resetPending(); - } - - private void resetPending() { - repeatValue = -1; - currentLength = 0; - } -} diff --git a/src/main/java/com/itextpdf/rups/view/contextmenu/PdfTreeContextMenu.java b/src/main/java/com/itextpdf/rups/view/contextmenu/PdfTreeContextMenu.java index 5c40c490..c48ad815 100644 --- a/src/main/java/com/itextpdf/rups/view/contextmenu/PdfTreeContextMenu.java +++ b/src/main/java/com/itextpdf/rups/view/contextmenu/PdfTreeContextMenu.java @@ -43,12 +43,12 @@ This file is part of the iText (R) project. package com.itextpdf.rups.view.contextmenu; import com.itextpdf.brotlicompressor.BrotliStreamCompressionStrategy; +import com.itextpdf.kernel.pdf.ASCII85CompressionStrategy; +import com.itextpdf.kernel.pdf.ASCIIHexCompressionStrategy; import com.itextpdf.kernel.pdf.FlateCompressionStrategy; import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.RunLengthCompressionStrategy; import com.itextpdf.rups.controller.PdfReaderController; -import com.itextpdf.rups.io.encoders.ASCII85CompressionStrategy; -import com.itextpdf.rups.io.encoders.ASCIIHexCompressionStrategy; -import com.itextpdf.rups.io.encoders.RunLengthCompressionStrategy; import com.itextpdf.rups.util.ExcludeFromGeneratedJacocoReport; import com.itextpdf.rups.view.Language; import com.itextpdf.rups.view.itext.PdfTree; diff --git a/src/test/java/com/itextpdf/rups/io/encoders/ASCII85OutputStreamTest.java b/src/test/java/com/itextpdf/rups/io/encoders/ASCII85OutputStreamTest.java deleted file mode 100644 index b9c223be..00000000 --- a/src/test/java/com/itextpdf/rups/io/encoders/ASCII85OutputStreamTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2026 Apryse Group NV - Authors: Apryse Software. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License version 3 - as published by the Free Software Foundation with the addition of the - following permission added to Section 15 as permitted in Section 7(a): - FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY - APRYSE GROUP. APRYSE GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT - OF THIRD PARTY RIGHTS - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program; if not, see http://www.gnu.org/licenses or write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA, 02110-1301 USA, or download the license from the following URL: - http://itextpdf.com/terms-of-use/ - - The interactive user interfaces in modified source and object code versions - of this program must display Appropriate Legal Notices, as required under - Section 5 of the GNU Affero General Public License. - - In accordance with Section 7(b) of the GNU Affero General Public License, - a covered work must retain the producer line in every PDF that is created - or manipulated using iText. - - You can be released from the requirements of the license by purchasing - a commercial license. Buying such a license is mandatory as soon as you - develop commercial activities involving the iText software without - disclosing the source code of your own applications. - These activities include: offering paid services to customers as an ASP, - serving PDFs on the fly in a web application, shipping iText with a closed - source product. - - For more information, please contact iText Software Corp. at this - address: sales@itextpdf.com - */ -package com.itextpdf.rups.io.encoders; - -import com.itextpdf.rups.io.util.CloseableByteArrayOutputStream; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -@Tag("UnitTest") -public class ASCII85OutputStreamTest { - public static Iterable