Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<dom4j.version>2.2.0</dom4j.version>
<flatlaf.version>3.6.2</flatlaf.version>
<icu4j.version>76.1</icu4j.version>
<itext.version>9.4.0</itext.version>
<itext.version>9.5.0-SNAPSHOT</itext.version>
<jackson.version>2.20.1</jackson.version>
<logback.version>1.5.21</logback.version>

Expand Down Expand Up @@ -117,6 +117,11 @@
<artifactId>bouncy-castle-adapter</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>brotli-compressor</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/com/itextpdf/rups/RupsConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.rups;

import com.itextpdf.brotlicompressor.BrotliStreamCompressionStrategy;
import com.itextpdf.kernel.pdf.FlateCompressionStrategy;
import com.itextpdf.kernel.pdf.IStreamCompressionStrategy;
import com.itextpdf.kernel.pdf.PdfName;
import com.itextpdf.rups.conf.LookAndFeelId;
import com.itextpdf.rups.model.LoggerHelper;
import com.itextpdf.rups.model.MruListHandler;
Expand Down Expand Up @@ -94,6 +98,7 @@ public enum RupsConfiguration {
private static final String DEFAULT_HOME_VALUE = "home";
private static final String CLOSE_OPERATION_KEY = "ui.closeoperation";
private static final String DUPLICATE_OPEN_FILES_KEY = "rups.duplicatefiles";
private static final String DEFAULT_FILTER_KEY = "rups.defaultfilter";
private static final String HOME_FOLDER_KEY = "user.home";
private static final String LOCALE_KEY = "user.locale";
private static final String LOOK_AND_FEEL_KEY = "ui.lookandfeel";
Expand Down Expand Up @@ -132,6 +137,39 @@ public boolean canOpenDuplicateFiles() {
return Boolean.parseBoolean(value);
}

/**
* Returns which default compression filter RUPS should use for streams.
*
* @return PdfName of the compression filter, or {@code null} if none.
*/
public PdfName getDefaultFilter() {
final String value = getValueFromSystemPreferences(DEFAULT_FILTER_KEY);
if (PdfName.FlateDecode.getValue().equals(value)) {
return PdfName.FlateDecode;
}
if (PdfName.BrotliDecode.getValue().equals(value)) {
return PdfName.BrotliDecode;
}
return null;
}

/**
* Returns which default compression filter strategy RUPS should use for streams.
*
* @return compression strategy for the default filter or {@code null} if
* no compression required.
*/
public IStreamCompressionStrategy getDefaultFilterStrategy() {
final String value = getValueFromSystemPreferences(DEFAULT_FILTER_KEY);
if (PdfName.FlateDecode.getValue().equals(value)) {
return new FlateCompressionStrategy();
}
if (PdfName.BrotliDecode.getValue().equals(value)) {
return new BrotliStreamCompressionStrategy();
}
return null;
}

/**
* Returns the closing operation for the RUPS instance. Default it is returning EXIT_ON_CLOSE, but
* another value could be useful when embedding RUPS or calling it from a Java process.
Expand Down Expand Up @@ -218,6 +256,18 @@ public void setOpenDuplicateFiles(boolean value) {
this.temporaryProperties.setProperty(DUPLICATE_OPEN_FILES_KEY, Boolean.toString(value));
}

/**
* Sets which default compression filter RUPS should use for streams.
*
* @param value PdfName of the compression filter, or {@code null} if none.
*/
public void setDefaultFilter(PdfName value) {
this.temporaryProperties.setProperty(
DEFAULT_FILTER_KEY,
value != null ? value.getValue() : "null"
);
}

/**
* Sets the default folder to use in JFileChoosers.
*
Expand Down
79 changes: 79 additions & 0 deletions src/main/java/com/itextpdf/rups/conf/StreamFilterId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2025 Apryse Group NV
Authors: Apryse Software.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation with the addition of the
following permission added to Section 15 as permitted in Section 7(a):
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
APRYSE GROUP. APRYSE GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
OF THIRD PARTY RIGHTS

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, see http://www.gnu.org/licenses or write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA, 02110-1301 USA, or download the license from the following URL:
http://itextpdf.com/terms-of-use/

The interactive user interfaces in modified source and object code versions
of this program must display Appropriate Legal Notices, as required under
Section 5 of the GNU Affero General Public License.

In accordance with Section 7(b) of the GNU Affero General Public License,
a covered work must retain the producer line in every PDF that is created
or manipulated using iText.

You can be released from the requirements of the license by purchasing
a commercial license. Buying such a license is mandatory as soon as you
develop commercial activities involving the iText software without
disclosing the source code of your own applications.
These activities include: offering paid services to customers as an ASP,
serving PDFs on the fly in a web application, shipping iText with a closed
source product.

For more information, please contact iText Software Corp. at this
address: sales@itextpdf.com
*/
package com.itextpdf.rups.conf;

import com.itextpdf.kernel.pdf.PdfName;
import com.itextpdf.rups.view.Language;

import java.util.Objects;

public class StreamFilterId {
private final PdfName value;

public StreamFilterId(PdfName value) {
this.value = value;
}

public PdfName getValue() {
return value;
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
final StreamFilterId that = (StreamFilterId) o;
return Objects.equals(value, that.value);
}

@Override
public int hashCode() {
return Objects.hashCode(value);
}

@Override
public String toString() {
return value != null ? value.getValue() : Language.NONE.getString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public PdfReaderController(TreeSelectionListener treeSelectionListener,
pdfTree = new PdfTree();

pdfTree.addTreeSelectionListener(treeSelectionListener);
final PdfTreeContextMenu menu = new PdfTreeContextMenu(pdfTree);
final PdfTreeContextMenu menu = new PdfTreeContextMenu(pdfTree, this);
pdfTree.setComponentPopupMenu(menu);
pdfTree.addMouseListener(new PdfTreeContextMenuMouseListener(menu, pdfTree));

Expand Down Expand Up @@ -386,15 +386,20 @@ public int addTreeNodeArrayChild(PdfObjectTreeNode parent, int index) {

public int deleteTreeChild(PdfObjectTreeNode parent, int index) {
parent.remove(index);
((DefaultTreeModel) pdfTree.getModel()).reload(parent);
getTreeModel().reload(parent);
return index;
}

public void deleteAllTreeChildren(PdfObjectTreeNode parent) {
parent.removeAllChildren();
getTreeModel().reload(parent);
}

//Returns index of the added child
public int addTreeNodeChild(PdfObjectTreeNode parent, PdfObjectTreeNode child, int index) {
parent.insert(child, index);
nodes.expandNode(child);
((DefaultTreeModel) pdfTree.getModel()).reload(parent);
getTreeModel().reload(parent);
return index;
}

Expand Down Expand Up @@ -477,4 +482,8 @@ private void forAllComponents(Consumer<IRupsEventListener> func) {
func.accept(objectPanel);
func.accept(streamPane);
}

private DefaultTreeModel getTreeModel() {
return (DefaultTreeModel) pdfTree.getModel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public void valueChanged(TreeSelectionEvent evt) {
*/
final JPopupMenu menu = tree.getComponentPopupMenu();
if ((menu instanceof PdfTreeContextMenu) && (selectedNode instanceof IPdfContextMenuTarget)) {
((PdfTreeContextMenu) menu).setEnabledForNode((IPdfContextMenuTarget) selectedNode);
((PdfTreeContextMenu) menu).prepareForNode((IPdfContextMenuTarget) selectedNode);
}

if (selectedNode instanceof PdfTrailerTreeNode) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2025 Apryse Group NV
Authors: Apryse Software.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation with the addition of the
following permission added to Section 15 as permitted in Section 7(a):
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
APRYSE GROUP. APRYSE GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
OF THIRD PARTY RIGHTS

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, see http://www.gnu.org/licenses or write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA, 02110-1301 USA, or download the license from the following URL:
http://itextpdf.com/terms-of-use/

The interactive user interfaces in modified source and object code versions
of this program must display Appropriate Legal Notices, as required under
Section 5 of the GNU Affero General Public License.

In accordance with Section 7(b) of the GNU Affero General Public License,
a covered work must retain the producer line in every PDF that is created
or manipulated using iText.

You can be released from the requirements of the license by purchasing
a commercial license. Buying such a license is mandatory as soon as you
develop commercial activities involving the iText software without
disclosing the source code of your own applications.
These activities include: offering paid services to customers as an ASP,
serving PDFs on the fly in a web application, shipping iText with a closed
source product.

For more information, please contact iText Software Corp. at this
address: sales@itextpdf.com
*/
package com.itextpdf.rups.io.encoders;

import com.itextpdf.kernel.pdf.IStreamCompressionStrategy;
import com.itextpdf.kernel.pdf.PdfName;
import com.itextpdf.kernel.pdf.PdfObject;
import com.itextpdf.kernel.pdf.PdfStream;

import java.io.OutputStream;

public class ASCII85CompressionStrategy implements IStreamCompressionStrategy {
@Override
public PdfName getFilterName() {
return PdfName.ASCII85Decode;
}

@Override
public PdfObject getDecodeParams() {
return null;
}

@Override
public OutputStream createNewOutputStream(OutputStream original, PdfStream stream) {
return new ASCII85OutputStream(original);
}
}
Loading