foray-commit Mailing List for FOray (Page 6)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2025-05-27 15:02:32
|
Revision: 13753
http://sourceforge.net/p/foray/code/13753
Author: victormote
Date: 2025-05-27 15:02:27 +0000 (Tue, 27 May 2025)
Log Message:
-----------
Doc and formatting changes only.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsObjectComposite.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/Ascii85DecodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/Ascii85EncodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexDecodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexEncodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/CcittFaxDecodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/CcittFaxEncodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/DctDecodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/DctEncodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/FlateDecodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/FlateEncodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsDecodeFilter4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsEncodeFilter4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/RunLengthDecodeFilter.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/RunLengthEncodeFilter.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsObjectComposite.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsObjectComposite.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsObjectComposite.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -30,6 +30,8 @@
/**
* A PostScript composite object.
+ *
+ * @see "PostScript Language Reference, Third Edition, Section 3.3.1"
*/
public abstract class PsObjectComposite implements PsObject {
@@ -45,12 +47,10 @@
*/
public void setAccess(final PsInterpreter4a interpreter, final PsAccess accessLevel) {
if (accessLevel == null) {
- throw new NullPointerException("Access level cannot be null on PostScript composite "
- + "object");
+ throw new IllegalArgumentException("Access level cannot be null on PostScript composite object");
}
- /* Don't allow access to be increased (per documentation of readonly
- * and related operators). */
+ /* Don't allow access to be increased (per documentation of readonly and related operators). */
if (accessLevel.getPrivilege() > getAccess().getPrivilege()) {
return;
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/Ascii85DecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/Ascii85DecodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/Ascii85DecodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -28,20 +28,22 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
/**
- * An ASCII85Decode filter.
+ * Decoding filter for {@link PsFilterType#ASCII_85}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class Ascii85DecodeFilter extends PsDecodeFilter4a {
/**
* Constructor.
- * @param inputStream The underlying input stream from which the encoded
- * data should be read.
- * Use {@link ByteArrayInputStream} if the encoded data is in a byte
- * array instead of a normal stream.
+ * @param inputStream The underlying input stream from which the encoded data should be read.
+ * Use {@link ByteArrayInputStream} if the encoded data is in a byte array instead of a normal stream.
*/
public Ascii85DecodeFilter(final InputStream inputStream) {
super(inputStream);
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/Ascii85EncodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/Ascii85EncodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/Ascii85EncodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -29,6 +29,7 @@
package org.foray.ps.filter;
import org.axsl.constants.PrimitiveConstants;
+import org.axsl.ps.PsFilterType;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -35,9 +36,9 @@
import java.io.OutputStream;
/**
- * Acts as either an ASCII85Encode Filter or an ASCII85Decode filter.
- * The ASCII base-85 encoding produces five ASCII characters for every four
- * bytes of binary data.
+ * Encoding filter for {@link PsFilterType#ASCII_85}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class Ascii85EncodeFilter extends PsEncodeFilter4a {
@@ -65,32 +66,27 @@
/** The maximum encoded value in a byte. */
private static final byte MAXIMUM_ENCODED_VALUE = 117;
- /** Constant specified in the PostScript standard indicating five
- * consecutive encoded zeroes. */
+ /** Constant specified in the PostScript standard indicating five consecutive encoded zeroes. */
private static final char ASCII85_ZERO = 'z';
- /** Constant specified in the PostScript standard indicating the value added
- * to all encoded binary data to ensure that they are ASCII characters. */
+ /** Constant specified in the PostScript standard indicating the value added to all encoded binary data to ensure
+ * that they are ASCII characters. */
private static final char ASCII85_START = '!';
- /** End-of-data marker specified in the PostScript standard, that is,
- * "~>". */
+ /** End-of-data marker specified in the PostScript standard, that is, "~>". */
private static final byte[] ASCII85_EOD = { 0x7E, 0x3E };
/** The radix in which Base-85 numbers are stored. */
private static final long BASE_85_4 = 85;
- /** The size, in bytes, of each unencoded block (4 unencoded bytes are
- * equal to 5 encoded bytes). */
+ /** The size, in bytes, of each unencoded block (4 unencoded bytes are equal to 5 encoded bytes). */
private static final byte UNENCODED_BLOCK_SIZE = 4;
- /** The size, in bytes, of each encoded block (4 unencoded bytes are
- * equal to 5 encoded bytes). */
+ /** The size, in bytes, of each encoded block (4 unencoded bytes are equal to 5 encoded bytes). */
private static final byte ENCODED_BLOCK_SIZE = 5;
/** The array of unencoded bytes. */
- private final byte[] unencodedBytes =
- new byte[Ascii85EncodeFilter.UNENCODED_BLOCK_SIZE];
+ private final byte[] unencodedBytes = new byte[Ascii85EncodeFilter.UNENCODED_BLOCK_SIZE];
/** The index into {@link #unencodedBytes}. */
private int unencodedIndex = 0;
@@ -97,16 +93,13 @@
/**
* Constructor.
- * @param outputStream The underlying output stream to which the encoded
- * data should be written.
- * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is
- * needed in a byte array instead of being written to an actual stream.
- * @param isApplied See
- * {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full
- * explanation of this parameter.
+ * @param outputStream The underlying output stream to which the encoded data should be written.
+ * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is needed in a byte array instead of being
+ * written to an actual stream.
+ * @param isApplied See {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full explanation of
+ * this parameter.
*/
- public Ascii85EncodeFilter(final OutputStream outputStream,
- final boolean isApplied) {
+ public Ascii85EncodeFilter(final OutputStream outputStream, final boolean isApplied) {
super(outputStream, isApplied);
}
@@ -168,11 +161,10 @@
/**
* This converts a 32 bit value (4 bytes) into 5 bytes using base 85.
- * each byte in the result starts with zero at the '!' character so
- * the resulting base85 number fits into printable ascii chars
- * @param word the 32 bit unsigned (hence the long datatype) word
- * @return 5 bytes (or a single byte of the 'z' character for word
- * values of 0)
+ * Each byte in the result starts with zero at the '!' character so the resulting base85 number fits into printable
+ * ASCII chars.
+ * @param word The 32 bit unsigned (hence the long datatype) word.
+ * @return 5 bytes (or a single byte of the 'z' character for word values of 0)
* @throws IOException If an illegal character is found in the input.
*/
protected static byte[] convertWord(final long word) throws IOException {
@@ -212,12 +204,10 @@
@Override
public void flush() throws IOException {
if (this.unencodedIndex != 0) {
- /* We have a partial word started that needs to be completed and
- * processed. */
+ /* We have a partial word started that needs to be completed and processed. */
/* First 0-fill the remaining unencoded bytes. */
- for (int j = this.unencodedIndex; j < this.unencodedBytes.length;
- j++) {
+ for (int j = this.unencodedIndex; j < this.unencodedBytes.length; j++) {
this.unencodedBytes[j] = 0;
}
@@ -234,8 +224,7 @@
out.write(conv);
}
/* Write the two character end of data marker. */
- out.write(Ascii85EncodeFilter.ASCII85_EOD, 0,
- Ascii85EncodeFilter.ASCII85_EOD.length);
+ out.write(Ascii85EncodeFilter.ASCII85_EOD, 0, Ascii85EncodeFilter.ASCII85_EOD.length);
super.flush();
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexDecodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexDecodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -31,6 +31,7 @@
import org.foray.primitive.StringUtils;
import org.axsl.constants.MeasurementConstants;
+import org.axsl.ps.PsFilterType;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -38,11 +39,9 @@
import java.io.InputStream;
/**
- * An ASCIIHexDecode filter.
- * The static methods are suitable for direct decoding of entire arrays.
- * The instance methods are suitable for processing smaller array
- * chunks. So, for example, if you have a 1GB file that you wish to process in
- * 1KB chunks, the instance methods will help you do that.
+ * Decoding filter for {@link PsFilterType#ASCII_HEX}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class AsciiHexDecodeFilter extends PsDecodeFilter4a {
@@ -49,26 +48,21 @@
/** End-of-data marker specified in the PostScript standard. */
public static final byte END_OF_DATA = 0x3E;
- /** Stores exactly one meaningful leftover byte from the end of the last
- * chunk processed that needs to be included in the next chunk to be
- * processed. */
+ /** Stores exactly one meaningful leftover byte from the end of the last chunk processed that needs to be included
+ * in the next chunk to be processed. */
private byte leftoverByte = -1;
- /** For decoding, stores the location of the end-of-data marker. If -1,
- * then eod has not yet been found. */
+ /** For decoding, stores the location of the end-of-data marker. If -1, then eod has not yet been found. */
private int eodLocation = -1;
/** Indicates whether the underlying input stream has been read yet. */
private boolean inputRead = false;
- /** Buffer of bytes that have been read from our underlying input stream
- * but not yet decoded. */
+ /** Buffer of bytes that have been read from our underlying input stream but not yet decoded. */
private byte[] encodedBuffer;
- /** Buffer of bytes that have been decoded but not yet read by our
- * client.*/
- private byte[] decodedBuffer
- = new byte[MeasurementConstants.BYTES_PER_KILOBYTE];
+ /** Buffer of bytes that have been decoded but not yet read by our client.*/
+ private byte[] decodedBuffer = new byte[MeasurementConstants.BYTES_PER_KILOBYTE];
/** The starting index in decodedBuffer which is active. */
private int decodedIndex = 0;
@@ -75,10 +69,8 @@
/**
* Constructor.
- * @param inputStream The underlying input stream from which the encoded
- * data should be read.
- * Use {@link ByteArrayInputStream} if the encoded data is in a byte
- * array instead of a normal stream.
+ * @param inputStream The underlying input stream from which the encoded data should be read.
+ * Use {@link ByteArrayInputStream} if the encoded data is in a byte array instead of a normal stream.
*/
public AsciiHexDecodeFilter(final InputStream inputStream) {
super(inputStream);
@@ -134,8 +126,7 @@
* Scan the input, looking for end-of-data character & counting data
* bytes.
*/
- for (int i = 0; i < this.encodedBuffer.length && this.eodLocation < 0;
- i ++) {
+ for (int i = 0; i < this.encodedBuffer.length && this.eodLocation < 0; i ++) {
if (this.encodedBuffer[i] == AsciiHexEncodeFilter.END_OF_DATA) {
this.eodLocation = i;
break;
@@ -154,8 +145,7 @@
} else {
// Otherwise, count backward from the end of the array to find
// the leftovers
- for (int i = this.encodedBuffer.length - 1;
- i > 0 && this.leftoverByte < 1; i--) {
+ for (int i = this.encodedBuffer.length - 1; i > 0 && this.leftoverByte < 1; i--) {
if (! AsciiHexEncodeFilter.isAsciiHexWhitespace(this.encodedBuffer[i])) {
this.leftoverByte = this.encodedBuffer[i];
}
@@ -168,23 +158,21 @@
}
/**
- * Decodes the input array, starting at byte 0 and extending to byte
- * inputLength, and returns the output in a byte array. Handles possible
- * leftover byte from a previous run.
- * @param leftoverByte The byte, if any, leftover from processing a
- * previous chunk. If there is no leftover byte, enter any negative number
- * to skip processing.
- * @param input The input byte array. This first byte of this array must
- * never be the second byte of a 2-byte "word".
- * @param inputLength The last byte of the input byte array that should be
- * examined for purposes of creating the output byte array.
+ * Decodes the input array, starting at byte 0 and extending to byte inputLength, and returns the output in a byte
+ * array.
+ * Handles possible leftover byte from a previous run.
+ * @param leftoverByte The byte, if any, leftover from processing a previous chunk.
+ * If there is no leftover byte, enter any negative number to skip processing.
+ * @param input The input byte array. This first byte of this array must never be the second byte of a 2-byte
+ * "word".
+ * @param inputLength The last byte of the input byte array that should be examined for purposes of creating the
+ * output byte array.
* @param outputLength The size that the output array should be.
- * @return The output byte array. It should be approximately 1/2 the size
- * of the input array (whitespace characters in the input are ignored, so it
- * may be somewhat less than 1/2 the size of the input array). Please note
- * that this routine ignores any incomplete "words" in the input.
- * @throws IOException If the input array contains invalid ASCIIHex
- * characters.
+ * @return The output byte array.
+ * It should be approximately 1/2 the size of the input array (whitespace characters in the input are ignored, so it
+ * may be somewhat less than 1/2 the size of the input array).
+ * Please note that this routine ignores any incomplete "words" in the input.
+ * @throws IOException If the input array contains invalid ASCIIHex characters.
*/
public static byte[] decodeArray(final byte leftoverByte, final byte[] input, final int inputLength,
final int outputLength) {
@@ -215,8 +203,7 @@
continue;
}
if (byte1Found && byte2Found) {
- output[outputIndex] = StringUtils.asciiHexBytesToHex(byte1,
- byte2);
+ output[outputIndex] = StringUtils.asciiHexBytesToHex(byte1, byte2);
outputIndex ++;
byte1Found = false;
byte2Found = false;
@@ -234,8 +221,7 @@
if (! byte2Found) {
byte2 = 0x00;
}
- output[outputIndex] = StringUtils.asciiHexBytesToHex(byte1,
- byte2);
+ output[outputIndex] = StringUtils.asciiHexBytesToHex(byte1, byte2);
}
}
return output;
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexEncodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexEncodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/AsciiHexEncodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -29,6 +29,7 @@
package org.foray.ps.filter;
import org.axsl.constants.PrimitiveConstants;
+import org.axsl.ps.PsFilterType;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -36,11 +37,9 @@
import java.io.UnsupportedEncodingException;
/**
- * A class that can act as either an ASCIIHexEncode Filter or an ASCIIHexDecode
- * filter. The static methods are suitable for direct encoding and decoding of
- * entire arrays. The instance methods are suitable for processing smaller array
- * chunks. So, for example, if you have a 1GB file that you wish to process in
- * 1KB chunks, the instance methods will help you do that.
+ * Encoding filter for {@link PsFilterType#ASCII_HEX}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class AsciiHexEncodeFilter extends PsEncodeFilter4a {
@@ -56,16 +55,13 @@
/**
* Constructor.
- * @param outputStream The underlying output stream to which the encoded
- * data should be written.
- * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is
- * needed in a byte array instead of being written to an actual stream.
- * @param isApplied See
- * {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full
- * explanation of this parameter.
+ * @param outputStream The underlying output stream to which the encoded data should be written.
+ * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is needed in a byte array instead of being
+ * written to an actual stream.
+ * @param isApplied See {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full explanation of
+ * this parameter.
*/
- public AsciiHexEncodeFilter(final OutputStream outputStream,
- final boolean isApplied) {
+ public AsciiHexEncodeFilter(final OutputStream outputStream, final boolean isApplied) {
super(outputStream, isApplied);
}
@@ -95,22 +91,19 @@
/**
- * Encodes the input array, starting at start and extending to byte
- * inputLength, and returns the output in a byte array.
+ * Encodes the input array, starting at start and extending to byte inputLength, and returns the output in a byte
+ * array.
* @param input The input byte array.
* @param start The first byte in input to be encoded.
* @param size The number of bytes in input that should be encoded.
- * @param lineBreak The number of bytes to write before a line-feed should
- * be written.
- * Adding a line-feed at regular intervals breaks the output into smaller
- * chunks.
- * For example, Adobe Type1 font files in the PFA format place a line
- * break after every 72nd character in the output.
+ * @param lineBreak The number of bytes to write before a line-feed should be written.
+ * Adding a line-feed at regular intervals breaks the output into smaller chunks.
+ * For example, Adobe Type1 font files in the PFA format place a line break after every 72nd character in the
+ * output.
* Any value less than 1 will result in no line-feeds being added.
* @return The output byte array.
* This array should be approximately twice the size of the size parameter.
- * Whitespace characters may be added to the output, so it may be somewhat
- * larger.
+ * Whitespace characters may be added to the output, so it may be somewhat larger.
*/
private static byte[] encodeArray(final byte[] input, final int start,
final int size, final int lineBreak) {
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/CcittFaxDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/CcittFaxDecodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/CcittFaxDecodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -28,20 +28,22 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
/**
- * A CCITTFaxDecode filter.
+ * Decoding filter for {@link PsFilterType#CCITT_FAX}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class CcittFaxDecodeFilter extends PsDecodeFilter4a {
/**
* Constructor.
- * @param inputStream The underlying input stream from which the encoded
- * data should be read.
- * Use {@link ByteArrayInputStream} if the encoded data is in a byte
- * array instead of a normal stream.
+ * @param inputStream The underlying input stream from which the encoded data should be read.
+ * Use {@link ByteArrayInputStream} if the encoded data is in a byte array instead of a normal stream.
*/
public CcittFaxDecodeFilter(final InputStream inputStream) {
super(inputStream);
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/CcittFaxEncodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/CcittFaxEncodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/CcittFaxEncodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -32,15 +32,22 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
- * CCF Filter class. Right now it is just used as a dummy filter flag so
- * we can write TIFF images to the PDF. The encode method just returns the
- * data passed to it. In the future an actual CCITT Group 4 compression should
- * be added to the encode method so other images can be compressed.
+ * Encoding filter for {@link PsFilterType#CCITT_FAX}.
+ * Static methods are available for processing entire arrays.
+ *
+ * <p>TODO: Right now this is just used as a dummy filter flag so we can write TIFF images to the PDF.
+ * The encode method just returns the data passed to it.
+ * In the future an actual CCITT Group 4 compression should be added to the encode method so other images can be
+ * compressed.
+ *
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class CcittFaxEncodeFilter extends PsEncodeFilter4a {
@@ -49,16 +56,13 @@
/**
* Constructor.
- * @param outputStream The underlying output stream to which the encoded
- * data should be written.
- * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is
- * needed in a byte array instead of being written to an actual stream.
- * @param isApplied See
- * {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full
- * explanation of this parameter.
+ * @param outputStream The underlying output stream to which the encoded data should be written.
+ * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is needed in a byte array instead of being
+ * written to an actual stream.
+ * @param isApplied See {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full explanation of
+ * this parameter.
*/
- public CcittFaxEncodeFilter(final OutputStream outputStream,
- final boolean isApplied) {
+ public CcittFaxEncodeFilter(final OutputStream outputStream, final boolean isApplied) {
super(outputStream, isApplied);
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/DctDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/DctDecodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/DctDecodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -28,20 +28,22 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
/**
- * A DCTDecode filter.
+ * Decoding filter for {@link PsFilterType#DCT}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class DctDecodeFilter extends PsDecodeFilter4a {
/**
* Constructor.
- * @param inputStream The underlying input stream from which the encoded
- * data should be read.
- * Use {@link ByteArrayInputStream} if the encoded data is in a byte
- * array instead of a normal stream.
+ * @param inputStream The underlying input stream from which the encoded data should be read.
+ * Use {@link ByteArrayInputStream} if the encoded data is in a byte array instead of a normal stream.
*/
public DctDecodeFilter(final InputStream inputStream) {
super(inputStream);
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/DctEncodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/DctEncodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/DctEncodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -32,30 +32,32 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
- * DCT Filter class. Right now it is just used as a dummy filter flag so
- * we can write JPG images to the PDF. The encode method just returns the
- * data passed to it. In the future an actual JPEG compression should be
- * added to the encode method so other images can be compressed.
+ * Encoding filter for {@link PsFilterType#DCT}.
+ * Static methods are available for processing entire arrays.
+ *
+ * <p>TODO: Right now this is just used as a dummy filter flag so we can write JPG images to the PDF.
+ * The encode method just returns the data passed to it.
+ * In the future an actual JPEG compression should be added to the encode method so other images can be compressed.</p>
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class DctEncodeFilter extends PsEncodeFilter4a {
/**
* Constructor.
- * @param outputStream The underlying output stream to which the encoded
- * data should be written.
- * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is
- * needed in a byte array instead of being written to an actual stream.
- * @param isApplied See
- * {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full
- * explanation of this parameter.
+ * @param outputStream The underlying output stream to which the encoded data should be written.
+ * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is needed in a byte array instead of being
+ * written to an actual stream.
+ * @param isApplied See {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full explanation of
+ * this parameter.
*/
- public DctEncodeFilter(final OutputStream outputStream,
- final boolean isApplied) {
+ public DctEncodeFilter(final OutputStream outputStream, final boolean isApplied) {
super(outputStream, isApplied);
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/EexecDecodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -36,41 +36,33 @@
import java.io.IOException;
/**
- * Handles the PostScript encryption used in the "eexec" operator, usually used
- * in Type1 fonts to encrypt the actual glyph-drawing data and the /Private
- * dictionary.
+ * <p>Handles the PostScript encryption used in the "eexec" operator, usually used in Type1 fonts to encrypt the actual
+ * glyph-drawing data and the /Private dictionary.</p>
*
- * Please note that although this is a true filter, it should not be used
- * directly in PostScript or PDF output. It is used by PostScript interpreters
- * to decode contents processed by the "eexec" operator, and is used by font
- * writing or embedding programs that need to encrypt code to be used by that
- * operator. It is not (to our knowledge) available as a standard filter.
+ * <p>Please note that although this is a true filter, it should not be used directly in PostScript or PDF output.
+ * It is used by PostScript interpreters to decode contents processed by the "eexec" operator, and is used by font
+ * writing or embedding programs that need to encrypt code to be used by that operator.
+ * It is not (to our knowledge) available as a standard filter.</p>
*
- * This filter is designed to allow chunks of data to be encoded or decoded at
- * a time. In other words, the entire set of data does not have to be encoded
- * or decoded as the same time, but can be done in pieces. (This was done to
- * save memory).
- * However, the encoding and decoding used by this filter are dependent on data
- * previously processed.
- * Therefore, you must process the data starting at its beginning to be able to
- * encode or decode subsequent data.
- * Both the encode and decode methods are stateful, i.e. they are highly
- * dependent on keeping track of their state from one chunk to the next.
- * Of course, there is nothing wrong with encoding or decoding your entire
- * input in one chunk, if you wish to do so.
+ * <p>This filter is designed to allow chunks of data to be encoded or decoded at a time.
+ * In other words, the entire set of data does not have to be encoded or decoded as the same time, but can be done in
+ * pieces.
+ * (This was done to save memory).
+ * However, the encoding and decoding used by this filter are dependent on data previously processed.
+ * Therefore, you must process the data starting at its beginning to be able to encode or decode subsequent data.
+ * Both the encode and decode methods are stateful, i.e. they are highly dependent on keeping track of their state from
+ * one chunk to the next.
+ * Of course, there is nothing wrong with encoding or decoding your entire input in one chunk, if you wish to do so.</p>
*
+ * <p>Type1 fonts actually use a double layer of encryption, whereby the glyph definitions are encrypted using this
+ * algorithm, then a large chunk of the font file, which includes the glyph definitions, is encrypted again, also using
+ * this algorithm (although with different seeding and constants).
+ * This situation can be handled by using two instances of this class, one for the inside encryption and one for the
+ * outside.</p>
*
- * Type1 fonts actually use a double layer of encryption, whereby the glyph
- * definitions are encrypted using this algorithm, then a large chunk of the
- * font file, which includes the glyph definitions, is encrypted again, also
- * using this algorithm (although with different seeding and constants). This
- * situation can be handled by using two instances of this class, one for the
- * inside encryption and one for the outside.
- *
- * The definition of the algorithms implemented in this class can be found in
- * Chapter 7 of the Adobe Type 1 Font Format Specification. The PostScript
- * Language Reference Manual (2nd Edition) cites this document as the
- * authoritative reference on the topic (see the "eexec" operator).
+ * @see "Adobe Type 1 Font Format, Chapter 7, for the algorithms implemented in this class."
+ * @see "PostScript Language Reference, Third Edition, which cites the above Type 1 documentation as the authoritative
+ * reference on the eexec operator. See the eexec operator in Section 8.2."
*/
public class EexecDecodeFilter {
/* TODO: This class should eventually extend PSDecodeFilter. */
@@ -91,36 +83,32 @@
/** A magic number specified in the PostScript standard. */
private static final int ENCRYPTION_CONSTANT_2 = 22719;
- /** This is the variable "R" described in the spec. The spec calls for an
- * unsigned 16-bit integer, but we have no such thing in java, so we use
- * an int instead to handle the extra bit. */
+ /** This is the variable "R" described in the spec. The spec calls for an unsigned 16-bit integer, but we have no
+ * such thing in java, so we use an int instead to handle the extra bit. */
private int encryptionKey;
- /** The quantity of randomBytes that should occur at the beginning of the
- * sequence to be processed. This is the variable "n" in the spec. */
+ /** The quantity of randomBytes that should occur at the beginning of the sequence to be processed. This is the
+ * variable "n" in the spec. */
private byte randomBytes;
- /** Tracks the number of random bytes that still need to be discarded. The
- * variable is needed in case not enought bytes are in the first byte array
- * that is decrypted to use them all. */
+ /** Tracks the number of random bytes that still need to be discarded. The variable is needed in case not enough
+ * bytes are in the first byte array that is decrypted to use them all. */
private byte randomBytesToDiscard;
- /** The first four bytes must be analyzed in order to figure out whether the
- * input is in ASCII hexadecimal format or binary format. */
- private byte[] first4Bytes =
- new byte[EexecDecodeFilter.EEXEC_INITIAL_BYTES];
+ /** The first four bytes must be analyzed in order to figure out whether the input is in ASCII hexadecimal format or
+ * binary format. */
+ private byte[] first4Bytes = new byte[EexecDecodeFilter.EEXEC_INITIAL_BYTES];
- /** This tracks how much of the first four bytes has actually been
- * accumulated. This is needed because we might not get all four bytes
- * in the first chunk. */
+ /** This tracks how much of the first four bytes has actually been accumulated. This is needed because we might not
+ * get all four bytes in the first chunk. */
private byte first4BytesIndex = 0;
- /** Tracks whether the input file is in ASCII hexadecimal format. If it is
- * false, then the input is in binary format. */
+ /** Tracks whether the input file is in ASCII hexadecimal format. If it is false, then the input is in binary
+ * format. */
private boolean hexFormat = false;
- /** Tracks whether we yet know what format the input file is in. It should
- * be set to false until we have analyzed the first four bytes. */
+ /** Tracks whether we yet know what format the input file is in. It should be set to false until we have analyzed
+ * the first four bytes. */
private boolean formatResolved = false;
/** Helper filter used to normalize input in ASCII hex format. */
@@ -129,8 +117,8 @@
/**
* Default constructor.
* @param encryptionKey The starting encryption key to use.
- * @param randomBytes The quantity of random bytes that should occur at the
- * beginning of the sequence to be processed.
+ * @param randomBytes The quantity of random bytes that should occur at the beginning of the sequence to be
+ * processed.
*/
public EexecDecodeFilter(final int encryptionKey, final byte randomBytes) {
this.encryptionKey = encryptionKey;
@@ -150,9 +138,8 @@
}
if (! this.formatResolved) {
resolveFormat(input);
- /* If the format is not yet resolved, it is because we don't have
- * all of the first 4 bytes yet. Fill the input array with spaces
- * and return it. */
+ /* If the format is not yet resolved, it is because we don't have all of the first 4 bytes yet.
+ * Fill the input array with spaces and return it. */
if (! this.formatResolved) {
for (int i = 0; i < input.length; i++) {
input[i] = ' ';
@@ -163,8 +150,7 @@
byte[] normalizedInput = input;
if (this.hexFormat) {
if (this.hexFilter == null) {
- final ByteArrayInputStream bais = new ByteArrayInputStream(
- input);
+ final ByteArrayInputStream bais = new ByteArrayInputStream(input);
this.hexFilter = new AsciiHexDecodeFilter(bais);
}
this.hexFilter.read();
@@ -187,8 +173,7 @@
* @return The decrypted value.
*/
private byte decrypt(final byte cipherText) {
- final byte temp = (byte) (this.encryptionKey
- >> PrimitiveConstants.SHIFT_1_BYTE);
+ final byte temp = (byte) (this.encryptionKey >> PrimitiveConstants.SHIFT_1_BYTE);
byte plainText = (byte) (cipherText ^ temp);
// The trick here is to get cipherText treated as unsigned
int unsignedCipherText = cipherText;
@@ -202,8 +187,7 @@
this.encryptionKey = (int) temp2;
/*
* The first few bytes of the decrypted text need to be discarded.
- * To avoid copying arrays around, we'll try to just replace them with
- * spaces.
+ * To avoid copying arrays around, we'll try to just replace them with spaces.
*/
if (this.randomBytesToDiscard > 0) {
plainText = ' ';
@@ -228,14 +212,12 @@
return;
}
/*
- * Otherwise, we have the first four bytes. Section 7.2 of the Adobe
- * Type 1 Font Format spec says that at least one of the first 4
- * ciphertext bytes must not be one of the ASCII hexadecimal
- * character codes (0-9, A-F, a-f). Since the binary format is one
- * byte per ciphertext byte, all we need to do is find one byte in
- * the first four that is outside the range for ASCII hexadecimal
- * codes. If we find that, then the file is binary. Otherwise it is
- * ASCII hexadecimal.
+ * Otherwise, we have the first four bytes. Section 7.2 of the Adobe Type 1 Font Format spec says that at least
+ * one of the first 4 ciphertext bytes must not be one of the ASCII hexadecimal character codes (0-9, A-F, a-f).
+ * Since the binary format is one byte per ciphertext byte, all we need to do is find one byte in the first four
+ * that is outside the range for ASCII hexadecimal codes.
+ * If we find that, then the file is binary.
+ * Otherwise it is ASCII hexadecimal.
*/
for (int i = 0; i < EexecDecodeFilter.EEXEC_INITIAL_BYTES; i++) {
if (! StringUtils.isASCIIHex(this.first4Bytes[i])) {
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/FlateDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/FlateDecodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/FlateDecodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -28,12 +28,16 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.zip.InflaterInputStream;
/**
- * A FlateDecodeFilter implementation.
+ * Decoding filter for {@link PsFilterType#FLATE}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public final class FlateDecodeFilter extends PsDecodeFilter4a {
@@ -67,10 +71,8 @@
/**
* Constructor.
- * @param inputStream The underlying input stream from which the encoded
- * data should be read.
- * Use {@link ByteArrayInputStream} if the encoded data is in a byte
- * array instead of a normal stream.
+ * @param inputStream The underlying input stream from which the encoded data should be read.
+ * Use {@link ByteArrayInputStream} if the encoded data is in a byte array instead of a normal stream.
*/
private FlateDecodeFilter(final InflaterInputStream inputStream) {
super(inputStream);
@@ -81,10 +83,8 @@
* @param inputStream The underlying input stream.
* @return The new FlateDecodeFilter instance.
*/
- public static FlateDecodeFilter makeFlateDecodeFilter(
- final InputStream inputStream) {
- final InflaterInputStream inflaterInputStream
- = new InflaterInputStream(inputStream);
+ public static FlateDecodeFilter makeFlateDecodeFilter(final InputStream inputStream) {
+ final InflaterInputStream inflaterInputStream = new InflaterInputStream(inputStream);
return new FlateDecodeFilter(inflaterInputStream);
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/FlateEncodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/FlateEncodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/FlateEncodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -28,6 +28,8 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -34,19 +36,19 @@
import java.util.zip.DeflaterOutputStream;
/**
- * This class applies a FlateEncode filter to the stream.
+ * Encoding filter for {@link PsFilterType#FLATE}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public final class FlateEncodeFilter extends PsEncodeFilter4a {
/**
* Constructor.
- * @param deflaterOutputStream The underlying output stream to which the
- * encoded data should be written.
- * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is
- * needed in a byte array instead of being written to an actual stream.
- * @param isApplied See
- * {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full
- * explanation of this parameter.
+ * @param deflaterOutputStream The underlying output stream to which the encoded data should be written.
+ * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is needed in a byte array instead of being
+ * written to an actual stream.
+ * @param isApplied See {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full explanation of
+ * this parameter.
*/
private FlateEncodeFilter(final DeflaterOutputStream deflaterOutputStream,
final boolean isApplied) {
@@ -56,13 +58,11 @@
/**
* Factory method to create a FlateEncodeFilter.
* @param outputStream The underlying output stream.
- * @param isApplied See
- * {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full
- * explanation of this parameter.
+ * @param isApplied See {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full explanation of
+ * this parameter.
* @return The new FlateEncodeFilter instance.
*/
- public static FlateEncodeFilter makeFlateEncodeFilter(
- final OutputStream outputStream, final boolean isApplied) {
+ public static FlateEncodeFilter makeFlateEncodeFilter(final OutputStream outputStream, final boolean isApplied) {
DeflaterOutputStream deflaterOutputStream = null;
if (outputStream != null) {
deflaterOutputStream = new DeflaterOutputStream(outputStream);
@@ -95,11 +95,9 @@
@Override
public void setOutputStream(final OutputStream outputStream) {
- /* This class interposes a DeflaterOutputStream, so that is the
- * stream that we need to set. The easiest way to do that seems to be
- * to create a new one. */
- final DeflaterOutputStream deflaterOutputStream
- = new DeflaterOutputStream(outputStream);
+ /* This class interposes a DeflaterOutputStream, so that is the stream that we need to set.
+ * The easiest way to do that seems to be to create a new one. */
+ final DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(outputStream);
this.out = deflaterOutputStream;
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsDecodeFilter4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsDecodeFilter4a.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsDecodeFilter4a.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -33,7 +33,8 @@
import java.io.InputStream;
/**
- * A PostScript filter object.
+ * Superclass for PostScript decode filters.
+ * @see "PostScript Language Reference, Third Edition, Section 3.8.4."
*/
public abstract class PsDecodeFilter4a extends FilterInputStream {
@@ -42,10 +43,8 @@
/**
* Constructor.
- * @param inputStream The underlying input stream from which the encoded
- * data should be read.
- * Use {@link ByteArrayInputStream} if the encoded data is in a byte
- * array instead of a normal stream.
+ * @param inputStream The underlying input stream from which the encoded data should be read.
+ * Use {@link ByteArrayInputStream} if the encoded data is in a byte array instead of a normal stream.
*/
public PsDecodeFilter4a(final InputStream inputStream) {
super(inputStream);
@@ -60,13 +59,11 @@
}
/**
- * Set the applied attribute to the given value. This attribute is
- * used to determine if this filter is just a placeholder for the
- * decodeparms and dictionary entries, or if the filter needs to
- * actually encode the data. For example if the raw data is copied
- * out of an image file in it's compressed format, then this
- * should be set to true and the filter options should be set to
- * those which the raw data was encoded with.
+ * Set the applied attribute to the given value.
+ * This attribute is used to determine if this filter is just a placeholder for the decodeparms and dictionary
+ * entries, or if the filter needs to actually encode the data.
+ * For example if the raw data is copied out of an image file in it's compressed format, then this should be set to
+ * true and the filter options should be set to those which the raw data was encoded with.
* @param b The new "applied" value.
*/
public void setApplied(final boolean b) {
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsEncodeFilter4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsEncodeFilter4a.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsEncodeFilter4a.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -34,7 +34,8 @@
import java.io.OutputStream;
/**
- * A PostScript filter object.
+ * Superclass for PostScript encode filters.
+ * @see "PostScript Language Reference, Third Edition, Section 3.8.4."
*/
public abstract class PsEncodeFilter4a extends PsEncodeFilter {
@@ -43,19 +44,15 @@
/**
* Constructor.
- * @param outputStream The underlying output stream to which the encoded
- * data should be written.
- * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is
- * needed in a byte array instead of being written to an actual stream.
+ * @param outputStream The underlying output stream to which the encoded data should be written.
+ * Use {@link ByteArrayOutputStream#toByteArray()} if the encoded data is needed in a byte array instead of being
+ * written to an actual stream.
* @param isApplied Indicates whether this filter has already been applied.
- * If set to "true" this filter makes no changes to the data, but simply
- * passes it through.
- * This is useful in cases where a stack of encoding filters must be
- * decoded in the opposite order and the stack itself is used to indicate
- * that decoding.
- * For example if the raw data is copied out of an image file in its
- * compressed format, then this should be set to true and the filter options
- * should be set to those which the raw data was encoded with.
+ * If set to "true" this filter makes no changes to the data, but simply passes it through.
+ * This is useful in cases where a stack of encoding filters must be decoded in the opposite order and the stack
+ * itself is used to indicate that decoding.
+ * For example if the raw data is copied out of an image file in its compressed format, then this should be set to
+ * true and the filter options should be set to those which the raw data was encoded with.
*/
public PsEncodeFilter4a(final OutputStream outputStream, final boolean isApplied) {
super(outputStream);
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/RunLengthDecodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/RunLengthDecodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/RunLengthDecodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -28,20 +28,22 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
/**
- * A RunLengthDecode filter.
+ * Decoding filter for {@link PsFilterType#RUN_LENGTH}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class RunLengthDecodeFilter extends PsDecodeFilter4a {
/**
* Constructor.
- * @param inputStream The underlying input stream from which the encoded
- * data should be read.
- * Use {@link ByteArrayInputStream} if the encoded data is in a byte
- * array instead of a normal stream.
+ * @param inputStream The underlying input stream from which the encoded data should be read.
+ * Use {@link ByteArrayInputStream} if the encoded data is in a byte array instead of a normal stream.
*/
public RunLengthDecodeFilter(final InputStream inputStream) {
super(inputStream);
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/RunLengthEncodeFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/RunLengthEncodeFilter.java 2025-05-27 11:08:36 UTC (rev 13752)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/RunLengthEncodeFilter.java 2025-05-27 15:02:27 UTC (rev 13753)
@@ -33,16 +33,19 @@
package org.foray.ps.filter;
+import org.axsl.ps.PsFilterType;
+
import java.io.IOException;
import java.io.OutputStream;
/**
- * Acts as either a RunLengthEncode Filter or a RunLengthDecode filter.
+ * Encoding filter for {@link PsFilterType#RUN_LENGTH}.
+ * Static methods are available for processing entire arrays.
+ * @see "PostScript Language Reference, Third Edition, Section 3.13.3."
*/
public class RunLengthEncodeFilter extends PsEncodeFilter4a {
- /** The number of bytes necessary to know before we know whether we have
- * a sequence or not. */
+ /** The number of bytes necessary to know before we know whether we have a sequence or not. */
private static final int QTY_START_SEQUENCE_HEADER_BYTES = 3;
/** The maximum number of bytes that can be encoded in one run. */
@@ -78,11 +81,9 @@
/**
* Constructor.
- * @param encodeStream The output stream to which the encoded data should
- * be written.
- * @param isApplied See
- * {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full
- * explanation of this parameter.
+ * @param encodeStream The output stream to which the encoded data should be written.
+ * @param isApplied See {@link PsEncodeFilter4a#PsEncodeFilter4a(OutputStream, boolean)} for a full explanation of
+ * this parameter.
*/
public RunLengthEncodeFilter(final OutputStream encodeStream,
final boolean isApplied) {
@@ -145,8 +146,7 @@
break;
case RunLengthEncodeFilter.MAX_SEQUENCE_COUNT:
if (this.isSequence == RunLengthEncodeFilter.IN_SEQUENCE) {
- out.write(RunLengthEncodeFilter.BYTE_MAX
- - (RunLengthEncodeFilter.MAX_SEQUENCE_COUNT - 1));
+ out.write(RunLengthEncodeFilter.BYTE_MAX - (RunLengthEncodeFilter.MAX_SEQUENCE_COUNT - 1));
out.write(this.runBuffer[this.runCount - 1]);
this.runBuffer[0] = this.runBuffer[this.runCount];
this.runCount = 1;
@@ -160,38 +160,30 @@
default:
switch (this.isSequence) {
case RunLengthEncodeFilter.IN_SEQUENCE:
- if (this.runBuffer[this.runCount]
- != this.runBuffer[this.runCount - 1]) {
- out.write(RunLengthEncodeFilter.BYTE_MAX
- - (this.runCount - 1));
+ if (this.runBuffer[this.runCount] != this.runBuffer[this.runCount - 1]) {
+ out.write(RunLengthEncodeFilter.BYTE_MAX - (this.runCount - 1));
out.write(this.runBuffer[this.runCount - 1]);
this.runBuffer[0] = this.runBuffer[this.runCount];
this.runCount = 1;
- this.isSequence =
- RunLengthEncodeFilter.NOT_IDENTIFY_SEQUENCE;
+ this.isSequence = RunLengthEncodeFilter.NOT_IDENTIFY_SEQUENCE;
break;
}
this.runCount++;
break;
case RunLengthEncodeFilter.NOT_IN_SEQUENCE:
- if (this.runBuffer[this.runCount]
- == this.runBuffer[this.runCount - 1]) {
+ if (this.runBuffer[this.runCount] == this.runBuffer[this.runCount - 1]) {
this.isSequence = RunLengthEncodeFilter.START_SEQUENCE;
}
this.runCount++;
break;
case RunLengthEncodeFilter.START_SEQUENCE:
- if (this.runBuffer[this.runCount]
- == this.runBuffer[this.runCount - 1]) {
- out.write(this.runCount
- - RunLengthEncodeFilter
- .QTY_START_SEQUENCE_HEADER_BYTES);
+ if (this.runBuffer[this.runCount] == this.runBuffer[this.runCount - 1]) {
+ out.write(this.runCount - RunLengthEncodeFilter.QTY_START_SEQUENCE_HEADER_BYTES);
out.write(this.runBuffer, 0, this.runCount - 2);
this.runBuffer[0] = this.runBuffer[this.runCount];
this.runBuffer[1] = this.runBuffer[this.runCount];
this.runBuffer[2] = this.runBuffer[this.runCount];
- this.runCount = RunLengthEncodeFilter
- .QTY_START_SEQUENCE_HEADER_BYTES;
+ this.runCount = RunLengthEncodeFilter.QTY_START_SEQUENCE_HEADER_BYTES;
this.isSequence = RunLengthEncodeFilter.IN_SEQUENCE;
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-27 11:08:41
|
Revision: 13752
http://sourceforge.net/p/foray/code/13752
Author: victormote
Date: 2025-05-27 11:08:36 +0000 (Tue, 27 May 2025)
Log Message:
-----------
Conform to aXSL change: Use InputStream instead of File as basis for PsInput.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformEps.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInputFile.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/java2d/demo/DemoPanel.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformEps.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformEps.java 2025-05-26 21:33:23 UTC (rev 13751)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformEps.java 2025-05-27 11:08:36 UTC (rev 13752)
@@ -44,6 +44,7 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
/**
@@ -69,9 +70,10 @@
final File file = new File(getGraphic().getUrl().getFile());
PsInput psInput = null;
try {
- psInput = doc.getPsServer().createPsInput(file);
+ final FileInputStream fis = new FileInputStream(file);
+ psInput = doc.getPsServer().createPsInput(fis);
} catch (final IOException e) {
- throw new GraphicException("Cannot open EPS file.");
+ throw new GraphicException(e);
}
final PsServer psServer = doc.getPsServer();
PsSystemDict systemDict = null;
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInputFile.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInputFile.java 2025-05-26 21:33:23 UTC (rev 13751)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInputFile.java 2025-05-27 11:08:36 UTC (rev 13752)
@@ -38,7 +38,6 @@
import org.axsl.primitive.sequence.ByteSequence;
import org.axsl.ps.PsInput;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -53,13 +52,11 @@
/**
* Basic constructor.
- * @param psFile The File instance that should be used as standard input
- * to the PsInterpreter.
+ * @param input The File instance that should be used as standard input to the PsInterpreter.
* @throws IOException If the file cannot be opened for use.
*/
- public PsInputFile(final File psFile) throws IOException {
- this.in = new java.io.BufferedInputStream(
- new java.io.FileInputStream(psFile));
+ public PsInputFile(final InputStream input) throws IOException {
+ this.in = new java.io.BufferedInputStream(input);
}
@Override
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-05-26 21:33:23 UTC (rev 13751)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-05-27 11:08:36 UTC (rev 13752)
@@ -41,7 +41,6 @@
import org.axsl.ps.PsServer;
import java.awt.Graphics2D;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -51,8 +50,8 @@
public class PsServer4a implements PsServer {
@Override
- public PsInput createPsInput(final File inputFile) throws IOException {
- return new PsInputFile(inputFile);
+ public PsInput createPsInput(final InputStream input) throws IOException {
+ return new PsInputFile(input);
}
@Override
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/java2d/demo/DemoPanel.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/java2d/demo/DemoPanel.java 2025-05-26 21:33:23 UTC (rev 13751)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/java2d/demo/DemoPanel.java 2025-05-27 11:08:36 UTC (rev 13752)
@@ -42,6 +42,7 @@
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import javax.swing.JOptionPane;
@@ -126,8 +127,9 @@
g2d.scale(2, 2);
final File file = new File(this.fileName);
+ final FileInputStream fis = new FileInputStream(file);
PsInputFile eps = null;
- eps = new PsInputFile(file);
+ eps = new PsInputFile(fis);
final Java2dSystemDict j2dSystemDict = new Java2dSystemDict(g2d);
final PsInterpreter4a interpreter = new PsInterpreter4a(eps, j2dSystemDict);
interpreter.process();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-26 21:33:26
|
Revision: 13751
http://sourceforge.net/p/foray/code/13751
Author: victormote
Date: 2025-05-26 21:33:23 +0000 (Mon, 26 May 2025)
Log Message:
-----------
Remove PdfDocument from finalize and related methods.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfContentStream4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/filespec/PdfEmbeddedFileStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfIccProfileStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfGenericStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCmap.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontFileStream.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfToUnicodeCmap.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfContentStream4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfContentStream4a.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfContentStream4a.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -341,7 +341,7 @@
}
@Override
- protected void finalizeStreamContent(final PdfDocument4a doc) {
+ protected void finalizeStreamContent() {
/* Nothing needs to be done here. */
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/filespec/PdfEmbeddedFileStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/filespec/PdfEmbeddedFileStream.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/filespec/PdfEmbeddedFileStream.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -62,7 +62,7 @@
}
@Override
- protected void finalizeStreamContent(final PdfDocument4a doc) {
+ protected void finalizeStreamContent() {
/* Nothing needs to be done here. */
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfIccProfileStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfIccProfileStream.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfIccProfileStream.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -52,7 +52,7 @@
}
@Override
- protected void finalizeStreamContent(final PdfDocument4a doc) throws PdfException {
+ protected void finalizeStreamContent() throws PdfException {
write(this.cs.getProfile().getData());
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -248,7 +248,7 @@
}
@Override
- protected void finalizeStreamContent(final PdfDocument4a doc) {
+ protected void finalizeStreamContent() {
/* Nothing needs to be done here. */
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfGenericStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfGenericStream.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfGenericStream.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -57,9 +57,8 @@
}
@Override
- protected void finalizeStreamContent(final PdfDocument4a doc) {
+ protected void finalizeStreamContent() {
// TODO Auto-generated method stub
-
}
@Override
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCmap.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCmap.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCmap.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -350,7 +350,7 @@
}
@Override
- protected void finalizeStreamContent(final PdfDocument4a doc) throws PdfException {
+ protected void finalizeStreamContent() throws PdfException {
final StringBuilder builder = new StringBuilder();
writePreStream(builder);
writeStreamComments(builder);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontFileStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontFileStream.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontFileStream.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -58,14 +58,14 @@
}
@Override
- protected void finalizeStreamContent(final PdfDocument4a doc) throws PdfException {
+ protected void finalizeStreamContent() throws PdfException {
final ByteSequence fontFileStream = this.font.getContent();
/* TODO: The addition of the filters below was prohibited by the parent class, PdfStream, because content
* had already been written into the stream without them. There is perhaps some sequencing problem that has
* resulted from the one-step serialization process recently (Dec 2020) implemented. */
/* The first filter specified is the last one applied. */
- addFilter("ascii-85", doc);
- addFilter("flate", doc);
+ addFilter("ascii-85");
+ addFilter("flate");
write(fontFileStream);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfToUnicodeCmap.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfToUnicodeCmap.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfToUnicodeCmap.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -28,8 +28,6 @@
package org.foray.pdf.text;
-import org.foray.pdf.document.PdfDocument4a;
-
import org.axsl.constants.PrimitiveConstants;
import org.axsl.font.FontUse;
import org.axsl.pdf.PdfException;
@@ -94,7 +92,7 @@
}
@Override
- protected void finalizeStreamContent(final PdfDocument4a doc) throws PdfException {
+ protected void finalizeStreamContent() throws PdfException {
final StringBuilder builder = new StringBuilder();
writeCIDInit(builder);
writeCIDSystemInfo(builder);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-26 17:44:45 UTC (rev 13750)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-26 21:33:23 UTC (rev 13751)
@@ -173,15 +173,13 @@
/**
* Adds a filter of the specified type to this stream.
- * Note that the filters should be added in reverse order, that is the last
- * filter to be applied should be added first.
- * @param filterType The type of filter to add, one of "flate", "ascii-85",
- * or "ascii-hex".
- * @param doc The PDF document.
+ * Note that the filters should be added in reverse order, that is the last filter to be applied should be added
+ * first.
+ * @param filterType The type of filter to add, one of "flate", "ascii-85", or "ascii-hex".
* @return The newly-created filter.
* @throws PdfException For errors while adding the filter.
*/
- public PsEncodeFilter addFilter(final String filterType, final PdfDocument4a doc) throws PdfException {
+ public PsEncodeFilter addFilter(final String filterType) throws PdfException {
if (filterType == null
|| "".equals(filterType)) {
return null;
@@ -213,7 +211,7 @@
final List<String> filters = doc.getDefaultFilters();
for (int i = 0; i < filters.size(); i++) {
final String filterToAdd = filters.get(i);
- addFilter(filterToAdd, doc);
+ addFilter(filterToAdd);
}
}
@@ -237,7 +235,7 @@
@Override
public int serialize(final OutputStream stream, final PdfDocument4a doc) throws PdfException {
/* Give subclasses an opportunity to finish writing to the stream content. */
- finalizeStreamContent(doc);
+ finalizeStreamContent();
int length = 0;
final String filterEntry = applyFilters();
@@ -276,10 +274,9 @@
* This method is an explicit opportunity for subclasses to finish writing
* whatever content may still need to be written to the stream before the
* dictionary and stream contents are written.
- * @param doc The PDF document.
* @throws PdfException For errors writing stream content.
*/
- protected abstract void finalizeStreamContent(PdfDocument4a doc) throws PdfException;
+ protected abstract void finalizeStreamContent() throws PdfException;
/**
* Subclasses return any specialized dictionary entries here, so that they
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-26 17:44:48
|
Revision: 13750
http://sourceforge.net/p/foray/code/13750
Author: victormote
Date: 2025-05-26 17:44:45 +0000 (Mon, 26 May 2025)
Log Message:
-----------
Conform to aXSL changes: Remove methods to obtain filters from the PsServer. These should be obtained some other way.
Modified Paths:
--------------
trunk/foray/foray-app/src/main/java/org/foray/app/OutputTargetFactory.java
trunk/foray/foray-pdf/build.gradle
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsFilter.java
trunk/foray/foray-render/build.gradle
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
Modified: trunk/foray/foray-app/src/main/java/org/foray/app/OutputTargetFactory.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/app/OutputTargetFactory.java 2025-05-26 16:40:12 UTC (rev 13749)
+++ trunk/foray/foray-app/src/main/java/org/foray/app/OutputTargetFactory.java 2025-05-26 17:44:45 UTC (rev 13750)
@@ -89,8 +89,7 @@
break;
}
case PS: {
- final PsServer psServer = new PsServer4a();
- renderer = new PsRenderer(outputOptions, psServer);
+ renderer = new PsRenderer(outputOptions);
break;
}
case TXT: {
Modified: trunk/foray/foray-pdf/build.gradle
===================================================================
--- trunk/foray/foray-pdf/build.gradle 2025-05-26 16:40:12 UTC (rev 13749)
+++ trunk/foray/foray-pdf/build.gradle 2025-05-26 17:44:45 UTC (rev 13750)
@@ -22,9 +22,9 @@
api (project(':foray-common'))
implementation (project(':foray-primitive'))
implementation (project(':foray-pdf-core'))
+ implementation (project(":foray-ps-data"))
testImplementation (project(':foray-font'))
- testImplementation (project(":foray-ps-data"))
}
javadoc {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-26 16:40:12 UTC (rev 13749)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-26 17:44:45 UTC (rev 13750)
@@ -36,6 +36,7 @@
import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfStream;
+import org.foray.ps.filter.PsFilter;
import org.axsl.font.FontConsumer;
import org.axsl.graphic.BitmapGraphic;
@@ -49,8 +50,6 @@
import org.axsl.pdf.PdfException;
import org.axsl.pdf.PdfXobject;
import org.axsl.ps.PsEncodeFilter;
-import org.axsl.ps.PsFilterType;
-import org.axsl.ps.PsServer;
import java.io.OutputStream;
@@ -126,7 +125,7 @@
} else {
throw new GraphicException("Unsupported Graphic Type: " + img.getFormat());
}
- xObject.filter = xObject.getFilter(xObject.getOutputStream(), pdfDoc);
+ xObject.filter = xObject.getFilter(xObject.getOutputStream());
return xObject;
}
@@ -161,17 +160,14 @@
/**
* Return an appropriate compression filter for the Graphic.
* @param outputStream The output stream into which the compressed data should be written.
- * @param doc The PDF document.
* @return An appropriate compression filter, or null if no compression should be used.
* @throws GraphicException For error reading Graphic file.
*/
- private PsEncodeFilter getFilter(final OutputStream outputStream, final PdfDocument4a doc)
- throws GraphicException {
- final PsServer psServer = doc.getPsServer();
+ private PsEncodeFilter getFilter(final OutputStream outputStream) throws GraphicException {
PsEncodeFilter filter = null;
final Graphic graphic = this.getGraphic();
if (graphic.getFormat() == GraphicFormat.JPEG) {
- filter = psServer.createEncodeFilter(PsFilterType.DCT, outputStream);
+ filter = PsFilter.DCT.makeEncodeFilter(outputStream, false);
filter.setInactive();
return filter;
}
@@ -182,16 +178,16 @@
case UNCOMPRESSED:
return null;
case CCITT_GROUP_3:
- filter = psServer.createEncodeFilter(PsFilterType.CCITT_FAX, outputStream);
+ filter = PsFilter.CCITT_FAX.makeEncodeFilter(outputStream, false);
filter.setInactive();
return filter;
case CCITT_GROUP_4:
- filter = psServer.createEncodeFilter(PsFilterType.CCITT_FAX, outputStream);
+ filter = PsFilter.CCITT_FAX.makeEncodeFilter(outputStream, false);
filter.setInactive();
filter.setDecodeParms("<< /K -1 /Columns " + graphic.getPixelWidth() + " >>");
return filter;
case JPEG:
- filter = psServer.createEncodeFilter(PsFilterType.DCT, outputStream);
+ filter = PsFilter.DCT.makeEncodeFilter(outputStream, false);
filter.setInactive();
return filter;
default:
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-26 16:40:12 UTC (rev 13749)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-26 17:44:45 UTC (rev 13750)
@@ -30,12 +30,12 @@
import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.encrypt.PdfEncryption4a;
+import org.foray.ps.filter.PsFilter;
import org.axsl.pdf.PdfException;
import org.axsl.primitive.sequence.ByteSequence;
import org.axsl.primitive.sequence.ByteSequencePlus;
import org.axsl.ps.PsEncodeFilter;
-import org.axsl.ps.PsFilterType;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -190,20 +190,12 @@
throw new PdfException("Cannot add filters to PdfStream after "
+ "content has been written to the stream.");
}
- PsFilterType psFilterType = null;
- if (filterType.equals("flate")) {
- psFilterType = PsFilterType.FLATE;
- } else if (filterType.equals("ascii-85")) {
- psFilterType = PsFilterType.ASCII_85;
- } else if (filterType.equals("ascii-hex")) {
- psFilterType = PsFilterType.ASCII_HEX;
- } else {
- throw new PdfException("Unsupported filter type in pdf-filters: " + filterType);
+ final PsFilter filter = PsFilter.findFilter(filterType);
+ final PsEncodeFilter encodeFilter = filter.makeEncodeFilter(this.out, false);
+ if (encodeFilter != null) {
+ this.out = encodeFilter;
+ this.filters.add(encodeFilter);
}
- final PsEncodeFilter encodeFilter = doc.getPsServer().createEncodeFilter(psFilterType,
- this.out);
- this.out = encodeFilter;
- this.filters.add(encodeFilter);
return encodeFilter;
}
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-05-26 16:40:12 UTC (rev 13749)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-05-26 17:44:45 UTC (rev 13750)
@@ -31,19 +31,6 @@
import org.foray.primitive.sequence.IntArrayBuilder;
import org.foray.ps.encode.CharSet4a;
import org.foray.ps.encode.CharSetParser;
-import org.foray.ps.filter.Ascii85DecodeFilter;
-import org.foray.ps.filter.Ascii85EncodeFilter;
-import org.foray.ps.filter.AsciiHexDecodeFilter;
-import org.foray.ps.filter.AsciiHexEncodeFilter;
-import org.foray.ps.filter.CcittFaxDecodeFilter;
-import org.foray.ps.filter.CcittFaxEncodeFilter;
-import org.foray.ps.filter.DctDecodeFilter;
-import org.foray.ps.filter.DctEncodeFilter;
-import org.foray.ps.filter.FlateDecodeFilter;
-import org.foray.ps.filter.FlateEncodeFilter;
-import org.foray.ps.filter.PsEncodeFilter4a;
-import org.foray.ps.filter.RunLengthDecodeFilter;
-import org.foray.ps.filter.RunLengthEncodeFilter;
import org.foray.ps.java2d.Java2dSystemDict;
import org.foray.ps.pdf.PdfSystemDict;
import org.foray.ps.readonly.ReadOnlySystemDict;
@@ -50,7 +37,6 @@
import org.axsl.ps.CharSet;
import org.axsl.ps.PsException;
-import org.axsl.ps.PsFilterType;
import org.axsl.ps.PsInput;
import org.axsl.ps.PsServer;
@@ -58,7 +44,6 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
/**
* Implementation of {@link PsServer} for FOray.
@@ -66,60 +51,6 @@
public class PsServer4a implements PsServer {
@Override
- public InputStream createDecodeFilter(final PsFilterType filterType, final InputStream inputStream) {
- switch (filterType) {
- case ASCII_85: {
- return new Ascii85DecodeFilter(inputStream);
- }
- case ASCII_HEX: {
- return new AsciiHexDecodeFilter(inputStream);
- }
- case CCITT_FAX: {
- return new CcittFaxDecodeFilter(inputStream);
- }
- case DCT: {
- return new DctDecodeFilter(inputStream);
- }
- case FLATE: {
- return FlateDecodeFilter.makeFlateDecodeFilter(inputStream);
- }
- case RUN_LENGTH: {
- return new RunLengthDecodeFilter(inputStream);
- }
- default: {
- throw new IllegalArgumentException("Unexpected filter type: " + filterType);
- }
- }
- }
-
- @Override
- public PsEncodeFilter4a createEncodeFilter(final PsFilterType filterType, final OutputStream outputStream) {
- switch (filterType) {
- case ASCII_85: {
- return new Ascii85EncodeFilter(outputStream, false);
- }
- case ASCII_HEX: {
- return new AsciiHexEncodeFilter(outputStream, false);
- }
- case CCITT_FAX: {
- return new CcittFaxEncodeFilter(outputStream, false);
- }
- case DCT: {
- return new DctEncodeFilter(outputStream, false);
- }
- case FLATE: {
- return FlateEncodeFilter.makeFlateEncodeFilter(outputStream, false);
- }
- case RUN_LENGTH: {
- return new RunLengthEncodeFilter(outputStream, false);
- }
- default: {
- throw new IllegalArgumentException("Unexpected filter type: " + filterType);
- }
- }
- }
-
- @Override
public PsInput createPsInput(final File inputFile) throws IOException {
return new PsInputFile(inputFile);
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsFilter.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsFilter.java 2025-05-26 16:40:12 UTC (rev 13749)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/PsFilter.java 2025-05-26 17:44:45 UTC (rev 13750)
@@ -45,7 +45,7 @@
public enum PsFilter {
/** An unknown filter type. */
- UNKNOWN("", null) {
+ UNKNOWN("", new String[] {}) {
@Override
public PsEncodeFilter4a makeEncodeFilter(final OutputStream outputStream,
@@ -93,7 +93,7 @@
},
/** An LZW filter. */
- LZW("LZW", null) {
+ LZW("LZW", new String[] {}) {
@Override
public PsEncodeFilter4a makeEncodeFilter(final OutputStream outputStream,
@@ -109,7 +109,7 @@
},
/** A Run Length filter. */
- RUN_LENGTH("RunLength", null) {
+ RUN_LENGTH("RunLength", new String[] {}) {
@Override
public PsEncodeFilter4a makeEncodeFilter(final OutputStream outputStream,
@@ -125,7 +125,7 @@
},
/** A CCITT Fax filter. */
- CCITT_FAX("CCITTFax", null) {
+ CCITT_FAX("CCITTFax", new String[] {}) {
@Override
public PsEncodeFilter4a makeEncodeFilter(final OutputStream outputStream,
@@ -141,7 +141,7 @@
},
/** A DCT (JPEG) filter. */
- DCT("DCT", null) {
+ DCT("DCT", new String[] {}) {
@Override
public PsEncodeFilter4a makeEncodeFilter(final OutputStream outputStream,
@@ -157,7 +157,7 @@
},
/** A Flate (zlib) filter. */
- FLATE("Flate", null) {
+ FLATE("Flate", new String[] {"flate"}) {
@Override
public PsEncodeFilter4a makeEncodeFilter(final OutputStream outputStream,
@@ -176,8 +176,7 @@
/** The minimum number of arguments on the command-line. */
private static final int CL_MIN_ARGS = 3;
- /** The postscript name of the filter, minus the "Encode" or "Decode"
- * suffix.*/
+ /** The postscript name of the filter, minus the "Encode" or "Decode" suffix.*/
private String psName;
/** Other names by which the filter might be identifed. */
@@ -185,8 +184,7 @@
/**
* Private Constructor.
- * @param psName The PostScript name of the filter, minus the "Encode" or
- * "Decode" suffix.
+ * @param psName The PostScript name of the filter, minus the "Encode" or "Decode" suffix.
* @param otherNames Other names by which the filter might be identified.
*/
PsFilter(final String psName, final String[] otherNames) {
@@ -197,8 +195,7 @@
/**
* Returns the PsFilter associated with a given name.
* @param filterName The name of the filter to be returned.
- * @return The PsFilter associated with {@code filterName}, or null if
- * there is none found.
+ * @return The PsFilter associated with {@code filterName}, or null if there is none found.
*/
public static PsFilter findFilter(final String filterName) {
if (filterName == null
@@ -227,14 +224,12 @@
/**
* Make an Encode filter for this filter type.
- * @param outputStream The output stream to which the filter output should
- * be written.
- * @param isApplied Set to true if the filter has already been applied to
- * the content and should not be applied again.
+ * @param outputStream The output stream to which the filter output should be written.
+ * @param isApplied Set to true if the filter has already been applied to the content and should not be applied
+ * again.
* @return The newly created Encode filter.
*/
- public abstract PsEncodeFilter4a makeEncodeFilter(OutputStream outputStream,
- boolean isApplied);
+ public abstract PsEncodeFilter4a makeEncodeFilter(OutputStream outputStream, boolean isApplied);
/**
* Make an Decode filter for this filter type.
Modified: trunk/foray/foray-render/build.gradle
===================================================================
--- trunk/foray/foray-render/build.gradle 2025-05-26 16:40:12 UTC (rev 13749)
+++ trunk/foray/foray-render/build.gradle 2025-05-26 17:44:45 UTC (rev 13750)
@@ -24,6 +24,7 @@
implementation (project(':foray-common'))
implementation (project(':foray-primitive'))
api (project(':foray-output'))
+ api (project(':foray-ps-data'))
}
javadoc {
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-26 16:40:12 UTC (rev 13749)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-26 17:44:45 UTC (rev 13750)
@@ -37,6 +37,7 @@
import org.foray.common.CharacterOutputStream;
import org.foray.primitive.StringUtils;
import org.foray.primitive.sequence.ByteArray;
+import org.foray.ps.filter.PsFilter;
import org.foray.render.PrintRenderer;
import org.axsl.constants.MimeConstants;
@@ -70,8 +71,6 @@
import org.axsl.ps.BoundingBox;
import org.axsl.ps.Encoding;
import org.axsl.ps.EncodingVector;
-import org.axsl.ps.PsFilterType;
-import org.axsl.ps.PsServer;
import org.axsl.value.RuleStyle;
import java.awt.Color;
@@ -178,9 +177,6 @@
*/
private Map<FontUse, PsFont> fontMap = new HashMap<FontUse, PsFont>();
- /** The PostScript server. */
- private PsServer psServer;
-
/** The user configuration for this output. */
private DocumentConfiguration configuration;
@@ -187,10 +183,8 @@
/**
* Constructor.
* @param renderConfig The configuration for this renderer.
- * @param psServer The PostScript server to be used for this render process.
*/
- public PsRenderer(final DocumentConfiguration renderConfig, final PsServer psServer) {
- this.psServer = psServer;
+ public PsRenderer(final DocumentConfiguration renderConfig) {
this.configuration = renderConfig;
}
@@ -805,14 +799,14 @@
*/
// imgmap[0] = 1;
OutputStream out = this.out;
- out = this.psServer.createEncodeFilter(PsFilterType.ASCII_85, out);
+ out = PsFilter.ASCII_85.makeEncodeFilter(out, false);
if (img.getFormat() == GraphicFormat.JPEG) {
//nop
} else {
if (this.psLevel >= PsRenderer.POSTSCRIPT_LEVEL_3) {
- out = this.psServer.createEncodeFilter(PsFilterType.FLATE, out);
+ out = PsFilter.FLATE.makeEncodeFilter(out, false);
} else {
- out = this.psServer.createEncodeFilter(PsFilterType.RUN_LENGTH, out);
+ out = PsFilter.RUN_LENGTH.makeEncodeFilter(out, false);
}
}
for (int index = 0; index < imgmap.length(); index ++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-26 16:40:15
|
Revision: 13749
http://sourceforge.net/p/foray/code/13749
Author: victormote
Date: 2025-05-26 16:40:12 +0000 (Mon, 26 May 2025)
Log Message:
-----------
Move PostScript filters to ps-data project.
Added Paths:
-----------
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/filter/
Removed Paths:
-------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-26 15:48:53
|
Revision: 13748
http://sourceforge.net/p/foray/code/13748
Author: victormote
Date: 2025-05-26 15:48:49 +0000 (Mon, 26 May 2025)
Log Message:
-----------
Fix build problem.
Modified Paths:
--------------
trunk/foray/foray-pdf-parse/build.gradle
Modified: trunk/foray/foray-pdf-parse/build.gradle
===================================================================
--- trunk/foray/foray-pdf-parse/build.gradle 2025-05-26 12:56:34 UTC (rev 13747)
+++ trunk/foray/foray-pdf-parse/build.gradle 2025-05-26 15:48:49 UTC (rev 13748)
@@ -12,6 +12,7 @@
implementation (project(':foray-common'))
implementation (project(':foray-pdf-core'))
+ implementation (project(':foray-primitive'))
}
javadoc {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-26 12:56:36
|
Revision: 13747
http://sourceforge.net/p/foray/code/13747
Author: victormote
Date: 2025-05-26 12:56:34 +0000 (Mon, 26 May 2025)
Log Message:
-----------
Progress toward an independent PDF Parser.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfParser.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java
trunk/foray/foray-pdf-core/build.gradle
trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfConstants.java
trunk/foray/foray-pdf-parse/build.gradle
trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java
trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java
Added Paths:
-----------
trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfParserConstants.java
trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfRandomAccessInput.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfParser.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfParser.java 2025-05-26 11:28:40 UTC (rev 13746)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfParser.java 2025-05-26 12:56:34 UTC (rev 13747)
@@ -29,9 +29,9 @@
package org.foray.pdf.serial;
import org.foray.common.data.ByteSequenceTokenizer;
-import org.foray.common.data.ByteSequenceTokenizerConfig;
import org.foray.pdf.PdfConstants;
import org.foray.pdf.PdfObjectReference;
+import org.foray.pdf.PdfParserConstants;
import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfArray;
@@ -57,8 +57,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.List;
import java.util.Stack;
/**
@@ -69,37 +67,6 @@
*/
public class PdfParser {
- /** The standard tokenizer configuration for parsing a PDF. */
- public static final ByteSequenceTokenizerConfig STD_TOKENIZER_CONFIG =
- new ByteSequenceTokenizerConfig(PdfConstants.PDF_DELIMITERS, PdfConstants.PDF_WHITESPACE, null, null);
-
- /** Delimiters for parsing literal PDF strings. */
- public static final List<ByteArray> PDF_TEXT_DELIMITERS = Arrays.asList(
- PdfConstants.CLOSE_STRING_LITERAL
- );
-
- /** Delimiter balancers for parsing literal PDF strings. */
- public static final List<ByteArray> PDF_TEXT_DELIMITER_BALANCERS = Arrays.asList(
- PdfConstants.OPEN_STRING_LITERAL
- );
-
- /** Delimiters for parsing literal PDF streams. */
- public static final List<ByteArray> PDF_STREAM_DELIMITERS = Arrays.asList(
- PdfConstants.KEYWORD_END_STREAM
- );
-
- /** The tokenizer configuration for parsing PDF text. */
- public static final ByteSequenceTokenizerConfig TEXT_TOKENIZER_CONFIG = new ByteSequenceTokenizerConfig(
- PDF_TEXT_DELIMITERS, null, PdfConstants.TEXT_ESCAPE_CHARS, PDF_TEXT_DELIMITER_BALANCERS);
-
- /** The tokenizer configuration for parsing a PDF comment. Just looking for the end of the line. */
- public static final ByteSequenceTokenizerConfig COMMENT_TOKENIZER_CONFIG =
- new ByteSequenceTokenizerConfig(PdfConstants.PDF_END_OF_LINE_DELIMITERS, null, null, null);
-
- /** The tokenizer configuration for parsing a PDF stream. */
- public static final ByteSequenceTokenizerConfig STREAM_TOKENIZER_CONFIG =
- new ByteSequenceTokenizerConfig(PDF_STREAM_DELIMITERS, null, null, null);
-
/** The raw document bytes. */
private ByteSequencePlus source;
@@ -195,7 +162,8 @@
PdfConstants.CLOSE_DICTIONARY.length();
final ByteSequenceSubset parseArea =
new ByteSequenceSubset(source, trailerDictStart, trailerDictEnd - trailerDictStart);
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(parseArea, STD_TOKENIZER_CONFIG);
+ final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(parseArea,
+ PdfParserConstants.STD_TOKENIZER_CONFIG);
final PdfObject trailerObject = this.parseObject(tokenizer);
if (trailerObject instanceof PdfTrailer) {
return (PdfTrailer) trailerObject;
@@ -228,7 +196,7 @@
/* We only expect indirect objects here. */
parseArea = new ByteSequenceSubset(source, objectStart, source.length() - objectStart);
- tokenizer = new ByteSequenceTokenizer(parseArea, STD_TOKENIZER_CONFIG);
+ tokenizer = new ByteSequenceTokenizer(parseArea, PdfParserConstants.STD_TOKENIZER_CONFIG);
PdfObject parsedObject = null;
try {
parsedObject = parseObject(tokenizer);
@@ -302,33 +270,33 @@
if (mode == TokenizerMode.STANDARD) {
if (PdfConstants.OPEN_COMMENT.equals(token)) {
mode = TokenizerMode.COMMENT;
- tokenizer.setConfig(COMMENT_TOKENIZER_CONFIG);
+ tokenizer.setConfig(PdfParserConstants.COMMENT_TOKENIZER_CONFIG);
} else if (PdfConstants.OPEN_STRING_LITERAL.equals(token)) {
mode = TokenizerMode.LITERAL_TEXT;
- tokenizer.setConfig(TEXT_TOKENIZER_CONFIG);
+ tokenizer.setConfig(PdfParserConstants.TEXT_TOKENIZER_CONFIG);
} else if (PdfConstants.KEYWORD_START_STREAM.equals(token)) {
mode = TokenizerMode.STREAM;
- tokenizer.setConfig(STREAM_TOKENIZER_CONFIG);
+ tokenizer.setConfig(PdfParserConstants.STREAM_TOKENIZER_CONFIG);
}
} else if (mode == TokenizerMode.COMMENT) {
if (PdfConstants.PDF_END_OF_LINE_DELIMITERS.contains(token)) {
/* We are at the end of the line. Switch back to standard. */
mode = TokenizerMode.STANDARD;
- tokenizer.setConfig(STD_TOKENIZER_CONFIG);
+ tokenizer.setConfig(PdfParserConstants.STD_TOKENIZER_CONFIG);
} else {
/* This is the comment text. Just let it go onto the token stack. */
}
} else if (mode == TokenizerMode.LITERAL_TEXT) {
- if (PDF_TEXT_DELIMITERS.contains(token)) {
+ if (PdfParserConstants.PDF_TEXT_DELIMITERS.contains(token)) {
/* We are at the end of the string literal. Switch back to standard. */
mode = TokenizerMode.STANDARD;
- tokenizer.setConfig(STD_TOKENIZER_CONFIG);
+ tokenizer.setConfig(PdfParserConstants.STD_TOKENIZER_CONFIG);
}
} else if (mode == TokenizerMode.STREAM) {
- if (PDF_STREAM_DELIMITERS.contains(token)) {
+ if (PdfParserConstants.PDF_STREAM_DELIMITERS.contains(token)) {
/* We are at the end of the stream. Switch back to standard. */
mode = TokenizerMode.STANDARD;
- tokenizer.setConfig(STD_TOKENIZER_CONFIG);
+ tokenizer.setConfig(PdfParserConstants.STD_TOKENIZER_CONFIG);
}
}
tokenStack.push(token);
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java 2025-05-26 11:28:40 UTC (rev 13746)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java 2025-05-26 12:56:34 UTC (rev 13747)
@@ -30,6 +30,7 @@
import org.foray.common.data.ByteSequenceTokenizer;
import org.foray.pdf.PdfObjectReference;
+import org.foray.pdf.PdfParserConstants;
import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfArray;
import org.foray.pdf.type.PdfDictionary;
@@ -61,7 +62,8 @@
public void parserTestInteger() throws PdfException {
final ByteArray input = new ByteArray("999999999");
final PdfParser out = new PdfParser();
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(input, PdfParser.STD_TOKENIZER_CONFIG);
+ final ByteSequenceTokenizer tokenizer =
+ new ByteSequenceTokenizer(input, PdfParserConstants.STD_TOKENIZER_CONFIG);
final PdfObject actual = out.parseObject(tokenizer);
assertTrue(actual instanceof PdfInteger);
final PdfInteger integer = (PdfInteger) actual;
@@ -76,7 +78,8 @@
public void parserTestObjectRef() throws PdfException {
final ByteArray input = new ByteArray("23494 0 R");
final PdfParser out = new PdfParser();
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(input, PdfParser.STD_TOKENIZER_CONFIG);
+ final ByteSequenceTokenizer tokenizer =
+ new ByteSequenceTokenizer(input, PdfParserConstants.STD_TOKENIZER_CONFIG);
final PdfObject actual = out.parseObject(tokenizer);
assertTrue(actual instanceof PdfObjectReference);
@@ -93,7 +96,8 @@
public void parserTestName() throws PdfException {
final ByteArray input = new ByteArray("/AnyName");
final PdfParser out = new PdfParser();
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(input, PdfParser.STD_TOKENIZER_CONFIG);
+ final ByteSequenceTokenizer tokenizer =
+ new ByteSequenceTokenizer(input, PdfParserConstants.STD_TOKENIZER_CONFIG);
final PdfObject actual = out.parseObject(tokenizer);
assertTrue(actual instanceof PdfName);
final PdfName name = (PdfName) actual;
@@ -109,7 +113,8 @@
/* From PDF Reference, Sixth Edition, Section 3.2.3. */
final ByteArray input = new ByteArray("<4E6F762073686D6F7A206B6120706F702E>");
final PdfParser out = new PdfParser();
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(input, PdfParser.STD_TOKENIZER_CONFIG);
+ final ByteSequenceTokenizer tokenizer =
+ new ByteSequenceTokenizer(input, PdfParserConstants.STD_TOKENIZER_CONFIG);
final PdfObject actual = out.parseObject(tokenizer);
assertTrue(actual instanceof PdfHexString);
@@ -131,7 +136,8 @@
public void parserTestLiteralStringSimple001() throws PdfException {
final ByteArray input = new ByteArray("(A simple string.)");
final PdfParser out = new PdfParser();
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(input, PdfParser.STD_TOKENIZER_CONFIG);
+ final ByteSequenceTokenizer tokenizer =
+ new ByteSequenceTokenizer(input, PdfParserConstants.STD_TOKENIZER_CONFIG);
final PdfObject actual = out.parseObject(tokenizer);
assertTrue(actual instanceof PdfTextString);
@@ -148,7 +154,8 @@
/* Note space at beginning of literal string (immediately after open paren). */
final ByteArray input = new ByteArray("( A simple string.)");
final PdfParser out = new PdfParser();
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(input, PdfParser.STD_TOKENIZER_CONFIG);
+ final ByteSequenceTokenizer tokenizer =
+ new ByteSequenceTokenizer(input, PdfParserConstants.STD_TOKENIZER_CONFIG);
final PdfObject actual = out.parseObject(tokenizer);
assertTrue(actual instanceof PdfTextString);
@@ -183,7 +190,8 @@
">>\n" +
"endobj\n");
final PdfParser out = new PdfParser();
- final ByteSequenceTokenizer tokenizer = new ByteSequenceTokenizer(input, PdfParser.STD_TOKENIZER_CONFIG);
+ final ByteSequenceTokenizer tokenizer =
+ new ByteSequenceTokenizer(input, PdfParserConstants.STD_TOKENIZER_CONFIG);
final PdfObject actual = out.parseObject(tokenizer);
assertTrue(actual instanceof PdfDictionary);
final PdfDictionary dict = (PdfDictionary) actual;
Modified: trunk/foray/foray-pdf-core/build.gradle
===================================================================
--- trunk/foray/foray-pdf-core/build.gradle 2025-05-26 11:28:40 UTC (rev 13746)
+++ trunk/foray/foray-pdf-core/build.gradle 2025-05-26 12:56:34 UTC (rev 13747)
@@ -11,6 +11,7 @@
api (group: 'org.axsl', name: 'axsl-pdf', version: versions.axsl)
implementation (project(':foray-primitive'))
+ implementation (project(':foray-common'))
}
Modified: trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfConstants.java
===================================================================
--- trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfConstants.java 2025-05-26 11:28:40 UTC (rev 13746)
+++ trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfConstants.java 2025-05-26 12:56:34 UTC (rev 13747)
@@ -97,6 +97,9 @@
/** Character used to indicate that the object being parsed is a reference to an indirect object: {@code R}. */
public static final ByteArray KEYWORD_REFERENCE_MARKER = new ByteArray("R");
+ /** String used to mark the beginning of the trailer. */
+ public static final ByteArray TRAILER_MARKER = new ByteArray("trailer");
+
/**
* Comment marker for the beginning of a PDF: "%PDF-".
* @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.2."
Added: trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfParserConstants.java
===================================================================
--- trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfParserConstants.java (rev 0)
+++ trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfParserConstants.java 2025-05-26 12:56:34 UTC (rev 13747)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf;
+
+import org.foray.common.data.ByteSequenceTokenizerConfig;
+import org.foray.primitive.sequence.ByteArray;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class PdfParserConstants {
+
+ /** The standard tokenizer configuration for parsing a PDF. */
+ public static final ByteSequenceTokenizerConfig STD_TOKENIZER_CONFIG =
+ new ByteSequenceTokenizerConfig(PdfConstants.PDF_DELIMITERS, PdfConstants.PDF_WHITESPACE, null, null);
+
+ /** Delimiters for parsing literal PDF strings. */
+ public static final List<ByteArray> PDF_TEXT_DELIMITERS = Arrays.asList(
+ PdfConstants.CLOSE_STRING_LITERAL
+ );
+
+ /** Delimiter balancers for parsing literal PDF strings. */
+ public static final List<ByteArray> PDF_TEXT_DELIMITER_BALANCERS = Arrays.asList(
+ PdfConstants.OPEN_STRING_LITERAL
+ );
+
+ /** Delimiters for parsing literal PDF streams. */
+ public static final List<ByteArray> PDF_STREAM_DELIMITERS = Arrays.asList(
+ PdfConstants.KEYWORD_END_STREAM
+ );
+
+ /** The tokenizer configuration for parsing PDF text. */
+ public static final ByteSequenceTokenizerConfig TEXT_TOKENIZER_CONFIG = new ByteSequenceTokenizerConfig(
+ PDF_TEXT_DELIMITERS, null, PdfConstants.TEXT_ESCAPE_CHARS, PDF_TEXT_DELIMITER_BALANCERS);
+
+ /** The tokenizer configuration for parsing a PDF comment. Just looking for the end of the line. */
+ public static final ByteSequenceTokenizerConfig COMMENT_TOKENIZER_CONFIG =
+ new ByteSequenceTokenizerConfig(PdfConstants.PDF_END_OF_LINE_DELIMITERS, null, null, null);
+
+ /** The tokenizer configuration for parsing a PDF stream. */
+ public static final ByteSequenceTokenizerConfig STREAM_TOKENIZER_CONFIG =
+ new ByteSequenceTokenizerConfig(PDF_STREAM_DELIMITERS, null, null, null);
+
+}
Property changes on: trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfParserConstants.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-pdf-parse/build.gradle
===================================================================
--- trunk/foray/foray-pdf-parse/build.gradle 2025-05-26 11:28:40 UTC (rev 13746)
+++ trunk/foray/foray-pdf-parse/build.gradle 2025-05-26 12:56:34 UTC (rev 13747)
@@ -8,6 +8,7 @@
dependencies {
api (group: 'org.axsl', name: 'axsl-pdf', version: versions.axsl)
+ api (group: 'org.axsl', name: 'axsl-primitive', version: versions.axsl)
implementation (project(':foray-common'))
implementation (project(':foray-pdf-core'))
Modified: trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java
===================================================================
--- trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java 2025-05-26 11:28:40 UTC (rev 13746)
+++ trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java 2025-05-26 12:56:34 UTC (rev 13747)
@@ -30,4 +30,6 @@
public interface PdfHandler {
+ default void pdfVersion(final String value) { return; }
+
}
Modified: trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java
===================================================================
--- trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java 2025-05-26 11:28:40 UTC (rev 13746)
+++ trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java 2025-05-26 12:56:34 UTC (rev 13747)
@@ -28,8 +28,6 @@
package org.foray.pdf;
-import org.foray.common.RandomAccessInput;
-
import java.io.IOException;
/**
@@ -37,10 +35,46 @@
*/
public class PdfParser {
- public void parse(final RandomAccessInput input, final int offset, final PdfHandler handler)
+ public void parse(final PdfRandomAccessInput input, final int offset, final PdfHandler handler)
throws IOException {
input.seek(offset);
+
+
+ /* *** Parse the Header. *** */
+ final String headerLine = input.readLine();
+ if (! headerLine.startsWith(PdfConstants.DOCUMENT_BEGIN_MARKER.toString())) {
+ return;
+ }
+ final String versionString = headerLine.substring(PdfConstants.DOCUMENT_BEGIN_MARKER.length()).trim();
+ handler.pdfVersion(versionString);
+
+
+
+
+
+ /* *** Parse the Trailer. *** */
+// final int trailerIndex = input.lastIndexOf(PdfConstants.TRAILER_MARKER, 0);
+// final int trailerDictStart = input.indexOf(PdfConstants.OPEN_DICTIONARY, trailerIndex);
+// final int trailerDictEnd = input.indexOf(PdfConstants.CLOSE_DICTIONARY, trailerDictStart) +
+// PdfConstants.CLOSE_DICTIONARY.length();
+// final ByteSequenceSubset parseArea =
+// new ByteSequenceSubset(input.getByteSequence(), trailerDictStart, trailerDictEnd - trailerDictStart);
+// final ByteSequenceTokenizer tokenizer =
+// new ByteSequenceTokenizer(parseArea, PdfParserConstants.STD_TOKENIZER_CONFIG);
+
+// final PdfObject trailerObject = this.parseObject(tokenizer);
+// if (trailerObject instanceof PdfTrailer) {
+// return (PdfTrailer) trailerObject;
+// }
+// if (trailerObject instanceof PdfGenericDictionary) {
+// return new PdfTrailer((PdfGenericDictionary) trailerObject);
+// }
+// throw new PdfException("Unable to parse the trailer dictionary.");
+
+
+
+
/* TODO: Complete this. */
}
}
Added: trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfRandomAccessInput.java
===================================================================
--- trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfRandomAccessInput.java (rev 0)
+++ trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfRandomAccessInput.java 2025-05-26 12:56:34 UTC (rev 13747)
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf;
+
+import org.foray.common.RandomAccessInput;
+import org.foray.common.sequence.ByteSequenceParser;
+
+import org.axsl.primitive.sequence.ByteSequence;
+import org.axsl.primitive.sequence.ByteSequencePlus;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A parser that includes methods specialized for parsing TrueType fonts.
+ */
+public interface PdfRandomAccessInput extends RandomAccessInput {
+
+ /**
+ * Simple implementation.
+ */
+ class Impl extends ByteSequenceParser implements PdfRandomAccessInput {
+
+ /**
+ * Constructor.
+ * @param sequence The sequence being wrapped.
+ */
+ public Impl(final ByteSequencePlus sequence) {
+ super(sequence);
+ }
+
+ /**
+ * Constructor for an {@link InputStream} instance.
+ * Reads the content of {@code inputStream} into the parser, then closes it.
+ * @param inputStream The {@link InputStream} whose content should be captured as a byte sequence.
+ * @throws IOException For errors reading or closing the input stream.
+ */
+ public Impl(final InputStream inputStream) throws IOException {
+ super(inputStream);
+ }
+
+ @Override
+ public int lastIndexOf(ByteSequence sequence, int fromIndex) {
+ return getByteSequence().lastIndexOf(sequence);
+ }
+
+ @Override
+ public int indexOf(ByteSequence sequence, int fromIndex) {
+ return getByteSequence().indexOf(sequence, fromIndex);
+ }
+
+ }
+
+
+ /* Checkstyle: Suppress method name checking when matching low-level type names. */
+
+ /**
+ * Returns the wrapped byte sequence.
+ * @return The wrapped byte sequence.
+ */
+ ByteSequencePlus getByteSequence();
+
+ /**
+ * Returns the first index of a given sequence in the content, starting at a given point.
+ * @param sequence The sequence being sought.
+ * @param fromIndex The offset from which the search should begin.
+ * @return The offset of the occurrence of {@code sequence}.
+ * @see ByteSequencePlus#indexOf(ByteSequence, int)
+ */
+ int indexOf(ByteSequence sequence, int fromIndex);
+
+ /**
+ * Returns the last index of a given sequence in the content.
+ * @param sequence The sequence being sought.
+ * @param fromIndex The offset from which the search should begin.
+ * @return The offset of the last occurrence of {@code sequence}.
+ * @see ByteSequencePlus#lastIndexOf(ByteSequence, int)
+ */
+ int lastIndexOf(ByteSequence sequence, int fromIndex);
+
+
+ /* Checkstyle: Restart method name checking. */
+}
Property changes on: trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfRandomAccessInput.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-26 11:28:45
|
Revision: 13746
http://sourceforge.net/p/foray/code/13746
Author: victormote
Date: 2025-05-26 11:28:40 +0000 (Mon, 26 May 2025)
Log Message:
-----------
Have ByteSequenceParser wrap ByteSequencePlus instead of ByteSequence, giving access to more methods.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteSequenceParser.java
trunk/foray/foray-common/src/test/java/org/foray/common/sequence/ByteSequenceParserTests.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteSequenceParser.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteSequenceParser.java 2025-05-25 19:36:27 UTC (rev 13745)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/sequence/ByteSequenceParser.java 2025-05-26 11:28:40 UTC (rev 13746)
@@ -32,7 +32,7 @@
import org.foray.primitive.sequence.ByteArrayBuilder;
import org.axsl.constants.PrimitiveConstants;
-import org.axsl.primitive.sequence.ByteSequence;
+import org.axsl.primitive.sequence.ByteSequencePlus;
import org.apache.commons.io.EndianUtils;
@@ -44,13 +44,13 @@
import java.nio.charset.StandardCharsets;
/**
- * Wraps an instance of {@link ByteSequence} and provides methods for parsing that sequence and accessing its content
- * using random access.
+ * Wraps an instance of {@link ByteSequencePlus} and provides methods for parsing that sequence and accessing its
+ * content using random access.
*/
public class ByteSequenceParser implements RandomAccessInput {
/** The sequence being iterated. */
- private ByteSequence sequence;
+ private ByteSequencePlus sequence;
/** The current location in {@link #sequence}. */
private int index;
@@ -59,7 +59,7 @@
* Constructor.
* @param sequence The sequence being wrapped.
*/
- public ByteSequenceParser(final ByteSequence sequence) {
+ public ByteSequenceParser(final ByteSequencePlus sequence) {
this.sequence = sequence;
}
@@ -342,7 +342,7 @@
* Returns the wrapped byte sequence.
* @return The wrapped byte sequence.
*/
- public ByteSequence getByteSequence() {
+ public ByteSequencePlus getByteSequence() {
return this.sequence;
}
Modified: trunk/foray/foray-common/src/test/java/org/foray/common/sequence/ByteSequenceParserTests.java
===================================================================
--- trunk/foray/foray-common/src/test/java/org/foray/common/sequence/ByteSequenceParserTests.java 2025-05-25 19:36:27 UTC (rev 13745)
+++ trunk/foray/foray-common/src/test/java/org/foray/common/sequence/ByteSequenceParserTests.java 2025-05-26 11:28:40 UTC (rev 13746)
@@ -30,7 +30,7 @@
import org.foray.primitive.sequence.ByteArray;
-import org.axsl.primitive.sequence.ByteSequence;
+import org.axsl.primitive.sequence.ByteSequencePlus;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
@@ -49,7 +49,7 @@
* @return A parser ready to be tested.
*/
private ByteSequenceParser createParser(final byte[] byteArray) {
- final ByteSequence sequence = new ByteArray(byteArray);
+ final ByteSequencePlus sequence = new ByteArray(byteArray);
return new ByteSequenceParser(sequence);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 19:36:36
|
Revision: 13745
http://sourceforge.net/p/foray/code/13745
Author: victormote
Date: 2025-05-25 19:36:27 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove remaining dependencies on PdfDocument4a in serialize method.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfObjectReference.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfResources.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfAnnotList.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfNameDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPages.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/encrypt/PdfEncryption4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/filespec/PdfFileSpec.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/function/PdfFunction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfColor4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfPattern4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfShading.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationNamed4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfAction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfUri.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfBorderStyle.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfSerializer.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCharProcs.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidSystemInfo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfObjectReference.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfObjectReference.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfObjectReference.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
@@ -60,7 +59,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
return ByteArray.EMPTY;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfResources.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfResources.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfResources.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.content;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.graphics.PdfPattern4a;
import org.foray.pdf.graphics.PdfShading;
import org.foray.pdf.graphics.PdfXobject4a;
@@ -94,7 +93,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder p = new StringBuilder();
p.append(this.getSerializedId() + EOL);
p.append("<<" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfAnnotList.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfAnnotList.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfAnnotList.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -73,7 +73,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder p = new StringBuilder();
p.append(this.getSerializedId() + EOL);
p.append("[" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfNameDictionary.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfNameDictionary.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfNameDictionary.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -93,10 +93,9 @@
/**
* Represent the object as PDF.
- * @param doc The PDF Document.
* @return The PDF string
*/
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder p = new StringBuilder();
p.append(this.getSerializedId());
p.append(EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -136,7 +136,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder sb = new StringBuilder();
sb.append(this.getSerializedId() + EOL
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPages.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPages.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPages.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -75,7 +75,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
/* TODO: Create a balanced tree here. See the PDF Reference. */
final StringBuilder p = new StringBuilder();
p.append(this.getSerializedId() + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -137,10 +137,9 @@
/**
* Represent the object as PDF.
- * @param doc The PDF Document.
* @return The PDF string
*/
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder p = new StringBuilder();
p.append(this.getSerializedId());
p.append(EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/encrypt/PdfEncryption4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/encrypt/PdfEncryption4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/encrypt/PdfEncryption4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -402,7 +402,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
if (this.dictionary == null) {
throw new IllegalStateException("PDF Encryption has not been initialized");
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/filespec/PdfFileSpec.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/filespec/PdfFileSpec.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/filespec/PdfFileSpec.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.filespec;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
@@ -65,7 +64,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder builder = new StringBuilder();
builder.append(getSerializedId() + EOL
+ "<<" + EOL
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/function/PdfFunction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/function/PdfFunction.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/function/PdfFunction.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -29,7 +29,6 @@
package org.foray.pdf.function;
import org.foray.common.ps.PsUtil;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.StringUtils;
import org.foray.primitive.sequence.ByteArray;
@@ -415,7 +414,7 @@
* @return the PDF string.
*/
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
int vectorSize = 0;
int numberOfFunctions = 0;
int tempInt = 0;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfColor4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfColor4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfColor4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -29,7 +29,6 @@
package org.foray.pdf.graphics;
import org.foray.common.ps.PsColor;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.primitive.sequence.ByteSequencePlus;
@@ -70,7 +69,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder buffer = new StringBuilder();
buffer.append("[");
buffer.append(getRed() + " ");
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfPattern4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfPattern4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfPattern4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -182,7 +182,7 @@
* @return the PDF string.
*/
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
int vectorSize = 0;
int tempInt = 0;
final StringBuilder p = new StringBuilder();
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfShading.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfShading.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfShading.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -371,7 +371,7 @@
* @return the PDF string.
*/
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
int vectorSize;
int tempInt;
final StringBuilder p = new StringBuilder();
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -34,7 +34,6 @@
package org.foray.pdf.interact;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.document.PdfPage4a;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
@@ -78,7 +77,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.getSerializedId());
buffer.append(EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationNamed4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationNamed4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationNamed4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.interact;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.structure.PdfTextString;
import org.foray.pdf.type.PdfObject;
@@ -63,8 +62,8 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
- return this.name.serialize(doc);
+ public ByteSequencePlus serialize() {
+ return this.name.serialize();
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.interact;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.structure.PdfNameTree;
/**
@@ -38,8 +37,7 @@
public class PdfNamedDestinationsTree4a extends PdfNameTree<PdfDestinationNamed4a> {
@Override
- protected String valueToPDF(final PdfDestinationNamed4a value, final PdfDocument4a doc) {
- doc.registerIndirectObject(this);
+ protected String valueToPDF(final PdfDestinationNamed4a value) {
return getIndirectReference().getSerializedReference();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -62,7 +62,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
if (getChildren().size() < 1) {
return ByteArray.EMPTY;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -170,12 +170,12 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder result = new StringBuilder();
result.append(this.getSerializedId() + EOL + "<<" + EOL);
final int countDescendants = this.count();
// subentry Outline object
- result.append(" /Title " + this.title.serialize(doc) + EOL);
+ result.append(" /Title " + this.title.serialize() + EOL);
result.append(" /Parent " + this.parent.getIndirectReference().getSerializedReference() + EOL);
if (getFirst() != null && getLast() != null) {
result.append(" /First " + getFirst().getIndirectReference().getSerializedReference() + EOL);
@@ -197,20 +197,20 @@
result.append(" /Dest ");
if (this.target instanceof PdfDestinationNamed4a) {
final PdfDestinationNamed4a named = (PdfDestinationNamed4a) this.target;
- result.append(named.serialize(doc));
+ result.append(named.serialize());
} else if (this.target instanceof PdfDestinationExplicit4a) {
final PdfDestinationExplicit4a explicit = (PdfDestinationExplicit4a) this.target;
- result.append(explicit.serialize(doc));
+ result.append(explicit.serialize());
}
result.append(EOL);
} else if (this.target instanceof PdfAction) {
final PdfAction action = (PdfAction) this.target;
- result.append(" /A " + action.serialize(doc));
+ result.append(" /A " + action.serialize());
}
if (this.color != null
&& ! this.color.isBlack()) {
- result.append(" /C " + this.color.serialize(doc) + EOL);
+ result.append(" /C " + this.color.serialize() + EOL);
}
if (this.flags() != 0) {
result.append(" /F " + this.flags() + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -79,7 +79,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.getSerializedId() + EOL);
buffer.append("<< /Type /PageLabel" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfAction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfAction.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfAction.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.interact.action;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
/**
@@ -41,10 +40,9 @@
* this method should be implemented to return the action which gets
* called by the Link Object. This could be a reference to another object
* or the specific destination of the link
- * @param doc The PDF Document.
*
* @return the action to place next to /A within a Link
*/
- public abstract String getAction(PdfDocument4a doc);
+ public abstract String getAction();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.interact.action;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.interact.PdfDestinationExplicit4a;
import org.foray.primitive.sequence.ByteArray;
@@ -52,19 +51,18 @@
}
@Override
- public String getAction(final PdfDocument4a doc) {
- doc.registerIndirectObject(this);
+ public String getAction() {
return getIndirectReference().getSerializedReference();
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.getSerializedId() + EOL);
buffer.append("<<" + EOL);
buffer.append("/S /GoTo" + EOL);
- buffer.append("/D " + this.destination.serialize(doc) + ">>" + EOL);
+ buffer.append("/D " + this.destination.serialize() + ">>" + EOL);
buffer.append("endobj" + EOL);
return new ByteArray(buffer);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.interact.action;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.filespec.PdfFileSpec;
import org.foray.primitive.sequence.ByteArray;
@@ -80,13 +79,12 @@
}
@Override
- public String getAction(final PdfDocument4a doc) {
- doc.registerIndirectObject(this);
+ public String getAction() {
return this.getIndirectReference().getSerializedReference();
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
String p = new String(this.getSerializedId() + EOL
+ "<<" + EOL + "/S /GoToR" + EOL + "/F "
+ this.pdfFileSpec.getIndirectReference().getSerializedReference() + "" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfUri.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfUri.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfUri.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,8 +28,6 @@
package org.foray.pdf.interact.action;
-import org.foray.pdf.document.PdfDocument4a;
-
import org.axsl.primitive.sequence.ByteSequencePlus;
/**
@@ -50,10 +48,9 @@
/**
* Returns the action necessary for a uri.
- * @param doc The PDF Document.
* @return the action to place next to /A within a Link
*/
- public String getAction(final PdfDocument4a doc) {
+ public String getAction() {
return "<< /URI (" + this.uri + ")" + EOL + "/S /URI >>";
}
@@ -64,7 +61,7 @@
* @return an empty string
*/
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
return null;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfBorderStyle.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfBorderStyle.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfBorderStyle.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -106,7 +106,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.getSerializedId() + EOL);
buffer.append("<< /Type /Border" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -117,7 +117,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final PdfDocument4a document = this.destination.getPage().getParent().getRoot().getDocument();
final StringBuilder buffer = new StringBuilder();
buffer.append(this.getSerializedId() + EOL);
@@ -135,18 +135,18 @@
+ "]" + EOL);
buffer.append("/BS " + document.getDefaultBorderStyle().getIndirectReference().getSerializedReference() + EOL);
if (this.color != null && ! this.color.isBlack()) {
- buffer.append("/C " + this.color.serialize(doc) + EOL);
+ buffer.append("/C " + this.color.serialize() + EOL);
}
if (this.destinationName != null
&& this.destinationName.length() > 0) {
// If there is a named destination, use that ...
- buffer.append("/Dest " + this.destinationName.serialize(doc)
+ buffer.append("/Dest " + this.destinationName.serialize()
+ EOL);
} else if (this.destination != null) {
- buffer.append("/Dest " + this.destination.serialize(doc));
+ buffer.append("/Dest " + this.destination.serialize());
} else if (this.action != null) {
// ... otherwise, use the Action.
- buffer.append("/A " + this.action.getAction(doc) + EOL);
+ buffer.append("/A " + this.action.getAction() + EOL);
}
buffer.append(">>" + EOL + "endobj" + EOL);
return new ByteArray(buffer);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfSerializer.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfSerializer.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/serial/PdfSerializer.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -176,7 +176,7 @@
/* Write the trailer. */
final ByteArrayBuilder builder = new ByteArrayBuilder();
builder.append("trailer" + PdfObject.EOL);
- builder.append(this.document.createTrailer().serialize(this.document));
+ builder.append(this.document.createTrailer().serialize());
builder.append("startxref");
builder.append(PdfObject.EOL);
builder.append(Long.toString(xrefPosition));
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfDate.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.structure;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
@@ -67,7 +66,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
if (this.date == null) {
return ByteArray.EMPTY;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.structure;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArrayBuilder;
@@ -50,7 +49,7 @@
private SortedMap<String, T> names = new TreeMap<String, T>();
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
/* TODO: This currently handles a tree with only one level. Add the capability here of writing a root node,
* intermediate nodes, and leaf nodes to properly balance the serialized version of the tree for performance. */
final ByteArrayBuilder p = new ByteArrayBuilder();
@@ -70,7 +69,7 @@
p.append("(");
p.append(entry.getKey());
p.append(") ");
- p.append(valueToPDF(value, doc));
+ p.append(valueToPDF(value));
p.append(EOL);
}
p.append("]");
@@ -103,11 +102,9 @@
/**
* Provides the PDF content that should be used as the "value" for a given map entry.
* @param value The raw value from the internal map.
- * @param doc The PDF document.
* @return The content to be written to the PDF for {@code value}.
*/
- protected String valueToPDF(final T value, final PdfDocument4a doc) {
- doc.registerIndirectObject(this);
+ protected String valueToPDF(final T value) {
return this.getIndirectReference().getSerializedReference();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.structure;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
@@ -49,7 +48,7 @@
private Map<Integer, T> nums = new TreeMap<Integer, T>();
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder p = new StringBuilder();
p.append(this.getSerializedId() + EOL);
p.append("<<" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfTextString.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.structure;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfLiteralString;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
@@ -90,7 +89,7 @@
* PDFDocEncoding).
*/
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
if (this.theSequence == null) {
return ByteArray.EMPTY;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCharProcs.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCharProcs.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCharProcs.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.text;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.pdf.type.PdfStream;
import org.foray.primitive.sequence.ByteArray;
@@ -69,7 +68,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
// TODO: Implement this.
return ByteArray.EMPTY;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -32,7 +32,6 @@
package org.foray.pdf.text;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.pdf.type.PdfStream;
import org.foray.primitive.StringUtils;
@@ -125,7 +124,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final Font font = this.fsFont.getFont();
final StringBuilder p = new StringBuilder();
p.append(getSerializedId() + EOL);
@@ -139,7 +138,7 @@
p.append(EOL + "/Subtype /");
p.append(this.subType.getPdfName());
p.append(EOL);
- p.append(this.systemInfo.serialize(doc));
+ p.append(this.systemInfo.serialize());
p.append(EOL + "/FontDescriptor ");
p.append(this.descriptor.getIndirectReference().getSerializedReference());
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidSystemInfo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidSystemInfo.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidSystemInfo.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -33,7 +33,6 @@
package org.foray.pdf.text;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfDictionary;
import org.foray.primitive.sequence.ByteArray;
@@ -79,7 +78,7 @@
* the referencing object.
*/
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder buffer = new StringBuilder();
buffer.setLength(0);
buffer.append("/CIDSystemInfo << /Registry (");
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.text;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
@@ -75,10 +74,9 @@
/**
* The String used to reference this object within the PDF.
- * @param doc The PDF Document.
* @return The String used to reference this object within the PDF.
*/
- public String pdfReference(final PdfDocument4a doc) {
+ public String pdfReference() {
if (this.encoding.isBuiltInPdf()) {
return "/" + this.getName();
}
@@ -85,12 +83,11 @@
if (! (this.encoding instanceof EncodingVector)) {
return "/" + this.getName();
}
- doc.registerIndirectObject(this);
return getIndirectReference().getSerializedReference();
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
if (this.encoding.isBuiltInPdf()) {
/* The predefined PDF encodings are present by name. They do not
* need to be written into the document. */
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -180,7 +180,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final StringBuilder buffer = new StringBuilder();
buffer.append(this.getSerializedId() + EOL);
buffer.append("<<" + EOL);
@@ -189,14 +189,14 @@
buffer.append("/BaseFont /" + getBaseFont() + EOL);
writeFirstChar(buffer);
writeLastChar(buffer);
- writeWidths(buffer, doc);
- writeFontDescriptor(buffer, doc);
- writeEncoding(buffer, doc);
+ writeWidths(buffer);
+ writeFontDescriptor(buffer);
+ writeEncoding(buffer);
writeFontBBox(buffer);
- writeFontMatrix(buffer, doc);
- writeCharProcs(buffer, doc);
- writeToUnicode(buffer, doc);
- writeDescendantFonts(buffer, doc);
+ writeFontMatrix(buffer);
+ writeCharProcs(buffer);
+ writeToUnicode(buffer);
+ writeDescendantFonts(buffer);
buffer.append(">>" + EOL);
buffer.append("endobj" + EOL);
return new ByteArray(buffer);
@@ -255,9 +255,8 @@
/**
* Write the /Widths component of the font entry.
* @param buffer The buffer into which the component should be written.
- * @param doc The PDF document.
*/
- protected void writeWidths(final StringBuilder buffer, final PdfDocument4a doc) {
+ protected void writeWidths(final StringBuilder buffer) {
if (isStandardFont()) {
return;
}
@@ -268,7 +267,7 @@
widthArray.add(aShort);
}
buffer.append("/Widths ");
- buffer.append(widthArray.serialize(doc));
+ buffer.append(widthArray.serialize());
buffer.append(EOL);
}
@@ -275,9 +274,8 @@
/**
* Write the /FontDescriptor component of the font entry.
* @param buffer The buffer into which the component should be written.
- * @param doc The PDF Document.
*/
- protected void writeFontDescriptor(final StringBuilder buffer, final PdfDocument4a doc) {
+ protected void writeFontDescriptor(final StringBuilder buffer) {
if (this.descriptor == null) {
return;
}
@@ -289,9 +287,8 @@
/**
* Write the /Encoding component of the font entry.
* @param buffer The buffer into which the component should be written.
- * @param doc The PDF Document.
*/
- private void writeEncoding(final StringBuilder buffer, final PdfDocument4a doc) {
+ private void writeEncoding(final StringBuilder buffer) {
if (this.pdfEncoding == null) {
return;
}
@@ -302,7 +299,7 @@
return;
}
buffer.append("/Encoding ");
- buffer.append(this.pdfEncoding.pdfReference(doc));
+ buffer.append(this.pdfEncoding.pdfReference());
buffer.append(EOL);
}
@@ -327,9 +324,8 @@
/**
* Write the /FontMatrix component of the font entry.
* @param buffer The buffer into which the component should be written.
- * @param doc The PDF document.
*/
- private void writeFontMatrix(final StringBuilder buffer, final PdfDocument4a doc) {
+ private void writeFontMatrix(final StringBuilder buffer) {
if (this.fontSubType != PdfFont4a.SubType.TYPE3) {
return;
}
@@ -338,7 +334,7 @@
final PdfArray fontMatrix = new PdfArray();
if (fontMatrix != null) {
buffer.append("/FontMatrix ");
- buffer.append(fontMatrix.serialize(doc));
+ buffer.append(fontMatrix.serialize());
buffer.append(EOL);
}
}
@@ -346,9 +342,8 @@
/**
* Write the /CharProcs component of the font entry.
* @param buffer The buffer into which the component should be written.
- * @param doc The PDF Document.
*/
- private void writeCharProcs(final StringBuilder buffer, final PdfDocument4a doc) {
+ private void writeCharProcs(final StringBuilder buffer) {
if (this.fontSubType != PdfFont4a.SubType.TYPE3) {
return;
}
@@ -355,7 +350,6 @@
/* TODO: This is all bogus and is really just a placeholder for future
* implementation. */
final PdfCharProcs charProcs = new PdfCharProcs();
- doc.registerIndirectObject(charProcs);
if (charProcs != null) {
buffer.append("/CharProcs ");
buffer.append(charProcs.getIndirectReference().getSerializedReference());
@@ -366,13 +360,13 @@
/**
* Write the /ToUnicode component of the font entry.
* @param buffer The buffer into which the component should be written.
- * @param doc The PDF Document.
*/
- private void writeToUnicode(final StringBuilder buffer, final PdfDocument4a doc) {
- final PdfToUnicodeCmap toUnicode = getToUnicodeCMAP(doc);
+ private void writeToUnicode(final StringBuilder buffer) {
+ final PdfToUnicodeCmap toUnicode = getToUnicodeCMAP();
if (toUnicode == null) {
return;
}
+ this.document.registerIndirectObject(toUnicode);
buffer.append("/ToUnicode " + toUnicode.getIndirectReference().getSerializedReference());
buffer.append(EOL);
}
@@ -379,10 +373,9 @@
/**
* Returns the ToUnicode CMap for this font.
- * @param doc The PDF Document.
* @return The ToUnicode CMap for this font.
*/
- protected PdfToUnicodeCmap getToUnicodeCMAP(final PdfDocument4a doc) {
+ protected PdfToUnicodeCmap getToUnicodeCMAP() {
return null;
}
@@ -389,9 +382,8 @@
/**
* Write the /DescendantFonts component of the font entry.
* @param buffer The buffer into which the component should be written.
- * @param doc The PDF Document.
*/
- private void writeDescendantFonts(final StringBuilder buffer, final PdfDocument4a doc) {
+ private void writeDescendantFonts(final StringBuilder buffer) {
final PdfCidFont descendantFonts = getDescendantFonts();
if (descendantFonts == null) {
return;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -136,7 +136,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final Font font = this.pdfFont.getFont();
final StringBuilder p = new StringBuilder();
p.append(this.getSerializedId() + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -57,47 +57,31 @@
doc.registerIndirectObject(this.descendantFonts);
}
- /**
- * {@inheritDoc}
- */
@Override
- protected PdfToUnicodeCmap getToUnicodeCMAP(final PdfDocument4a doc) {
+ protected PdfToUnicodeCmap getToUnicodeCMAP() {
final PdfToUnicodeCmap toUnicode =
new PdfToUnicodeCmap(PdfCmap.Type.IDENTITY_H, this.descendantFonts.getSystemInfo(), getFontUse());
- doc.registerIndirectObject(toUnicode);
return toUnicode;
}
- /**
- * {@inheritDoc}
- */
@Override
protected PdfCidFont getDescendantFonts() {
return this.descendantFonts;
}
- /**
- * {@inheritDoc}
- */
@Override
protected void writeFirstChar(final StringBuilder buffer) { }
- /**
- * {@inheritDoc}
- */
@Override
protected void writeLastChar(final StringBuilder buffer) { }
- /**
- * {@inheritDoc}
- */
@Override
- protected void writeWidths(final StringBuilder buffer, final PdfDocument4a doc) { }
+ protected void writeWidths(final StringBuilder buffer) { }
/**
* {@inheritDoc}
*/
@Override
- protected void writeFontDescriptor(final StringBuilder buffer, final PdfDocument4a doc) { }
+ protected void writeFontDescriptor(final StringBuilder buffer) { }
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfArray.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -30,7 +30,6 @@
import org.foray.pdf.PdfConstants;
import org.foray.pdf.PdfObjectReference;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.structure.PdfDate;
import org.foray.pdf.structure.PdfTextString;
import org.foray.primitive.sequence.ByteArray;
@@ -90,7 +89,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final ByteArrayBuilder builder = new ByteArrayBuilder();
builder.append(PdfConstants.OPEN_ARRAY);
builder.append(PdfObject.EOL);
@@ -97,7 +96,7 @@
for (int index = 0; index < this.arrayContents.size(); index ++) {
final PdfObject pdfObject = this.arrayContents.get(index);
- builder.append(pdfObject.serialize(doc));
+ builder.append(pdfObject.serialize());
builder.append(PdfObject.EOL);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfBoolean.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.type;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.primitive.sequence.ByteSequence;
@@ -63,7 +62,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
return new ByteArray(this.textValue);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfDictionary.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -30,7 +30,6 @@
import org.foray.pdf.PdfConstants;
import org.foray.pdf.PdfObjectReference;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.structure.PdfDate;
import org.foray.pdf.structure.PdfTextString;
import org.foray.primitive.StringUtils;
@@ -106,7 +105,7 @@
public abstract String getDictionaryType();
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
if (isEmpty()) {
return ByteArray.EMPTY;
}
@@ -139,7 +138,7 @@
final PdfObject object = get(key);
if (object != null) {
final PdfObjectReference indirectReference = object.getIndirectReference();
- final ByteSequencePlus asPdf = indirectReference == null ? object.serialize(doc) :
+ final ByteSequencePlus asPdf = indirectReference == null ? object.serialize() :
new ByteArray(indirectReference.getSerializedReference());
if (asPdf != null
&& ! asPdf.isEmpty()) {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfHexString.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -29,7 +29,6 @@
package org.foray.pdf.type;
import org.foray.pdf.PdfConstants;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.primitive.sequence.ByteArray;
import org.foray.primitive.sequence.ByteArrayBuilder;
@@ -53,7 +52,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
final ByteArrayBuilder builder = new ByteArrayBuilder();
builder.append(PdfConstants.OPEN_STRING_HEX);
builder.append(this.value.toHexByteSequence());
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfInteger.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.type;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.primitive.sequence.ByteSequencePlus;
@@ -59,7 +58,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
return new ByteArray(Long.toString(this.value));
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfLiteralString.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.type;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.structure.PdfTextString;
import org.foray.primitive.sequence.ByteArray;
@@ -76,7 +75,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
return new ByteArray(this.font.textToPdf(this.theString, this.fontContext, this.orthography));
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfName.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -32,7 +32,6 @@
*/
package org.foray.pdf.type;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.primitive.sequence.ByteSequencePlus;
@@ -60,7 +59,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
return new ByteArray("/" + this.value);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -56,15 +56,14 @@
/**
* Returns this object in its serialized form, i.e. the content that should be written to a PDF file.
- * @param doc The PDF document, which contains data needed by some objects in it.
* @return The PDF text necessary to represent the object. This should never be null, but can be empty.
* @see #serialize(OutputStream, PdfDocument4a)
*/
- public abstract ByteSequencePlus serialize(PdfDocument4a doc);
+ public abstract ByteSequencePlus serialize();
/**
* Writes the serialized content of this object directly to an output stream.
- * The default case runs {@link #serialize(PdfDocument4a)} first, then writes the result of that to the output
+ * The default case runs {@link #serialize()} first, then writes the result of that to the output
* stream.
* Subclasses like streams that do not wish to spend the memory to hold the entire serialized content in memory
* should override this method to write directly to the stream.
@@ -72,10 +71,10 @@
* @param doc The PDF document being written.
* @return The number of bytes written.
* @throws PdfException For I/O errors during output.
- * @see #serialize(PdfDocument4a)
+ * @see #serialize()
*/
public int serialize(final OutputStream stream, final PdfDocument4a doc) throws PdfException {
- final ByteSequencePlus pdf = this.serialize(doc);
+ final ByteSequencePlus pdf = this.serialize();
try {
pdf.writeTo(stream);
} catch (final IOException e) {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfReal.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -28,7 +28,6 @@
package org.foray.pdf.type;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.primitive.sequence.ByteSequencePlus;
@@ -55,7 +54,7 @@
}
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
return new ByteArray(this.value.toPlainString());
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -238,7 +238,7 @@
* Use {@link #serialize(OutputStream, PdfDocument4a)} instead.
*/
@Override
- public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ public ByteSequencePlus serialize() {
throw new RuntimeException("This content could be huge. Use serialize(OutputStream, PdfDocument4a) instead.");
}
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfArrayTests.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -57,7 +57,7 @@
out.add(new PdfTextString("Ralph"));
out.add(new PdfName("SomeName"));
- final ByteArray actual = new ByteArray(out.serialize(null));
+ final ByteArray actual = new ByteArray(out.serialize());
final ByteArray expected = new ByteArray("[\n549\n3.14\nfalse\n(Ralph)\n/SomeName\n]");
assertEquals(expected, actual);
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java 2025-05-25 19:03:19 UTC (rev 13744)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentInfo4aTests.java 2025-05-25 19:36:27 UTC (rev 13745)
@@ -86,7 +86,7 @@
out.setAuthor("Sir Arthur Conan Doyle");
out.setTitle("The Hound of the Baskervilles");
- final ByteSequencePlus actual = out.serialize(null);
+ final ByteSequencePlus actual = out.serialize();
final String expected =
"<< /Type /Info\n" +
"/Title (The Hound of the Baskervilles)\n" +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 19:03:21
|
Revision: 13744
http://sourceforge.net/p/foray/code/13744
Author: victormote
Date: 2025-05-25 19:03:19 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some dependencies on PdfDocument4a in serialize method.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 18:11:17 UTC (rev 13743)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 19:03:19 UTC (rev 13744)
@@ -242,4 +242,12 @@
}
}
+ /**
+ * Returns the parent.
+ * @return The parent.
+ */
+ public PdfPages getParent() {
+ return parent;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2025-05-25 18:11:17 UTC (rev 13743)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2025-05-25 19:03:19 UTC (rev 13744)
@@ -137,4 +137,12 @@
return new ByteArray(buffer);
}
+ /**
+ * Returns the page for this destination.
+ * @return The page for this destination.
+ */
+ public PdfPage4a getPage() {
+ return page;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2025-05-25 18:11:17 UTC (rev 13743)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2025-05-25 19:03:19 UTC (rev 13744)
@@ -118,6 +118,7 @@
@Override
public ByteSequencePlus serialize(final PdfDocument4a doc) {
+ final PdfDocument4a document = this.destination.getPage().getParent().getRoot().getDocument();
final StringBuilder buffer = new StringBuilder();
buffer.append(this.getSerializedId() + EOL);
buffer.append("<<" + EOL
@@ -132,7 +133,7 @@
+ " "
+ (getRectangle().getY() - getRectangle().getHeight()) / TypographicConstants.MILLIPOINTS_PER_POINT
+ "]" + EOL);
- buffer.append("/BS " + doc.getDefaultBorderStyle().getIndirectReference().getSerializedReference() + EOL);
+ buffer.append("/BS " + document.getDefaultBorderStyle().getIndirectReference().getSerializedReference() + EOL);
if (this.color != null && ! this.color.isBlack()) {
buffer.append("/C " + this.color.serialize(doc) + EOL);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFontDescriptor.java 2025-05-25 18:11:17 UTC (rev 13743)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFontDescriptor.java 2025-05-25 19:03:19 UTC (rev 13744)
@@ -28,7 +28,6 @@
package org.foray.pdf.text;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfStream;
// based on work by Takayuki Takeuchi
@@ -66,7 +65,7 @@
}
@Override
- protected void fillInPDF(final StringBuilder p, final PdfDocument4a doc) {
+ protected void fillInPDF(final StringBuilder p) {
p.append(EOL + "/MissingWidth 500" + EOL);
if (this.lang != null) {
p.append(EOL + "/Lang /");
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-25 18:11:17 UTC (rev 13743)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-25 19:03:19 UTC (rev 13744)
@@ -113,6 +113,9 @@
/** The descriptor of font metrics. */
private PdfFontDescriptor descriptor = null;
+ /** The PDF document. */
+ private PdfDocument4a document;
+
/**
* Create the /Font object.
* @param doc The parent PDF document.
@@ -119,6 +122,7 @@
* @param fsFont The FreeStandingFont which is the basis for this PDF Font.
*/
public PdfFont4a(final PdfDocument4a doc, final FontUse fsFont) {
+ this.document = doc;
this.fontCount = doc.registerFontResource(this);
this.fsFont = fsFont;
this.pdfEncoding = doc.obtainPDFEncoding(fsFont.getEncoding());
@@ -166,12 +170,11 @@
/**
* Return the PostScript name for this font.
- * @param doc The PDF document instance.
* @return The PostScript name for this font.
*/
- public String getBaseFont(final PdfDocument4a doc) {
+ public String getBaseFont() {
if (getFont().isSubsettable()) {
- return doc.getNextFontSubsetTag() + "+" + getFont().getPostscriptName();
+ return this.document.getNextFontSubsetTag() + "+" + getFont().getPostscriptName();
}
return getFont().getPostscriptName();
}
@@ -183,7 +186,7 @@
buffer.append("<<" + EOL);
buffer.append("/Type /Font" + EOL);
buffer.append("/Subtype /" + this.getFontSubtype().getPdfName() + EOL);
- buffer.append("/BaseFont /" + getBaseFont(doc) + EOL);
+ buffer.append("/BaseFont /" + getBaseFont() + EOL);
writeFirstChar(buffer);
writeLastChar(buffer);
writeWidths(buffer, doc);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2025-05-25 18:11:17 UTC (rev 13743)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2025-05-25 19:03:19 UTC (rev 13744)
@@ -130,8 +130,7 @@
* @param subtype The font type defined in the font stream
* @param fontfile The stream containing an embedded font
*/
- public void setFontFile(final PdfFont4a.SubType subtype,
- final PdfFontFileStream fontfile) {
+ public void setFontFile(final PdfFont4a.SubType subtype, final PdfFontFileStream fontfile) {
this.subtype = subtype;
this.fontfile = fontfile;
}
@@ -142,7 +141,7 @@
final StringBuilder p = new StringBuilder();
p.append(this.getSerializedId() + EOL);
p.append("<< /Type /FontDescriptor" + EOL);
- p.append("/FontName /" + this.pdfFont.getBaseFont(doc));
+ p.append("/FontName /" + this.pdfFont.getBaseFont());
p.append(EOL + "/FontBBox ");
p.append(new PdfRectangle(font.getBoundingBox()).toPDFString());
p.append(EOL + "/Flags ");
@@ -200,7 +199,7 @@
}
// charSet for subset fonts // not yet implemented
// CID optional field
- fillInPDF(p, doc);
+ fillInPDF(p);
p.append(EOL + " >>" + EOL + "endobj" + EOL);
return new ByteArray(p);
@@ -210,9 +209,8 @@
* Fill in the specifics for the font's descriptor.
* The given buffer already contains the fields common to all descriptors.
* @param begin The buffer to be completed with the specific fields
- * @param doc The PDF Document.
*/
- protected void fillInPDF(final StringBuilder begin, final PdfDocument4a doc) { }
+ protected void fillInPDF(final StringBuilder begin) { }
/**
* Sets this font up so that it will be embedded in the PDF document.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 18:11:23
|
Revision: 13743
http://sourceforge.net/p/foray/code/13743
Author: victormote
Date: 2025-05-25 18:11:17 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2025-05-25 17:48:46 UTC (rev 13742)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2025-05-25 18:11:17 UTC (rev 13743)
@@ -134,7 +134,7 @@
p.append(font.getPostscriptName());
if (this.cidMap != null) {
p.append(EOL + "/CIDToGIDMap ");
- p.append(this.cidMap.pdfReference(doc));
+ p.append(this.cidMap.getIndirectReference().getSerializedReference());
}
p.append(EOL + "/Subtype /");
p.append(this.subType.getPdfName());
@@ -141,7 +141,7 @@
p.append(EOL);
p.append(this.systemInfo.serialize(doc));
p.append(EOL + "/FontDescriptor ");
- p.append(this.descriptor.pdfReference(doc));
+ p.append(this.descriptor.getIndirectReference().getSerializedReference());
p.append(EOL + "/DW ");
p.append(font.getDefaultWidth());
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFontDescriptor.java 2025-05-25 17:48:46 UTC (rev 13742)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFontDescriptor.java 2025-05-25 18:11:17 UTC (rev 13743)
@@ -74,7 +74,7 @@
}
if (this.cidSet != null) {
p.append(EOL + "/CIDSet /");
- this.cidSet.pdfReference(doc);
+ this.cidSet.getIndirectReference().getSerializedReference();
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java 2025-05-25 17:48:46 UTC (rev 13742)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java 2025-05-25 18:11:17 UTC (rev 13743)
@@ -39,7 +39,7 @@
/**
* Class representing an /Encoding object.
*
- * Encodings are specified on page 213 and onwards of the PDF 1.3 spec.
+ * @see "PDF Reference Sixth Edition, Section 5.5.5."
*/
public class PdfEncoding4a extends PdfObject {
@@ -73,7 +73,11 @@
return "Identity-H";
}
- @Override
+ /**
+ * The String used to reference this object within the PDF.
+ * @param doc The PDF Document.
+ * @return The String used to reference this object within the PDF.
+ */
public String pdfReference(final PdfDocument4a doc) {
if (this.encoding.isBuiltInPdf()) {
return "/" + this.getName();
@@ -81,7 +85,8 @@
if (! (this.encoding instanceof EncodingVector)) {
return "/" + this.getName();
}
- return super.pdfReference(doc);
+ doc.registerIndirectObject(this);
+ return getIndirectReference().getSerializedReference();
}
@Override
@@ -103,7 +108,7 @@
}
/*
- * example (p. 214)
+ * example (PDF Reference, Sixth Edition, Section 5.5.5, Example 5.9)
* 25 0 obj
* <<
* /Type /Encoding
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2025-05-25 17:48:46 UTC (rev 13742)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2025-05-25 18:11:17 UTC (rev 13743)
@@ -90,8 +90,7 @@
* @param font The font to be encapsulated.
* @return The newly-created font descriptor.
*/
- public static PdfFontDescriptor makeFontDescriptor(final PdfDocument4a pdfDoc,
- final PdfFont4a font) {
+ public static PdfFontDescriptor makeFontDescriptor(final PdfDocument4a pdfDoc, final PdfFont4a font) {
PdfFontDescriptor fontDesc = null;
if (font.getFontSubtype() == PdfFont4a.SubType.TYPE0) {
// CID Font
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java 2025-05-25 17:48:46 UTC (rev 13742)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfObject.java 2025-05-25 18:11:17 UTC (rev 13743)
@@ -98,16 +98,6 @@
}
/**
- * The String used to reference this object within the PDF.
- * @param doc The PDF Document.
- * @return The String used to reference this object within the PDF.
- */
- public String pdfReference(final PdfDocument4a doc) {
- doc.registerIndirectObject(this);
- return this.reference.getSerializedReference();
- }
-
- /**
* The String used to identify this object as it is written in the PDF.
* @return The String used to identify this object as it is written in the
* PDF.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 17:48:49
|
Revision: 13742
http://sourceforge.net/p/foray/code/13742
Author: victormote
Date: 2025-05-25 17:48:46 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java 2025-05-25 16:06:30 UTC (rev 13741)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java 2025-05-25 17:48:46 UTC (rev 13742)
@@ -129,7 +129,7 @@
*/
public PdfOutline4a getOutlineRoot() {
if (this.outline == null) {
- this.outline = new PdfOutline4a();
+ this.outline = new PdfOutline4a(this.document);
this.document.registerIndirectObject(this.outline);
}
return this.outline;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java 2025-05-25 16:06:30 UTC (rev 13741)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutline4a.java 2025-05-25 17:48:46 UTC (rev 13742)
@@ -39,7 +39,19 @@
*/
public class PdfOutline4a extends PdfOutlineParent4a {
+ /** The PDF document. */
+ private PdfDocument4a document;
+
/**
+ * Constructor.
+ * @param document The PDF document.
+ */
+ public PdfOutline4a(final PdfDocument4a document) {
+ super(null);
+ this.document = document;
+ }
+
+ /**
* Returns the total number of open items at all levels of the outline.
* @return The total number of open items at all levels of the outline.
* @see "PDF Reference, 3rd Edition, Table 8.3.3"
@@ -59,8 +71,8 @@
result.append("<<" + EOL);
result.append(" /Type /Outlines" + EOL);
if (getFirst() != null && getLast() != null) {
- result.append(" /First " + getFirst().pdfReference(doc) + EOL);
- result.append(" /Last " + getLast().pdfReference(doc) + EOL);
+ result.append(" /First " + getFirst().getIndirectReference().getSerializedReference() + EOL);
+ result.append(" /Last " + getLast().getIndirectReference().getSerializedReference() + EOL);
}
if (count() > 0) {
result.append(" /Count " + count() + EOL);
@@ -69,4 +81,12 @@
return new ByteArray(result);
}
+ /**
+ * Returns the parent document.
+ * @return The parent document.
+ */
+ public PdfDocument4a getDocument() {
+ return this.document;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java 2025-05-25 16:06:30 UTC (rev 13741)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineItem4a.java 2025-05-25 17:48:46 UTC (rev 13742)
@@ -89,6 +89,7 @@
*/
public PdfOutlineItem4a(final PdfOutlineParent4a parent, final String title, final PdfOutlineTarget target,
final Color color, final boolean italic, final boolean bold) {
+ super(parent);
this.parent = parent;
this.title = new PdfTextString(title);
this.target = target;
@@ -175,18 +176,18 @@
final int countDescendants = this.count();
// subentry Outline object
result.append(" /Title " + this.title.serialize(doc) + EOL);
- result.append(" /Parent " + this.parent.pdfReference(doc) + EOL);
+ result.append(" /Parent " + this.parent.getIndirectReference().getSerializedReference() + EOL);
if (getFirst() != null && getLast() != null) {
- result.append(" /First " + getFirst().pdfReference(doc) + EOL);
- result.append(" /Last " + getLast().pdfReference(doc) + EOL);
+ result.append(" /First " + getFirst().getIndirectReference().getSerializedReference() + EOL);
+ result.append(" /Last " + getLast().getIndirectReference().getSerializedReference() + EOL);
}
final PdfOutlineItem4a previous = getPrevious();
if (previous != null) {
- result.append(" /Prev " + previous.pdfReference(doc) + EOL);
+ result.append(" /Prev " + previous.getIndirectReference().getSerializedReference() + EOL);
}
final PdfOutlineItem4a next = getNext();
if (next != null) {
- result.append(" /Next " + next.pdfReference(doc) + EOL);
+ result.append(" /Next " + next.getIndirectReference().getSerializedReference() + EOL);
}
if (countDescendants > 0) {
result.append(" /Count -" + countDescendants + EOL);
@@ -219,4 +220,9 @@
return new ByteArray(result);
}
+ @Override
+ public PdfDocument4a getDocument() {
+ return getParent().getDocument();
+ }
+
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java 2025-05-25 16:06:30 UTC (rev 13741)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java 2025-05-25 17:48:46 UTC (rev 13742)
@@ -28,6 +28,7 @@
package org.foray.pdf.interact;
+import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
import org.axsl.pdf.PdfOutlineParent;
@@ -44,10 +45,21 @@
public abstract class PdfOutlineParent4a extends PdfObject implements PdfOutlineParent {
+ /** The parent of this item. */
+ private PdfOutlineParent4a parent;
+
/** Collection of child PdfOutline objects. */
private List<PdfOutlineItem4a> children = new ArrayList<PdfOutlineItem4a>();
/**
+ * Constructor.
+ * @param parent The parent node.
+ */
+ public PdfOutlineParent4a(final PdfOutlineParent4a parent) {
+ this.parent = parent;
+ }
+
+ /**
* Return the children of this parent.
* @return The children of this parent.
*/
@@ -90,9 +102,23 @@
final Color color, final boolean italic, final boolean bold) {
final PdfOutlineItem4a newItem =
new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
-
+ parent.getDocument().registerIndirectObject(newItem);
this.children.add(newItem);
return newItem;
}
+ /**
+ * Returns the parent document.
+ * @return The parent document.
+ */
+ public abstract PdfDocument4a getDocument();
+
+ /**
+ * Returns the parent node.
+ * @return The parent node.
+ */
+ public PdfOutlineParent4a getParent() {
+ return this.parent;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 16:06:33
|
Revision: 13741
http://sourceforge.net/p/foray/code/13741
Author: victormote
Date: 2025-05-25 16:06:30 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfFormXobject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXreference.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfFormXobject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfFormXobject.java 2025-05-25 15:38:17 UTC (rev 13740)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfFormXobject.java 2025-05-25 16:06:30 UTC (rev 13741)
@@ -124,7 +124,9 @@
+ transform.getTranslateX() + " "
+ transform.getTranslateY() + "]"
+ EOL);
- buffer.append("/Resources " + doc.getResources().pdfReference(doc) + EOL);
+ buffer.append("/Resources ");
+ buffer.append(doc.getResources().getIndirectReference().getSerializedReference());
+ buffer.append(EOL);
/* Add any special entries that the subclasses might have. */
buffer.append(this.specialXFormDict(doc));
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java 2025-05-25 15:38:17 UTC (rev 13740)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java 2025-05-25 16:06:30 UTC (rev 13741)
@@ -75,6 +75,7 @@
&& cs instanceof ICC_ColorSpace) {
final ICC_ColorSpace iccCS = (ICC_ColorSpace) cs;
this.pdfICCStream = new PdfIccProfileStream(iccCS);
+ doc.registerIndirectObject(this.pdfICCStream);
try {
this.pdfICCStream.addDefaultFilters(doc);
} catch (final PdfException e) {
@@ -131,8 +132,10 @@
buffer.append("/Height " + pixelHeight + EOL);
buffer.append("/BitsPerComponent " + bitsPerPixel + EOL);
if (this.pdfICCStream != null) {
- buffer.append("/ColorSpace [/ICCBased "
- + this.pdfICCStream.pdfReference(doc) + "]" + EOL);
+ buffer.append("/ColorSpace [/ICCBased ");
+ buffer.append(this.pdfICCStream.getIndirectReference().getSerializedReference());
+ buffer.append("]");
+ buffer.append(EOL);
} else {
buffer.append("/ColorSpace /"
+ PdfColor4a.getColorSpacePDFString(cs)
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXreference.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXreference.java 2025-05-25 15:38:17 UTC (rev 13740)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXreference.java 2025-05-25 16:06:30 UTC (rev 13741)
@@ -113,7 +113,7 @@
final StringBuilder builder = new StringBuilder();
builder.append("/Ref" + EOL);
builder.append("<<" + EOL);
- builder.append("/F " + this.fileSpec.pdfReference(doc) + EOL);
+ builder.append("/F " + this.fileSpec.getIndirectReference().getSerializedReference() + EOL);
builder.append("/Page 0" + EOL);
builder.append(">>" + EOL);
return builder.toString();
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java 2025-05-25 15:38:17 UTC (rev 13740)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfOutlineParent4a.java 2025-05-25 16:06:30 UTC (rev 13741)
@@ -90,6 +90,7 @@
final Color color, final boolean italic, final boolean bold) {
final PdfOutlineItem4a newItem =
new PdfOutlineItem4a(this, titleText, internalDestination, color, italic, bold);
+
this.children.add(newItem);
return newItem;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java 2025-05-25 15:38:17 UTC (rev 13740)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfPageLabel.java 2025-05-25 16:06:30 UTC (rev 13741)
@@ -87,7 +87,7 @@
buffer.append("/S /" + this.style.getPdfName() + EOL);
}
if (this.labelPrefix != null) {
- buffer.append("/P " + this.labelPrefix.pdfReference(doc) + EOL);
+ buffer.append("/P " + this.labelPrefix.getValue().toAscii() + EOL);
}
if (this.startingNumber > 0) {
/* Ignore any entries with a value less than 1. */
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java 2025-05-25 15:38:17 UTC (rev 13740)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java 2025-05-25 16:06:30 UTC (rev 13741)
@@ -89,7 +89,7 @@
public ByteSequencePlus serialize(final PdfDocument4a doc) {
String p = new String(this.getSerializedId() + EOL
+ "<<" + EOL + "/S /GoToR" + EOL + "/F "
- + this.pdfFileSpec.pdfReference(doc) + "" + EOL);
+ + this.pdfFileSpec.getIndirectReference().getSerializedReference() + "" + EOL);
if (this.destination != null) {
p += "/D (" + this.destination + ")";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 15:38:20
|
Revision: 13740
http://sourceforge.net/p/foray/code/13740
Author: victormote
Date: 2025-05-25 15:38:17 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfResources.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/function/PdfFunction.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfPattern4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfShading.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfResources.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfResources.java 2025-05-25 15:02:27 UTC (rev 13739)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/content/PdfResources.java 2025-05-25 15:38:17 UTC (rev 13740)
@@ -104,8 +104,7 @@
p.append("<<" + EOL);
for (int i = 0; i < this.fonts.size(); i++) {
final PdfFont4a pdfFont = this.fonts.get(i);
- p.append("/" + pdfFont.getName() + " " + pdfFont.pdfReference(doc)
- + EOL);
+ p.append("/" + pdfFont.getName() + " " + pdfFont.getIndirectReference().getSerializedReference() + EOL);
}
p.append(">>" + EOL);
}
@@ -118,7 +117,7 @@
currentShadingNumber++) {
currentShading = this.shadings.get(currentShadingNumber);
p.append("/" + currentShading.getName() + " "
- + currentShading.pdfReference(doc) + EOL);
+ + currentShading.getIndirectReference().getSerializedReference() + EOL);
}
p.append(">>" + EOL);
}
@@ -133,7 +132,7 @@
currentPatternNumber++) {
currentPattern = this.patterns.get(currentPatternNumber);
p.append("/" + currentPattern.getName() + " "
- + currentPattern.pdfReference(doc) + EOL);
+ + currentPattern.getIndirectReference().getSerializedReference() + EOL);
}
p.append(">>" + EOL);
}
@@ -148,7 +147,7 @@
for (int i = 0; i < this.xObjects.size(); i++) {
final PdfXobject4a xObject = this.xObjects.get(i);
p.append("/" + xObject.getXobjectName() + " "
- + xObject.pdfReference(doc) + EOL);
+ + xObject.getIndirectReference().getSerializedReference() + EOL);
}
p.append(">>" + EOL);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2025-05-25 15:02:27 UTC (rev 13739)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2025-05-25 15:38:17 UTC (rev 13740)
@@ -630,6 +630,7 @@
theCone = colorToDoubleList(nextColor);
myfunc = new PdfFunction(2, null, null, theCzero, theCone, interpolation);
+ registerIndirectObject(myfunc);
theFunctions.add(myfunc);
@@ -636,6 +637,7 @@
} // end of for every consecutive color pair
myfunky = new PdfFunction(PdfFunction.TYPE_STITCHING, null, null, theFunctions, theBounds, null);
+ registerIndirectObject(myfunky);
if (radial) {
if (theCoords.size() == PdfConstants.QTY_RADIAL_SHADING_COMPONENTS) {
myShad = new PdfShading(this, PdfShading.TYPE_RADIAL,
@@ -658,11 +660,17 @@
null);
}
} else {
- myShad = new PdfShading(this, 2, theColorSpace,
- null, null, false, theCoords, null, myfunky, null);
+ myShad = new PdfShading(this, 2, theColorSpace, null, null, false, theCoords, null, myfunky, null);
}
- myPattern = new PdfPattern4a(this, 2, myShad, null,
- null, null);
+ myPattern = new PdfPattern4a(this, 2, myShad, null, null, null);
+
+ if (myShad != null) {
+ registerIndirectObject(myShad);
+ }
+ if (myPattern != null) {
+ registerIndirectObject(myPattern);
+ }
+
return myPattern;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/function/PdfFunction.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/function/PdfFunction.java 2025-05-25 15:02:27 UTC (rev 13739)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/function/PdfFunction.java 2025-05-25 15:38:17 UTC (rev 13740)
@@ -31,6 +31,7 @@
import org.foray.common.ps.PsUtil;
import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfObject;
+import org.foray.primitive.StringUtils;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.primitive.sequence.ByteSequencePlus;
@@ -622,9 +623,8 @@
p.append("/Functions [ ");
numberOfFunctions = this.functions.size();
for (tempInt = 0; tempInt < numberOfFunctions; tempInt++) {
- p.append((this.functions.get(tempInt))
- .pdfReference(doc) + " ");
-
+ p.append((this.functions.get(tempInt)).getIndirectReference().getSerializedReference());
+ p.append(StringUtils.SINGLE_SPACE);
}
p.append("]" + EOL);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfPattern4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfPattern4a.java 2025-05-25 15:02:27 UTC (rev 13739)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfPattern4a.java 2025-05-25 15:38:17 UTC (rev 13740)
@@ -189,7 +189,7 @@
p.append(this.getSerializedId() + EOL + "<<" + EOL + "/Type /Pattern" + EOL);
if (this.resources != null) {
- p.append("/Resources " + this.resources.pdfReference(doc) + EOL);
+ p.append("/Resources " + this.resources.getIndirectReference().getSerializedReference() + EOL);
}
p.append("/PatternType " + this.patternType + EOL);
@@ -240,7 +240,7 @@
// if (this.patternType ==2)
// Smooth Shading...
if (this.shading != null) {
- p.append("/Shading " + this.shading.pdfReference(doc) + EOL);
+ p.append("/Shading " + this.shading.getIndirectReference().getSerializedReference() + EOL);
}
if (this.xUID != null) {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfShading.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfShading.java 2025-05-25 15:02:27 UTC (rev 13739)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfShading.java 2025-05-25 15:38:17 UTC (rev 13740)
@@ -436,7 +436,7 @@
if (this.function != null) {
p.append("/Function ");
- p.append(this.function.pdfReference(doc) + EOL);
+ p.append(this.function.getIndirectReference().getSerializedReference() + EOL);
}
} else if ((this.shadingType == PdfShading.TYPE_AXIAL)
|| (this.shadingType == PdfShading.TYPE_RADIAL)) {
@@ -478,7 +478,7 @@
if (this.function != null) {
p.append("/Function ");
- p.append(this.function.pdfReference(doc) + EOL);
+ p.append(this.function.getIndirectReference().getSerializedReference() + EOL);
}
@@ -519,7 +519,7 @@
if (this.function != null) {
p.append("/Function ");
- p.append(this.function.pdfReference(doc) + EOL);
+ p.append(this.function.getIndirectReference().getSerializedReference() + EOL);
}
} else if (this.shadingType ==
@@ -551,7 +551,7 @@
if (this.function != null) {
p.append("/Function ");
- p.append(this.function.pdfReference(doc) + EOL);
+ p.append(this.function.getIndirectReference().getSerializedReference() + EOL);
}
if (this.verticesPerRow > 0) {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-25 15:02:27 UTC (rev 13739)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-25 15:38:17 UTC (rev 13740)
@@ -129,30 +129,34 @@
}
/**
- * Create a PdfFont4a with the next object number and add it to the
- * list of objects.
+ * Create a PdfFont4a with the next object number and add it to the list of objects.
* @param pdfDoc The parent PDF document.
* @param fsFont The FreeStandingFont to be added
* @return the created /Font object
*/
public static PdfFont4a makeFont(final PdfDocument4a pdfDoc, final FontUse fsFont) {
+ PdfFont4a font = null;
if (fsFont.getFont().isPdfStandardFont()) {
- final PdfFont4a font = new PdfFont4a(pdfDoc, fsFont);
- return font;
+ font = new PdfFont4a(pdfDoc, fsFont);
+ } else {
+ switch (PdfFont4a.getFontSubtype(fsFont)) {
+ case TYPE0:
+ font = new PdfFontType0(pdfDoc, fsFont);
+ break;
+ case TYPE1:
+ case MMTYPE1:
+ font = new PdfFont4a(pdfDoc, fsFont);
+ break;
+ case TRUETYPE:
+ font = new PdfFont4a(pdfDoc, fsFont);
+ break;
+ default: {
+ break;
+ }
}
- switch (PdfFont4a.getFontSubtype(fsFont)) {
- case TYPE0:
- return new PdfFontType0(pdfDoc, fsFont);
- case TYPE1:
- case MMTYPE1:
- return new PdfFont4a(pdfDoc, fsFont);
- case TRUETYPE:
- return new PdfFont4a(pdfDoc, fsFont);
- default: {
- break;
}
- }
- return null; // should not happen
+ pdfDoc.registerIndirectObject(font);
+ return font;
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 15:02:29
|
Revision: 13739
http://sourceforge.net/p/foray/code/13739
Author: victormote
Date: 2025-05-25 15:02:27 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java 2025-05-25 14:30:58 UTC (rev 13738)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java 2025-05-25 15:02:27 UTC (rev 13739)
@@ -57,8 +57,7 @@
/** The /Pages object that is root of the Pages hierarchy. */
private PdfPages pages;
- /** The number tree containing the range values for the page labels in this
- * document. */
+ /** The number tree containing the range values for the page labels in this document. */
private PdfNumberTree<PdfPageLabel> pageLabels;
/** The document's name dictionary. */
@@ -106,6 +105,7 @@
private PdfNumberTree<PdfPageLabel> getPageLabels() {
if (this.pageLabels == null) {
this.pageLabels = new PdfNumberTree<PdfPageLabel>();
+ this.document.registerIndirectObject(this.pageLabels);
}
return this.pageLabels;
}
@@ -153,12 +153,12 @@
p.append(EOL);
if (this.pageLabels != null) {
p.append("/PageLabels ");
- p.append(this.pageLabels.pdfReference(doc));
+ p.append(this.pageLabels.getIndirectReference().getSerializedReference());
p.append(EOL);
}
if (this.outline != null) {
p.append("/Outlines ");
- p.append(this.outline.pdfReference(doc));
+ p.append(this.outline.getIndirectReference().getSerializedReference());
p.append(EOL);
p.append(" /PageMode /UseOutlines");
p.append(EOL);
@@ -165,7 +165,7 @@
}
if (! this.names.isEmpty()) {
p.append("/Names ");
- p.append(this.names.pdfReference(doc));
+ p.append(this.names.getIndirectReference().getSerializedReference());
p.append(EOL);
}
p.append(PdfConstants.CLOSE_DICTIONARY.toAscii());
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2025-05-25 14:30:58 UTC (rev 13738)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNumberTree.java 2025-05-25 15:02:27 UTC (rev 13739)
@@ -56,7 +56,7 @@
p.append("/Nums [" + EOL);
for (Map.Entry<Integer, T> entry : this.nums.entrySet()) {
final PdfObject pdfObject = entry.getValue();
- p.append(entry.getKey() + " " + pdfObject.pdfReference(doc) + EOL);
+ p.append(entry.getKey() + " " + pdfObject.getIndirectReference().getSerializedReference() + EOL);
}
p.append("]" + EOL);
p.append(">>" + EOL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 14:31:01
|
Revision: 13738
http://sourceforge.net/p/foray/code/13738
Author: victormote
Date: 2025-05-25 14:30:58 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfAnnotList.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfNameDictionary.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfAnnotList.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfAnnotList.java 2025-05-25 14:04:07 UTC (rev 13737)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfAnnotList.java 2025-05-25 14:30:58 UTC (rev 13738)
@@ -79,7 +79,7 @@
p.append("[" + EOL);
for (int i = 0; i < this.annotations.size(); i++) {
final PdfAnnotation child = this.annotations.get(i);
- p.append(child.pdfReference(doc) + EOL);
+ p.append(child.getIndirectReference().getSerializedReference() + EOL);
}
p.append("] endobj" + EOL);
return new ByteArray(p);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfNameDictionary.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfNameDictionary.java 2025-05-25 14:04:07 UTC (rev 13737)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfNameDictionary.java 2025-05-25 14:30:58 UTC (rev 13738)
@@ -105,12 +105,12 @@
if (! this.dests.isEmpty()) {
p.append(" /Dests ");
- p.append(this.dests.pdfReference(doc));
+ p.append(this.dests.getIndirectReference().getSerializedReference());
p.append(EOL);
}
if (! this.embeddedFiles.isEmpty()) {
p.append(" /EmbeddedFiles ");
- p.append(this.embeddedFiles.pdfReference(doc));
+ p.append(this.embeddedFiles.getIndirectReference().getSerializedReference());
p.append(EOL);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 14:04:07 UTC (rev 13737)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 14:30:58 UTC (rev 13738)
@@ -206,6 +206,7 @@
link = new PdfLink(rect, destination);
}
getAnnotList().addAnnotation(link);
+ document.registerIndirectObject(link);
return link;
}
@@ -221,6 +222,7 @@
final PdfDocument4a document = this.parent.getRoot().getDocument();
final PdfNameTree<PdfDestinationNamed4a> namedDestinations =
document.getRoot().getNameDictionary().getNamedDestinations();
+ parent.getRoot().getDocument().registerIndirectObject(namedDestinations);
if (name != null) {
final PdfDestinationNamed4a existingDestination = namedDestinations.get(name);
if (existingDestination != null) {
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java 2025-05-25 14:04:07 UTC (rev 13737)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfNamedDestinationsTree4a.java 2025-05-25 14:30:58 UTC (rev 13738)
@@ -39,7 +39,8 @@
@Override
protected String valueToPDF(final PdfDestinationNamed4a value, final PdfDocument4a doc) {
- return value.getReferencedDestination().pdfReference(doc);
+ doc.registerIndirectObject(this);
+ return getIndirectReference().getSerializedReference();
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2025-05-25 14:04:07 UTC (rev 13737)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfNameTree.java 2025-05-25 14:30:58 UTC (rev 13738)
@@ -107,8 +107,9 @@
* @return The content to be written to the PDF for {@code value}.
*/
protected String valueToPDF(final T value, final PdfDocument4a doc) {
- return value.pdfReference(doc);
- }
+ doc.registerIndirectObject(this);
+ return this.getIndirectReference().getSerializedReference();
+}
/**
* Indicates whether this name tree is empty.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 14:04:10
|
Revision: 13737
http://sourceforge.net/p/foray/code/13737
Author: victormote
Date: 2025-05-25 14:04:07 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXreference.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2025-05-25 13:30:27 UTC (rev 13736)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2025-05-25 14:04:07 UTC (rev 13737)
@@ -445,6 +445,7 @@
public PdfBorderStyle getDefaultBorderStyle() {
if (this.defaultBorderStyle == null) {
this.defaultBorderStyle = new PdfBorderStyle(this, 0, PdfBorderStyle.Style.SOLID);
+ registerIndirectObject(this.defaultBorderStyle);
}
return this.defaultBorderStyle;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 13:30:27 UTC (rev 13736)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 14:04:07 UTC (rev 13737)
@@ -169,12 +169,15 @@
final PdfAction action;
PdfLink link = null;
int index = 0;
+ final PdfDocument4a document = this.parent.getRoot().getDocument();
+
if (externalLink) {
// check destination
// FileSpec
if (destination.endsWith(PdfPage4a.PDF_FILE_EXTENSION)) {
final PdfFileSpec fileSpec = new PdfFileSpec(destination);
+ document.registerIndirectObject(fileSpec);
action = new PdfGoToRemote(fileSpec);
} else if ((index = destination.indexOf(PdfPage4a.PDF_FILE_EXTENSION
+ PdfPage4a.PDF_PAGE_FRAGMENT_SPECIFIER)) > 0) {
@@ -183,6 +186,7 @@
index + PdfPage4a.PDF_FILE_EXTENSION.length()
+ PdfPage4a.PDF_PAGE_FRAGMENT_SPECIFIER.length()));
final PdfFileSpec fileSpec = new PdfFileSpec(file);
+ document.registerIndirectObject(fileSpec);
action = new PdfGoToRemote(fileSpec, pageNum);
} else if ((index = destination.indexOf(PdfPage4a.PDF_FILE_EXTENSION
+ PdfPage4a.PDF_DESTINATION_FRAGMENT_SPECIFIER)) > 0) {
@@ -192,6 +196,7 @@
index + PdfPage4a.PDF_FILE_EXTENSION.length()
+ PdfPage4a.PDF_DESTINATION_FRAGMENT_SPECIFIER.length());
final PdfFileSpec fileSpec = new PdfFileSpec(file);
+ document.registerIndirectObject(fileSpec);
action = new PdfGoToRemote(fileSpec, dest);
} else { // URI
action = new PdfUri(destination);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXreference.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXreference.java 2025-05-25 13:30:27 UTC (rev 13736)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXreference.java 2025-05-25 14:04:07 UTC (rev 13737)
@@ -75,6 +75,7 @@
throw new GraphicException(e);
}
this.fileSpec = new PdfFileSpec(embeddedFile);
+ doc.registerIndirectObject(this.fileSpec);
}
@Override
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java 2025-05-25 13:30:27 UTC (rev 13736)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoTo.java 2025-05-25 14:04:07 UTC (rev 13737)
@@ -53,7 +53,8 @@
@Override
public String getAction(final PdfDocument4a doc) {
- return pdfReference(doc);
+ doc.registerIndirectObject(this);
+ return getIndirectReference().getSerializedReference();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java 2025-05-25 13:30:27 UTC (rev 13736)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/action/PdfGoToRemote.java 2025-05-25 14:04:07 UTC (rev 13737)
@@ -81,7 +81,8 @@
@Override
public String getAction(final PdfDocument4a doc) {
- return this.pdfReference(doc);
+ doc.registerIndirectObject(this);
+ return this.getIndirectReference().getSerializedReference();
}
@Override
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2025-05-25 13:30:27 UTC (rev 13736)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2025-05-25 14:04:07 UTC (rev 13737)
@@ -132,8 +132,7 @@
+ " "
+ (getRectangle().getY() - getRectangle().getHeight()) / TypographicConstants.MILLIPOINTS_PER_POINT
+ "]" + EOL);
- buffer.append("/BS " + doc.getDefaultBorderStyle()
- .pdfReference(doc) + EOL);
+ buffer.append("/BS " + doc.getDefaultBorderStyle().getIndirectReference().getSerializedReference() + EOL);
if (this.color != null && ! this.color.isBlack()) {
buffer.append("/C " + this.color.serialize(doc) + EOL);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java 2025-05-25 13:30:27 UTC (rev 13736)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java 2025-05-25 14:04:07 UTC (rev 13737)
@@ -62,8 +62,8 @@
*/
@Override
protected PdfToUnicodeCmap getToUnicodeCMAP(final PdfDocument4a doc) {
- PdfToUnicodeCmap toUnicode = new PdfToUnicodeCmap(PdfCmap.Type.IDENTITY_H, this.descendantFonts.getSystemInfo(),
- getFontUse());
+ final PdfToUnicodeCmap toUnicode =
+ new PdfToUnicodeCmap(PdfCmap.Type.IDENTITY_H, this.descendantFonts.getSystemInfo(), getFontUse());
doc.registerIndirectObject(toUnicode);
return toUnicode;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 13:30:30
|
Revision: 13736
http://sourceforge.net/p/foray/code/13736
Author: victormote
Date: 2025-05-25 13:30:27 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfToUnicodeCmap.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2025-05-25 12:41:55 UTC (rev 13735)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2025-05-25 13:30:27 UTC (rev 13736)
@@ -116,8 +116,7 @@
* @param systemInfo The related system info object.
* @param descriptor The related font descriptor.
*/
- public PdfCidFont(final FontUse fsFont, final PdfCidSystemInfo systemInfo,
- final PdfCidFontDescriptor descriptor) {
+ public PdfCidFont(final FontUse fsFont, final PdfCidSystemInfo systemInfo, final PdfCidFontDescriptor descriptor) {
this.fsFont = fsFont;
this.systemInfo = systemInfo;
this.descriptor = descriptor;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-25 12:41:55 UTC (rev 13735)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-25 13:30:27 UTC (rev 13736)
@@ -275,7 +275,7 @@
return;
}
buffer.append("/FontDescriptor ");
- buffer.append(this.descriptor.pdfReference(doc));
+ buffer.append(this.descriptor.getIndirectReference().getSerializedReference());
buffer.append(EOL);
}
@@ -348,9 +348,10 @@
/* TODO: This is all bogus and is really just a placeholder for future
* implementation. */
final PdfCharProcs charProcs = new PdfCharProcs();
+ doc.registerIndirectObject(charProcs);
if (charProcs != null) {
buffer.append("/CharProcs ");
- buffer.append(charProcs.pdfReference(doc));
+ buffer.append(charProcs.getIndirectReference().getSerializedReference());
buffer.append(EOL);
}
}
@@ -361,19 +362,20 @@
* @param doc The PDF Document.
*/
private void writeToUnicode(final StringBuilder buffer, final PdfDocument4a doc) {
- final PdfToUnicodeCmap toUnicode = getToUnicodeCMAP();
+ final PdfToUnicodeCmap toUnicode = getToUnicodeCMAP(doc);
if (toUnicode == null) {
return;
}
- buffer.append("/ToUnicode " + toUnicode.pdfReference(doc));
+ buffer.append("/ToUnicode " + toUnicode.getIndirectReference().getSerializedReference());
buffer.append(EOL);
}
/**
* Returns the ToUnicode CMap for this font.
+ * @param doc The PDF Document.
* @return The ToUnicode CMap for this font.
*/
- protected PdfToUnicodeCmap getToUnicodeCMAP() {
+ protected PdfToUnicodeCmap getToUnicodeCMAP(final PdfDocument4a doc) {
return null;
}
@@ -388,7 +390,7 @@
return;
}
buffer.append("/DescendantFonts [ ");
- buffer.append(descendantFonts.pdfReference(doc));
+ buffer.append(descendantFonts.getIndirectReference().getSerializedReference());
buffer.append(" ] ");
buffer.append(EOL);
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2025-05-25 12:41:55 UTC (rev 13735)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2025-05-25 13:30:27 UTC (rev 13736)
@@ -100,6 +100,7 @@
// Create normal FontDescriptor
fontDesc = new PdfFontDescriptor(font);
}
+ pdfDoc.registerIndirectObject(fontDesc);
fontDesc.embedFont(pdfDoc);
return fontDesc;
}
@@ -196,7 +197,7 @@
default:
p.append(EOL + "/FontFile2 ");
}
- p.append(this.fontfile.pdfReference(doc));
+ p.append(this.fontfile.getIndirectReference().getSerializedReference());
}
// charSet for subset fonts // not yet implemented
// CID optional field
@@ -225,6 +226,7 @@
PdfFontFileStream stream = null;
try {
stream = new PdfFontFileStream(this.pdfFont.getFontUse());
+ doc.registerIndirectObject(stream);
} catch (final PdfException e) {
stream = null;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java 2025-05-25 12:41:55 UTC (rev 13735)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontType0.java 2025-05-25 13:30:27 UTC (rev 13736)
@@ -53,8 +53,8 @@
public PdfFontType0(final PdfDocument4a doc, final FontUse fsFont) {
super(doc, fsFont);
final PdfCidSystemInfo sysInfo = new PdfCidSystemInfo("Adobe", "UCS", 0);
- this.descendantFonts = new PdfCidFont(fsFont, sysInfo,
- (PdfCidFontDescriptor) getDescriptor());
+ this.descendantFonts = new PdfCidFont(fsFont, sysInfo, (PdfCidFontDescriptor) getDescriptor());
+ doc.registerIndirectObject(this.descendantFonts);
}
/**
@@ -61,9 +61,11 @@
* {@inheritDoc}
*/
@Override
- protected PdfToUnicodeCmap getToUnicodeCMAP() {
- return new PdfToUnicodeCmap(PdfCmap.Type.IDENTITY_H,
- this.descendantFonts.getSystemInfo(), getFontUse());
+ protected PdfToUnicodeCmap getToUnicodeCMAP(final PdfDocument4a doc) {
+ PdfToUnicodeCmap toUnicode = new PdfToUnicodeCmap(PdfCmap.Type.IDENTITY_H, this.descendantFonts.getSystemInfo(),
+ getFontUse());
+ doc.registerIndirectObject(toUnicode);
+ return toUnicode;
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfToUnicodeCmap.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfToUnicodeCmap.java 2025-05-25 12:41:55 UTC (rev 13735)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfToUnicodeCmap.java 2025-05-25 13:30:27 UTC (rev 13736)
@@ -69,13 +69,11 @@
/**
* Constructor.
- * @param name One of the registered names found in Table 5.14 in PDF
- * Reference, Second Edition.
+ * @param name One of the registered names found in Table 5.14 in PDF Reference, Second Edition.
* @param sysInfo The attributes of the character collection of the CIDFont.
* @param fsFont The encapsulated font.
*/
- public PdfToUnicodeCmap(final PdfCmap.Type name,
- final PdfCidSystemInfo sysInfo, final FontUse fsFont) {
+ public PdfToUnicodeCmap(final PdfCmap.Type name, final PdfCidSystemInfo sysInfo, final FontUse fsFont) {
super(name);
this.fsFont = fsFont;
}
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java 2025-05-25 12:41:55 UTC (rev 13735)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/serial/PdfParserTests.java 2025-05-25 13:30:27 UTC (rev 13736)
@@ -278,7 +278,7 @@
assertEquals(7, PdfInteger.unwrap(trailer.getPdfInteger("Size")).intValue());
final PdfObjectReference rootReference = trailer.getPdfObjectReference("Root");
- assertEquals(1, rootReference.getNumber());
+ assertEquals(2, rootReference.getNumber());
assertEquals(0, rootReference.getGeneration());
final PdfArray idArray = trailer.getPdfArray("ID");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 12:41:57
|
Revision: 13735
http://sourceforge.net/p/foray/code/13735
Author: victormote
Date: 2025-05-25 12:41:55 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java
trunk/foray/foray-pdf/src/test/resources/example/002-hello-world.pdf
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 12:10:11 UTC (rev 13734)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPage4a.java 2025-05-25 12:41:55 UTC (rev 13735)
@@ -103,6 +103,7 @@
this.pagewidth = pagewidth;
this.pageheight = pageheight;
this.contents = new PdfContentStream4a();
+ document.registerIndirectObject(this.contents);
try {
this.contents.addDefaultFilters(document);
} catch (final PdfException e) {
@@ -121,6 +122,7 @@
private PdfAnnotList getAnnotList() {
if (this.annotList == null) {
this.annotList = new PdfAnnotList();
+ this.parent.getRoot().getDocument().registerIndirectObject(annotList);
}
return this.annotList;
}
@@ -140,13 +142,13 @@
sb.append(this.getSerializedId() + EOL
+ "<<" + EOL
+ "/Type /Page" + EOL
- + "/Parent " + this.parent.pdfReference(doc) + EOL
+ + "/Parent " + this.parent.getIndirectReference().getSerializedReference() + EOL
+ "/MediaBox [ 0 0 " + this.pagewidth + " "
+ this.pageheight + " ]" + EOL
- + "/Resources " + this.resources.pdfReference(doc) + EOL
- + "/Contents " + this.contents.pdfReference(doc) + EOL);
+ + "/Resources " + this.resources.getIndirectReference().getSerializedReference() + EOL
+ + "/Contents " + this.contents.getIndirectReference().getSerializedReference() + EOL);
if (this.annotList != null) {
- sb.append("/Annots " + this.annotList.pdfReference(doc) + EOL);
+ sb.append("/Annots " + this.annotList.getIndirectReference().getSerializedReference() + EOL);
}
sb.append(">>" + EOL + "endobj" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java 2025-05-25 12:10:11 UTC (rev 13734)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfRoot.java 2025-05-25 12:41:55 UTC (rev 13735)
@@ -83,6 +83,7 @@
this.document = document;
this.pdfVersion = DEFAULT_PDF_VERSION;
this.pages = new PdfPages(this);
+ document.registerIndirectObject(this.pages);
this.names = new PdfNameDictionary(this);
}
@@ -148,7 +149,7 @@
p.append("/Type /Catalog");
p.append(EOL);
p.append("/Pages ");
- p.append(this.pages.pdfReference(doc));
+ p.append(this.pages.getIndirectReference().getSerializedReference());
p.append(EOL);
if (this.pageLabels != null) {
p.append("/PageLabels ");
Modified: trunk/foray/foray-pdf/src/test/resources/example/002-hello-world.pdf
===================================================================
--- trunk/foray/foray-pdf/src/test/resources/example/002-hello-world.pdf 2025-05-25 12:10:11 UTC (rev 13734)
+++ trunk/foray/foray-pdf/src/test/resources/example/002-hello-world.pdf 2025-05-25 12:41:55 UTC (rev 13735)
@@ -2,14 +2,27 @@
%\xAA\xAB\xAC\xAD
4 0 obj
<<
+/Length 59
+>>
+stream
+BT
+/F1 12.0 Tf
+1 0 0 1 36.0 576.0 Tm
+[(Hello World!)]TJ
+ET
+
+endstream
+endobj
+5 0 obj
+<<
/Type /Page
-/Parent 2 0 R
+/Parent 1 0 R
/MediaBox [ 0 0 396 612 ]
/Resources 3 0 R
-/Contents 6 0 R
+/Contents 4 0 R
>>
endobj
-5 0 obj
+6 0 obj
<<
/Type /Font
/Subtype /Type1
@@ -16,54 +29,41 @@
/BaseFont /Helvetica
>>
endobj
-6 0 obj
-<<
-/Length 59
->>
-stream
-BT
-/F1 12.0 Tf
-1 0 0 1 36.0 576.0 Tm
-[(Hello World!)]TJ
-ET
-
-endstream
-endobj
3 0 obj
<<
/Font
<<
-/F1 5 0 R
+/F1 6 0 R
>>
/ProcSet [ /PDF /ImageC /Text ]
>>
endobj
-2 0 obj
+1 0 obj
<< /Type /Pages
/Count 1
/Kids [
-4 0 R
+5 0 R
] >>
endobj
-1 0 obj
+2 0 obj
<<
/Type /Catalog
-/Pages 2 0 R
+/Pages 1 0 R
>>
endobj
xref
0 7
0000000000 65535 f
+0000000375 00000 n
0000000434 00000 n
-0000000375 00000 n
0000000300 00000 n
0000000015 00000 n
-0000000121 00000 n
-0000000191 00000 n
+0000000124 00000 n
+0000000230 00000 n
trailer
<<
/Size 7
-/Root 1 0 R
+/Root 2 0 R
/ID [
<4397CDCC3F8F94FD6C77A64F83E95278>
<7CA33F3FFDF62A30122D7AAD3DA09789>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 12:10:13
|
Revision: 13734
http://sourceforge.net/p/foray/code/13734
Author: victormote
Date: 2025-05-25 12:10:11 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Remove some inline creation of indirect references.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPages.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPages.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPages.java 2025-05-25 11:41:44 UTC (rev 13733)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfPages.java 2025-05-25 12:10:11 UTC (rev 13734)
@@ -84,7 +84,7 @@
p.append("/Kids [" + EOL);
for (int i = 0; i < this.kids.size(); i++) {
final PdfPage4a page = this.kids.get(i);
- final String pageRef = page.pdfReference(doc);
+ final String pageRef = page.getIndirectReference().getSerializedReference();
p.append(pageRef + EOL);
}
p.append("] >>" + EOL + "endobj" + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2025-05-25 11:41:44 UTC (rev 13733)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/PdfDestinationExplicit4a.java 2025-05-25 12:10:11 UTC (rev 13734)
@@ -83,7 +83,7 @@
buffer.append(this.getSerializedId());
buffer.append(EOL);
buffer.append("[");
- buffer.append(this.page.pdfReference(doc));
+ buffer.append(this.page.getIndirectReference().getSerializedReference());
buffer.append(" ");
buffer.append(this.positionAndZoom.getPdfName());
switch (this.positionAndZoom) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-25 11:41:46
|
Revision: 13733
http://sourceforge.net/p/foray/code/13733
Author: victormote
Date: 2025-05-25 11:41:44 +0000 (Sun, 25 May 2025)
Log Message:
-----------
Rough-in parser and handler for PDF.
Modified Paths:
--------------
trunk/foray/foray-pdf-parse/build.gradle
Added Paths:
-----------
trunk/foray/foray-pdf-parse/src/main/java/org/
trunk/foray/foray-pdf-parse/src/main/java/org/foray/
trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/
trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java
trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java
Modified: trunk/foray/foray-pdf-parse/build.gradle
===================================================================
--- trunk/foray/foray-pdf-parse/build.gradle 2025-05-24 16:32:59 UTC (rev 13732)
+++ trunk/foray/foray-pdf-parse/build.gradle 2025-05-25 11:41:44 UTC (rev 13733)
@@ -7,6 +7,10 @@
description = 'foray-pdf-parse'
dependencies {
+ api (group: 'org.axsl', name: 'axsl-pdf', version: versions.axsl)
+
+ implementation (project(':foray-common'))
+ implementation (project(':foray-pdf-core'))
}
javadoc {
Added: trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java
===================================================================
--- trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java (rev 0)
+++ trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java 2025-05-25 11:41:44 UTC (rev 13733)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf;
+
+public interface PdfHandler {
+
+}
Property changes on: trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java
===================================================================
--- trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java (rev 0)
+++ trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java 2025-05-25 11:41:44 UTC (rev 13733)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf;
+
+import org.foray.common.RandomAccessInput;
+
+import java.io.IOException;
+
+/**
+ * Parses a PDF.
+ */
+public class PdfParser {
+
+ public void parse(final RandomAccessInput input, final int offset, final PdfHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+}
Property changes on: trunk/foray/foray-pdf-parse/src/main/java/org/foray/pdf/PdfParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-24 16:33:04
|
Revision: 13732
http://sourceforge.net/p/foray/code/13732
Author: victormote
Date: 2025-05-24 16:32:59 +0000 (Sat, 24 May 2025)
Log Message:
-----------
Remove unneeded constructor.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfObjectReference.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfObjectReference.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfObjectReference.java 2025-05-24 15:23:40 UTC (rev 13731)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfObjectReference.java 2025-05-24 16:32:59 UTC (rev 13732)
@@ -29,11 +29,9 @@
package org.foray.pdf;
import org.foray.pdf.document.PdfDocument4a;
-import org.foray.pdf.type.PdfInteger;
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
-import org.axsl.pdf.PdfException;
import org.axsl.primitive.sequence.ByteSequencePlus;
/**
@@ -61,23 +59,6 @@
this.generation = generation;
}
- /**
- * Constructor.
- * @param objectNumber The object number for this reference.
- * @param generation The generation number for this reference.
- * @throws PdfException If either {@code objectNumber} or {@code generation} cannot be cast to {@link PdfInteger}.
- */
- public PdfObjectReference(final PdfObject objectNumber, final PdfObject generation) throws PdfException {
- if (! (objectNumber instanceof PdfInteger)) {
- throw new PdfException("Object Id value must be an integer, actual = " + objectNumber.toString());
- }
- if (! (generation instanceof PdfInteger)) {
- throw new PdfException("Generation must be an integer, actual = " + generation.toString());
- }
- this.number = ((PdfInteger) objectNumber).getValue();
- this.generation = ((PdfInteger) generation).getValue();
- }
-
@Override
public ByteSequencePlus serialize(final PdfDocument4a doc) {
return ByteArray.EMPTY;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-24 15:23:47
|
Revision: 13731
http://sourceforge.net/p/foray/code/13731
Author: victormote
Date: 2025-05-24 15:23:40 +0000 (Sat, 24 May 2025)
Log Message:
-----------
Move another common class to pdf-parse.
Added Paths:
-----------
trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfItem.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java 2025-05-24 15:20:13 UTC (rev 13730)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java 2025-05-24 15:23:40 UTC (rev 13731)
@@ -1,95 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf;
-
-import org.foray.primitive.StringUtils;
-
-import org.axsl.pdf.PdfException;
-import org.axsl.unicode.block.U0000_Basic_Latin;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-
-/**
- * Abstract superclass for all PDF "things".
- * There is no concept of a PDF Item defined in the references.
- * This class exists mostly as a way to generalize certain tasks whether they be for PDF objects, structures,
- * etc.
- */
-public abstract class PdfItem {
-
- /** The String that should be used to end a line in the PDF document.
- * Note that this always uses the Unix-style line ending, as it is more compact, and as the PDF generated should be
- * identical, regardless of the platform from which it is generated. */
- public static final String EOL = StringUtils.EMPTY_STRING + U0000_Basic_Latin.CONTROL_LINE_FEED;
-
- /** The String that should be used to end a cross-reference line in the PDF document.
- * According to the PDF Reference, 3rd Edition, Section 3.4.3, each cross-reference entry must be exactly 20 bytes
- * long, including the end-of-line character(s).
- * If a 1-character eol is used (such as a newline), then an extra character must be padded.
- * According to the Reference, that character must be a space. */
- public static final String XREF_EOL = StringUtils.SINGLE_SPACE + U0000_Basic_Latin.CONTROL_LINE_FEED;
-
- /** The String that should be used to end a line in log messages. */
- public static final String MSG_EOL = System.getProperty("line.separator");
-
- /**
- * Converts a StringBuilder buffer to an array of bytes.
- * @param buffer The input StringBuilder.
- * @return A properly-encoded array of bytes.
- */
- protected static byte[] bufferToByteArray(final StringBuilder buffer) {
- return stringToByteArray(buffer.toString());
- }
-
- /**
- * Converts a String to an array of bytes.
- * @param string The input String.
- * @return A properly-encoded array of bytes.
- */
- protected static byte[] stringToByteArray(final String string) {
- return string.getBytes(StandardCharsets.ISO_8859_1);
- }
-
- /**
- * Writes the content of a byte array to an output stream.
- * @param stream The stream to which the array should be written.
- * @param bytes The array to be written.
- * @throws PdfException For IO errors during output.
- */
- protected void byteArrayToStream(final byte[] bytes, final OutputStream stream) throws PdfException {
- try {
- stream.write(bytes);
- } catch (final IOException e) {
- throw new PdfException(e);
- }
- }
-
-}
Copied: trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfItem.java (from rev 13730, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java)
===================================================================
--- trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfItem.java (rev 0)
+++ trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfItem.java 2025-05-24 15:23:40 UTC (rev 13731)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2020 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf;
+
+import org.foray.primitive.StringUtils;
+
+import org.axsl.pdf.PdfException;
+import org.axsl.unicode.block.U0000_Basic_Latin;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * Abstract superclass for all PDF "things".
+ * There is no concept of a PDF Item defined in the references.
+ * This class exists mostly as a way to generalize certain tasks whether they be for PDF objects, structures,
+ * etc.
+ */
+public abstract class PdfItem {
+
+ /** The String that should be used to end a line in the PDF document.
+ * Note that this always uses the Unix-style line ending, as it is more compact, and as the PDF generated should be
+ * identical, regardless of the platform from which it is generated. */
+ public static final String EOL = StringUtils.EMPTY_STRING + U0000_Basic_Latin.CONTROL_LINE_FEED;
+
+ /** The String that should be used to end a cross-reference line in the PDF document.
+ * According to the PDF Reference, 3rd Edition, Section 3.4.3, each cross-reference entry must be exactly 20 bytes
+ * long, including the end-of-line character(s).
+ * If a 1-character eol is used (such as a newline), then an extra character must be padded.
+ * According to the Reference, that character must be a space. */
+ public static final String XREF_EOL = StringUtils.SINGLE_SPACE + U0000_Basic_Latin.CONTROL_LINE_FEED;
+
+ /** The String that should be used to end a line in log messages. */
+ public static final String MSG_EOL = System.getProperty("line.separator");
+
+ /**
+ * Converts a StringBuilder buffer to an array of bytes.
+ * @param buffer The input StringBuilder.
+ * @return A properly-encoded array of bytes.
+ */
+ protected static byte[] bufferToByteArray(final StringBuilder buffer) {
+ return stringToByteArray(buffer.toString());
+ }
+
+ /**
+ * Converts a String to an array of bytes.
+ * @param string The input String.
+ * @return A properly-encoded array of bytes.
+ */
+ protected static byte[] stringToByteArray(final String string) {
+ return string.getBytes(StandardCharsets.ISO_8859_1);
+ }
+
+ /**
+ * Writes the content of a byte array to an output stream.
+ * @param stream The stream to which the array should be written.
+ * @param bytes The array to be written.
+ * @throws PdfException For IO errors during output.
+ */
+ protected void byteArrayToStream(final byte[] bytes, final OutputStream stream) throws PdfException {
+ try {
+ stream.write(bytes);
+ } catch (final IOException e) {
+ throw new PdfException(e);
+ }
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-24 15:20:15
|
Revision: 13730
http://sourceforge.net/p/foray/code/13730
Author: victormote
Date: 2025-05-24 15:20:13 +0000 (Sat, 24 May 2025)
Log Message:
-----------
Clean up dependency on PdfDocument4a.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfRectangle.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
trunk/foray/foray-pdf-core/build.gradle
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java 2025-05-24 14:01:20 UTC (rev 13729)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java 2025-05-24 15:20:13 UTC (rev 13730)
@@ -28,7 +28,6 @@
package org.foray.pdf;
-import org.foray.pdf.document.PdfDocument4a;
import org.foray.primitive.StringUtils;
import org.axsl.pdf.PdfException;
@@ -36,7 +35,7 @@
import java.io.IOException;
import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
/**
* Abstract superclass for all PDF "things".
@@ -76,11 +75,7 @@
* @return A properly-encoded array of bytes.
*/
protected static byte[] stringToByteArray(final String string) {
- try {
- return string.getBytes(PdfDocument4a.ENCODING);
- } catch (final UnsupportedEncodingException ue) {
- return string.getBytes();
- }
+ return string.getBytes(StandardCharsets.ISO_8859_1);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2025-05-24 14:01:20 UTC (rev 13729)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2025-05-24 15:20:13 UTC (rev 13730)
@@ -112,10 +112,6 @@
*/
public class PdfDocument4a implements PdfDocument<PdfPage4a>, VectorOutputContext {
- /** Name of the CharSet that should be used when converting Strings to
- * bytes. */
- public static final String ENCODING = "ISO-8859-1";
-
/** This document's permanent file ID, if any. */
private ByteArray permanentFileId;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfRectangle.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfRectangle.java 2025-05-24 14:01:20 UTC (rev 13729)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/structure/PdfRectangle.java 2025-05-24 15:20:13 UTC (rev 13730)
@@ -28,11 +28,9 @@
package org.foray.pdf.structure;
-import org.foray.pdf.document.PdfDocument4a;
-
import org.axsl.ps.BoundingBox;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
/**
* A PDF rectangle.
@@ -98,11 +96,7 @@
* @return the PDF
*/
public byte[] toPDF() {
- try {
- return toPDFString().getBytes(PdfDocument4a.ENCODING);
- } catch (final UnsupportedEncodingException ue) {
- return toPDFString().getBytes();
- }
+ return toPDFString().getBytes(StandardCharsets.ISO_8859_1);
}
/**
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-24 14:01:20 UTC (rev 13729)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-24 15:20:13 UTC (rev 13730)
@@ -41,6 +41,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@@ -86,7 +87,7 @@
this.filtersLocked = true;
try {
try {
- this.out.write(content.toString().getBytes(PdfDocument4a.ENCODING));
+ this.out.write(content.toString().getBytes(StandardCharsets.ISO_8859_1));
} catch (final UnsupportedEncodingException ue) {
this.out.write(content.toString().getBytes());
}
@@ -307,11 +308,7 @@
throws PdfException {
int length = 0;
byte[] p;
- try {
- p = ("stream" + EOL).getBytes(PdfDocument4a.ENCODING);
- } catch (final UnsupportedEncodingException ue) {
- p = ("stream" + EOL).getBytes();
- }
+ p = ("stream" + EOL).getBytes(StandardCharsets.ISO_8859_1);
byteArrayToStream(p, stream);
length += p.length;
try {
@@ -322,11 +319,7 @@
throw new PdfException(e);
}
length += this.streamData.size();
- try {
- p = (EOL + "endstream" + EOL).getBytes(PdfDocument4a.ENCODING);
- } catch (final UnsupportedEncodingException ue) {
- p = (EOL + "endstream" + EOL).getBytes();
- }
+ p = (EOL + "endstream" + EOL).getBytes(StandardCharsets.ISO_8859_1);
byteArrayToStream(p, stream);
length += p.length;
return length;
Modified: trunk/foray/foray-pdf-core/build.gradle
===================================================================
--- trunk/foray/foray-pdf-core/build.gradle 2025-05-24 14:01:20 UTC (rev 13729)
+++ trunk/foray/foray-pdf-core/build.gradle 2025-05-24 15:20:13 UTC (rev 13730)
@@ -8,6 +8,8 @@
dependencies {
+ api (group: 'org.axsl', name: 'axsl-pdf', version: versions.axsl)
+
implementation (project(':foray-primitive'))
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-24 14:01:22
|
Revision: 13729
http://sourceforge.net/p/foray/code/13729
Author: victormote
Date: 2025-05-24 14:01:20 +0000 (Sat, 24 May 2025)
Log Message:
-----------
Move one class to the new foray-pdf-core project.
Modified Paths:
--------------
trunk/foray/foray-pdf/build.gradle
trunk/foray/foray-pdf-core/build.gradle
Added Paths:
-----------
trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfConstants.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java
Modified: trunk/foray/foray-pdf/build.gradle
===================================================================
--- trunk/foray/foray-pdf/build.gradle 2025-05-24 13:42:17 UTC (rev 13728)
+++ trunk/foray/foray-pdf/build.gradle 2025-05-24 14:01:20 UTC (rev 13729)
@@ -21,6 +21,7 @@
api (project(':foray-common'))
implementation (project(':foray-primitive'))
+ implementation (project(':foray-pdf-core'))
testImplementation (project(':foray-font'))
testImplementation (project(":foray-ps-data"))
Deleted: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java 2025-05-24 13:42:17 UTC (rev 13728)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java 2025-05-24 14:01:20 UTC (rev 13729)
@@ -1,199 +0,0 @@
-/*
- * Copyright 2020 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.pdf;
-
-import org.foray.primitive.sequence.ByteArray;
-
-import org.axsl.unicode.block.U0000_Basic_Latin;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Constants specific to PDF creation or parsing.
- */
-public final class PdfConstants {
-
- /** The PDF delimiter that opens a dictionary: {@code <<}. */
- public static final ByteArray OPEN_DICTIONARY = new ByteArray("<<");
-
- /** The PDF delimiter that closes a dictionary: {@code >>}. */
- public static final ByteArray CLOSE_DICTIONARY = new ByteArray(">>");
-
- /** The PDF delimiter that opens a literal string: {@code (}. */
- public static final ByteArray OPEN_STRING_LITERAL = new ByteArray("(");
-
- /** The PDF delimiter that closes a literal string: {@code)}. */
- public static final ByteArray CLOSE_STRING_LITERAL = new ByteArray(")");
-
- /** The PDF delimiter that opens a hex string: {@code <}. */
- public static final ByteArray OPEN_STRING_HEX = new ByteArray("<");
-
- /** The PDF delimiter that closes a hex string: {@code >}. */
- public static final ByteArray CLOSE_STRING_HEX = new ByteArray(">");
-
- /** The PDF delimiter that opens an array: {@code [}. */
- public static final ByteArray OPEN_ARRAY = new ByteArray("[");
-
- /** The PDF delimiter that closes an array: {@code ]}. */
- public static final ByteArray CLOSE_ARRAY = new ByteArray("]");
-
- /** The PDF delimiter that opens a function: "{". */
- public static final ByteArray OPEN_FUNCTION = new ByteArray("{");
-
- /** The PDF delimiter that closes a function: "}". */
- public static final ByteArray CLOSE_FUNCTION = new ByteArray("}");
-
- /** The PDF delimiter that prefixes a name object: {@code /}. */
- public static final ByteArray NAME_PREFIX = new ByteArray("/");
-
- /** The PDF delimiter that opens a comment: {@code %}. Note that an end-of-line closes the comment. */
- public static final ByteArray OPEN_COMMENT = new ByteArray("%");
-
- /** Escape characters for parsing literal PDF strings: {@value}. */
- public static final byte TEXT_ESCAPE_CHAR = (byte) '\\';
-
- /** Escape characters for parsing literal PDF strings. */
- public static final ByteArray TEXT_ESCAPE_CHARS = new ByteArray(TEXT_ESCAPE_CHAR);
-
- /** Byte array containing the token for the beginning of a stream: {@code obj}. */
- public static final ByteArray KEYWORD_START_OBJECT = new ByteArray("obj");
-
- /** Byte array containing the token for the end of a stream: {@code endobj}. */
- public static final ByteArray KEYWORD_END_OBJECT = new ByteArray("endobj");
-
- /** Byte array containing the token for the beginning of a stream: {@code stream}. */
- public static final ByteArray KEYWORD_START_STREAM = new ByteArray("stream");
-
- /** Byte array containing the token for the end of a stream: {@code endstream}. */
- public static final ByteArray KEYWORD_END_STREAM = new ByteArray("endstream");
-
- /** Character used to indicate that the object being parsed is a reference to an indirect object: {@code R}. */
- public static final ByteArray KEYWORD_REFERENCE_MARKER = new ByteArray("R");
-
- /**
- * Comment marker for the beginning of a PDF: "%PDF-".
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.2."
- */
- public static final ByteArray DOCUMENT_BEGIN_MARKER = new ByteArray("%PDF-");
-
- /**
- * Comment marker for the end of a PDF: "%%EOF".
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.2."
- */
- public static final ByteArray DOCUMENT_END_MARKER = new ByteArray("%%EOF");
-
- /** The carriage-return / linefeed combination, cast as a byte array. */
- public static final ByteArray ASCII_CARRIAGE_RETURN_LINEFEED =
- new ByteArray((byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN, (byte) U0000_Basic_Latin.CONTROL_LINE_FEED);
-
- /**
- * The PDF delimiter characters.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.1."
- */
- public static final List<ByteArray> PDF_DELIMITERS = Arrays.asList(
- /* Keep multi-byte arrays at the top of the list to make sure they get searched first. */
- PdfConstants.OPEN_DICTIONARY,
- PdfConstants.CLOSE_DICTIONARY,
-
- /* Single-byte arrays at the bottom of the list. */
- PdfConstants.OPEN_STRING_LITERAL,
- PdfConstants.CLOSE_STRING_LITERAL,
- PdfConstants.OPEN_STRING_HEX,
- PdfConstants.CLOSE_STRING_HEX,
- PdfConstants.OPEN_ARRAY,
- PdfConstants.CLOSE_ARRAY,
- PdfConstants.OPEN_FUNCTION,
- PdfConstants.CLOSE_FUNCTION,
- PdfConstants.NAME_PREFIX,
- PdfConstants.OPEN_COMMENT
- );
-
- /**
- * The PDF end-of-line delimiter characters.
- */
- public static final List<ByteArray> PDF_END_OF_LINE_DELIMITERS = Arrays.asList(
- /* Keep multi-byte arrays at the top of the list to make sure they get searched first. */
- PdfConstants.ASCII_CARRIAGE_RETURN_LINEFEED,
-
- /* Single-byte arrays at the bottom of the list. */
- new ByteArray((byte) U0000_Basic_Latin.CONTROL_LINE_FEED),
- new ByteArray((byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN)
- );
-
- /**
- * The PDF whitespace characters.
- * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.1, especially Table 3.1."
- */
- public static final ByteArray PDF_WHITESPACE = new ByteArray(
- (byte) U0000_Basic_Latin.CONTROL_NULL,
- (byte) U0000_Basic_Latin.CONTROL_CHARACTER_TABULATION,
- (byte) U0000_Basic_Latin.CONTROL_LINE_FEED,
- (byte) U0000_Basic_Latin.CONTROL_FORM_FEED,
- (byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN,
- (byte) U0000_Basic_Latin.SPACE);
-
- /** The maximum size, in bytes, of the file ID field. */
- public static final int FILE_ID_SIZE = 16;
-
- /** Constant indicating the number of components in a radial shading: {@value}. */
- public static final int QTY_RADIAL_SHADING_COMPONENTS = 6;
-
- /** The maximum value for an object generation. */
- public static final int MAX_OBJECT_GENERATION = 65535;
-
- /**
- * Constant indicating the number of elements describing the end point of a line when drawing a path, which is
- * {@value}.
- * There is 1 point defined, containing 2 elements.
- * @see java.awt.geom.PathIterator#SEG_LINETO
- */
- public static final byte QTY_ELEMENTS_LINEAR = 2;
-
- /**
- * Constant indicating the number of elements in a quadratic parametric curve when drawing a path, which is
- * {@value}.
- * There are 2 points defined, each containing 2 elements.
- * @see java.awt.geom.PathIterator#SEG_QUADTO
- */
- public static final byte QTY_ELEMENTS_QUAD = 4;
-
- /**
- * Constant indicating the number of elements in a cubic Bezier curve when drawing a path, which is {@value}.
- * There are 3 points defined, each containing 2 elements.
- * @see java.awt.geom.PathIterator#SEG_CUBICTO
- */
- public static final byte QTY_ELEMENTS_CUBIC = 6;
-
- /**
- * Private constructor. This is a utility class and should never be instantiated.
- */
- private PdfConstants() { }
-
-}
Modified: trunk/foray/foray-pdf-core/build.gradle
===================================================================
--- trunk/foray/foray-pdf-core/build.gradle 2025-05-24 13:42:17 UTC (rev 13728)
+++ trunk/foray/foray-pdf-core/build.gradle 2025-05-24 14:01:20 UTC (rev 13729)
@@ -7,6 +7,9 @@
description = 'foray-pdf-core'
dependencies {
+
+ implementation (project(':foray-primitive'))
+
}
javadoc {
Copied: trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfConstants.java (from rev 13727, trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java)
===================================================================
--- trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfConstants.java (rev 0)
+++ trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/PdfConstants.java 2025-05-24 14:01:20 UTC (rev 13729)
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2020 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.pdf;
+
+import org.foray.primitive.sequence.ByteArray;
+
+import org.axsl.unicode.block.U0000_Basic_Latin;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Constants specific to PDF creation or parsing.
+ */
+public final class PdfConstants {
+
+ /** The PDF delimiter that opens a dictionary: {@code <<}. */
+ public static final ByteArray OPEN_DICTIONARY = new ByteArray("<<");
+
+ /** The PDF delimiter that closes a dictionary: {@code >>}. */
+ public static final ByteArray CLOSE_DICTIONARY = new ByteArray(">>");
+
+ /** The PDF delimiter that opens a literal string: {@code (}. */
+ public static final ByteArray OPEN_STRING_LITERAL = new ByteArray("(");
+
+ /** The PDF delimiter that closes a literal string: {@code)}. */
+ public static final ByteArray CLOSE_STRING_LITERAL = new ByteArray(")");
+
+ /** The PDF delimiter that opens a hex string: {@code <}. */
+ public static final ByteArray OPEN_STRING_HEX = new ByteArray("<");
+
+ /** The PDF delimiter that closes a hex string: {@code >}. */
+ public static final ByteArray CLOSE_STRING_HEX = new ByteArray(">");
+
+ /** The PDF delimiter that opens an array: {@code [}. */
+ public static final ByteArray OPEN_ARRAY = new ByteArray("[");
+
+ /** The PDF delimiter that closes an array: {@code ]}. */
+ public static final ByteArray CLOSE_ARRAY = new ByteArray("]");
+
+ /** The PDF delimiter that opens a function: "{". */
+ public static final ByteArray OPEN_FUNCTION = new ByteArray("{");
+
+ /** The PDF delimiter that closes a function: "}". */
+ public static final ByteArray CLOSE_FUNCTION = new ByteArray("}");
+
+ /** The PDF delimiter that prefixes a name object: {@code /}. */
+ public static final ByteArray NAME_PREFIX = new ByteArray("/");
+
+ /** The PDF delimiter that opens a comment: {@code %}. Note that an end-of-line closes the comment. */
+ public static final ByteArray OPEN_COMMENT = new ByteArray("%");
+
+ /** Escape characters for parsing literal PDF strings: {@value}. */
+ public static final byte TEXT_ESCAPE_CHAR = (byte) '\\';
+
+ /** Escape characters for parsing literal PDF strings. */
+ public static final ByteArray TEXT_ESCAPE_CHARS = new ByteArray(TEXT_ESCAPE_CHAR);
+
+ /** Byte array containing the token for the beginning of a stream: {@code obj}. */
+ public static final ByteArray KEYWORD_START_OBJECT = new ByteArray("obj");
+
+ /** Byte array containing the token for the end of a stream: {@code endobj}. */
+ public static final ByteArray KEYWORD_END_OBJECT = new ByteArray("endobj");
+
+ /** Byte array containing the token for the beginning of a stream: {@code stream}. */
+ public static final ByteArray KEYWORD_START_STREAM = new ByteArray("stream");
+
+ /** Byte array containing the token for the end of a stream: {@code endstream}. */
+ public static final ByteArray KEYWORD_END_STREAM = new ByteArray("endstream");
+
+ /** Character used to indicate that the object being parsed is a reference to an indirect object: {@code R}. */
+ public static final ByteArray KEYWORD_REFERENCE_MARKER = new ByteArray("R");
+
+ /**
+ * Comment marker for the beginning of a PDF: "%PDF-".
+ * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.2."
+ */
+ public static final ByteArray DOCUMENT_BEGIN_MARKER = new ByteArray("%PDF-");
+
+ /**
+ * Comment marker for the end of a PDF: "%%EOF".
+ * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.2."
+ */
+ public static final ByteArray DOCUMENT_END_MARKER = new ByteArray("%%EOF");
+
+ /** The carriage-return / linefeed combination, cast as a byte array. */
+ public static final ByteArray ASCII_CARRIAGE_RETURN_LINEFEED =
+ new ByteArray((byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN, (byte) U0000_Basic_Latin.CONTROL_LINE_FEED);
+
+ /**
+ * The PDF delimiter characters.
+ * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.1."
+ */
+ public static final List<ByteArray> PDF_DELIMITERS = Arrays.asList(
+ /* Keep multi-byte arrays at the top of the list to make sure they get searched first. */
+ PdfConstants.OPEN_DICTIONARY,
+ PdfConstants.CLOSE_DICTIONARY,
+
+ /* Single-byte arrays at the bottom of the list. */
+ PdfConstants.OPEN_STRING_LITERAL,
+ PdfConstants.CLOSE_STRING_LITERAL,
+ PdfConstants.OPEN_STRING_HEX,
+ PdfConstants.CLOSE_STRING_HEX,
+ PdfConstants.OPEN_ARRAY,
+ PdfConstants.CLOSE_ARRAY,
+ PdfConstants.OPEN_FUNCTION,
+ PdfConstants.CLOSE_FUNCTION,
+ PdfConstants.NAME_PREFIX,
+ PdfConstants.OPEN_COMMENT
+ );
+
+ /**
+ * The PDF end-of-line delimiter characters.
+ */
+ public static final List<ByteArray> PDF_END_OF_LINE_DELIMITERS = Arrays.asList(
+ /* Keep multi-byte arrays at the top of the list to make sure they get searched first. */
+ PdfConstants.ASCII_CARRIAGE_RETURN_LINEFEED,
+
+ /* Single-byte arrays at the bottom of the list. */
+ new ByteArray((byte) U0000_Basic_Latin.CONTROL_LINE_FEED),
+ new ByteArray((byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN)
+ );
+
+ /**
+ * The PDF whitespace characters.
+ * @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.1, especially Table 3.1."
+ */
+ public static final ByteArray PDF_WHITESPACE = new ByteArray(
+ (byte) U0000_Basic_Latin.CONTROL_NULL,
+ (byte) U0000_Basic_Latin.CONTROL_CHARACTER_TABULATION,
+ (byte) U0000_Basic_Latin.CONTROL_LINE_FEED,
+ (byte) U0000_Basic_Latin.CONTROL_FORM_FEED,
+ (byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN,
+ (byte) U0000_Basic_Latin.SPACE);
+
+ /** The maximum size, in bytes, of the file ID field. */
+ public static final int FILE_ID_SIZE = 16;
+
+ /** Constant indicating the number of components in a radial shading: {@value}. */
+ public static final int QTY_RADIAL_SHADING_COMPONENTS = 6;
+
+ /** The maximum value for an object generation. */
+ public static final int MAX_OBJECT_GENERATION = 65535;
+
+ /**
+ * Constant indicating the number of elements describing the end point of a line when drawing a path, which is
+ * {@value}.
+ * There is 1 point defined, containing 2 elements.
+ * @see java.awt.geom.PathIterator#SEG_LINETO
+ */
+ public static final byte QTY_ELEMENTS_LINEAR = 2;
+
+ /**
+ * Constant indicating the number of elements in a quadratic parametric curve when drawing a path, which is
+ * {@value}.
+ * There are 2 points defined, each containing 2 elements.
+ * @see java.awt.geom.PathIterator#SEG_QUADTO
+ */
+ public static final byte QTY_ELEMENTS_QUAD = 4;
+
+ /**
+ * Constant indicating the number of elements in a cubic Bezier curve when drawing a path, which is {@value}.
+ * There are 3 points defined, each containing 2 elements.
+ * @see java.awt.geom.PathIterator#SEG_CUBICTO
+ */
+ public static final byte QTY_ELEMENTS_CUBIC = 6;
+
+ /**
+ * Private constructor. This is a utility class and should never be instantiated.
+ */
+ private PdfConstants() { }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|