Author: tilman
Date: Sat Sep 19 10:47:52 2026
New Revision: 1938364

Log:
PDFBOX-6262: Consolidate command line options for tools in PDFBox and classes 
for the tools, by Volker Kunert; closes #531

Modified:
   
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
   
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/DecompressObjectstreams.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExportFDF.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExportXFDF.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractXMP.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImageToPDF.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImportFDF.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImportXFDF.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/OverlayPDF.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java
   pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java

Modified: 
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
==============================================================================
--- 
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java 
    Sat Sep 19 08:30:40 2026        (r1938363)
+++ 
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java 
    Sat Sep 19 10:47:52 2026        (r1938364)
@@ -165,7 +165,7 @@ import picocli.CommandLine.Model.Command
  * @author Khyrul Bashar
  */
 @SuppressWarnings({ "serial", "squid:MaximumInheritanceDepth", "squid:S1948" })
-@Command(name = "pdfdebugger", description = "Analyzes and inspects the 
internal structure of a PDF document")
+@Command(name = "debug", description = "Analyzes and inspects the internal 
structure of a PDF document")
 public class PDFDebugger extends JFrame implements Callable<Integer>, 
HyperlinkListener
 {
     private static Logger LOG; // needs late initialization

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/DecompressObjectstreams.java
==============================================================================
--- 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/DecompressObjectstreams.java
       Sat Sep 19 08:30:40 2026        (r1938363)
+++ 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/DecompressObjectstreams.java
       Sat Sep 19 10:47:52 2026        (r1938364)
@@ -1,97 +1,97 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.pdfbox.tools;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.concurrent.Callable;
-
-import org.apache.pdfbox.Loader;
-import org.apache.pdfbox.pdfwriter.compress.CompressParameters;
-import org.apache.pdfbox.pdmodel.PDDocument;
-
-import picocli.CommandLine;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-/**
- * This program will just save the loaded pdf without any changes. As PDFBox 
doesn't support writing compressed object
- * streams those streams are stripped and will be gone in the resulting file. 
This is very helpful when trying to debug
- * problems as it'll make it possible to easily look through a PDF using a 
text editor. It also exposes problems which
- * stem from objects inside object streams overwriting other objects.
- * 
- * @author Adam Nichols
- */
-@Command(name = "DecompressObjectstreams", header = "Decompresses object 
streams in a PDF file.")
-public final class DecompressObjectstreams implements Callable<Integer>
-{
-    // Expected for CLI app to write to System.out/System.err
-    @SuppressWarnings("squid:S106")
-    private final PrintStream SYSERR;
-
-    @Option(names = {"-h", "--help"}, usageHelp = true, description = "display 
this help message")
-    boolean usageHelpRequested;
-    
-    @Option(names = {"-i", "--input"}, description = "the PDF file to 
decompress", required = true)
-    private File infile;
-
-    @Option(names = {"-o", "--output"}, description = "the decompressed PDF 
file. If omitted the original file is overwritten.")
-    private File outfile;
-    
-    /**
-     * Constructor.
-     */
-    public DecompressObjectstreams()
-    {
-        SYSERR = System.err;
-    }
-
-    /**
-     * This is the entry point for the application.
-     *
-     * @param args The command-line arguments.
-     */
-    public static void main(String[] args)
-    {
-        // suppress the Dock icon on OS X
-        System.setProperty("apple.awt.UIElement", "true");
-
-        int exitCode = new CommandLine(new 
DecompressObjectstreams()).execute(args);
-        System.exit(exitCode);
-    }
-
-    public Integer call()
-    {
-        try (PDDocument doc = Loader.loadPDF(infile))
-        {
-            // overwrite inputfile if no outputfile was specified
-            if (outfile == null) {
-                outfile = infile;
-            }
-
-            doc.save(outfile, CompressParameters.NO_COMPRESSION);
-        }
-        catch (IOException ioe)
-        {
-            SYSERR.println("Error processing file [" + 
ioe.getClass().getSimpleName() + "]: " + ioe.getMessage());
-            return 4;
-        }
-        return 0;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.pdfbox.tools;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.concurrent.Callable;
+
+import org.apache.pdfbox.Loader;
+import org.apache.pdfbox.pdfwriter.compress.CompressParameters;
+import org.apache.pdfbox.pdmodel.PDDocument;
+
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+/**
+ * This program will just save the loaded pdf without any changes. As PDFBox 
doesn't support writing compressed object
+ * streams those streams are stripped and will be gone in the resulting file. 
This is very helpful when trying to debug
+ * problems as it'll make it possible to easily look through a PDF using a 
text editor. It also exposes problems which
+ * stem from objects inside object streams overwriting other objects.
+ * 
+ * @author Adam Nichols
+ */
+@Command(name = "decompress", header = "Decompresses object streams in a PDF 
file.")
+public final class DecompressObjectstreams implements Callable<Integer>
+{
+    // Expected for CLI app to write to System.out/System.err
+    @SuppressWarnings("squid:S106")
+    private final PrintStream SYSERR;
+
+    @Option(names = {"-h", "--help"}, usageHelp = true, description = "display 
this help message")
+    boolean usageHelpRequested;
+    
+    @Option(names = {"-i", "--input"}, description = "the PDF file to 
decompress", required = true)
+    private File infile;
+
+    @Option(names = {"-o", "--output"}, description = "the decompressed PDF 
file. If omitted the original file is overwritten.")
+    private File outfile;
+    
+    /**
+     * Constructor.
+     */
+    public DecompressObjectstreams()
+    {
+        SYSERR = System.err;
+    }
+
+    /**
+     * This is the entry point for the application.
+     *
+     * @param args The command-line arguments.
+     */
+    public static void main(String[] args)
+    {
+        // suppress the Dock icon on OS X
+        System.setProperty("apple.awt.UIElement", "true");
+
+        int exitCode = new CommandLine(new 
DecompressObjectstreams()).execute(args);
+        System.exit(exitCode);
+    }
+
+    public Integer call()
+    {
+        try (PDDocument doc = Loader.loadPDF(infile))
+        {
+            // overwrite inputfile if no outputfile was specified
+            if (outfile == null) {
+                outfile = infile;
+            }
+
+            doc.save(outfile, CompressParameters.NO_COMPRESSION);
+        }
+        catch (IOException ioe)
+        {
+            SYSERR.println("Error processing file [" + 
ioe.getClass().getSimpleName() + "]: " + ioe.getMessage());
+            return 4;
+        }
+        return 0;
+    }
+}

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExportFDF.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExportFDF.java     
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExportFDF.java     
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -36,7 +36,7 @@ import picocli.CommandLine.Option;
  *
  * @author Ben Litchfield
  */
-@Command(name = "exportfdf", header = "Exports AcroForm form data to FDF", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "export:fdf", header = "Exports AcroForm form data to FDF", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
 public final class ExportFDF implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExportXFDF.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExportXFDF.java    
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExportXFDF.java    
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -37,7 +37,7 @@ import org.apache.pdfbox.pdmodel.fdf.FDF
  *
  * @author Ben Litchfield
  */
-@Command(name = "exportxfdf", header = "Exports AcroForm form data to XFDF", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "export:xfdf", header = "Exports AcroForm form data to XFDF", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
 public final class ExportXFDF implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java 
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java 
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -66,7 +66,7 @@ import picocli.CommandLine.Option;
  *
  * @author Ben Litchfield
  */
-@Command(name = "extractimages", header = "Extracts the images from a PDF 
document", versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "export:images", header = "Extracts the images from a PDF 
document", versionProvider = Version.class, mixinStandardHelpOptions = true)
 public final class ExtractImages implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java   
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java   
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -59,7 +59,7 @@ import picocli.CommandLine.Option;
  * @author Ben Litchfield
  * @author Tilman Hausherr
  */
-@Command(name = "extracttext", header = "Extracts the text from a PDF 
document", versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "export:text", header = "Extracts the text from a PDF 
document", versionProvider = Version.class, mixinStandardHelpOptions = true)
 public final class ExtractText  implements Callable<Integer>
 {
     private static final Logger LOG = LogManager.getLogger(ExtractText.class);

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractXMP.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractXMP.java    
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractXMP.java    
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -37,7 +37,7 @@ import picocli.CommandLine;
  *
  * @author Tilman Hausherr
  */
[email protected](name = "extractxmp", header = "Extracts the xmp stream 
from a PDF document", versionProvider = Version.class, mixinStandardHelpOptions 
= true)
[email protected](name = "extract:xmp", header = "Extracts the xmp stream 
from a PDF document", versionProvider = Version.class, mixinStandardHelpOptions 
= true)
 public class ExtractXMP implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImageToPDF.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImageToPDF.java    
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImageToPDF.java    
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -34,7 +34,7 @@ import picocli.CommandLine.Option;
 /**
  * Create a PDF document from images.
  */
-@Command(name = "imagetopdf", header = "Creates a PDF document from images", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "fromimage", header = "Creates a PDF document from images", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
 public final class ImageToPDF implements Callable<Integer>
 {
     private PDRectangle mediaBox = PDRectangle.LETTER;

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImportFDF.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImportFDF.java     
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImportFDF.java     
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -37,7 +37,7 @@ import picocli.CommandLine.Option;
  *
  * @author Ben Litchfield
  */
-@Command(name = "importfdf", header = "Imports AcroForm form data from FDF", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "import:fdf", header = "Imports AcroForm form data from FDF", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
 public class ImportFDF implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImportXFDF.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImportXFDF.java    
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ImportXFDF.java    
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -38,7 +38,7 @@ import java.util.concurrent.Callable;
  *
  * @author Ben Litchfield
  */
-@Command(name = "importxfdf", header = "Imports AcroForm form data from XFDF", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "import:xfdf", header = "Imports AcroForm form data from 
XFDF", versionProvider = Version.class, mixinStandardHelpOptions = true)
 public class ImportXFDF implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/OverlayPDF.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/OverlayPDF.java    
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/OverlayPDF.java    
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -38,7 +38,7 @@ import picocli.CommandLine.Option;
  * Based on code contributed by Balazs Jerk. 
  * 
  */
-@Command(name = "overlaypdf", header = "Adds an overlay to a PDF document", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "overlay", header = "Adds an overlay to a PDF document", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
 public final class OverlayPDF implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java        
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java        
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -56,6 +56,7 @@ public final class PDFBox implements Run
         commandLine.addSubcommand("decrypt", Decrypt.class);
         commandLine.addSubcommand("encrypt", Encrypt.class);
         commandLine.addSubcommand("decode", WriteDecodedDoc.class);
+        commandLine.addSubcommand("decompress", DecompressObjectstreams.class);
         commandLine.addSubcommand("export:images", ExtractImages.class);
         commandLine.addSubcommand("export:xmp", ExtractXMP.class);
         commandLine.addSubcommand("export:text", ExtractText.class);

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java      
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java      
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -38,7 +38,7 @@ import picocli.CommandLine.Option;
  *
  * @author Ben Litchfield
  */
-@Command(name = "pdfsplit", header = "Splits a PDF document into number of new 
documents", versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "split", header = "Splits a PDF document into number of new 
documents", versionProvider = Version.class, mixinStandardHelpOptions = true)
 public final class PDFSplit implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java    
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java    
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -46,7 +46,7 @@ import picocli.CommandLine.Option;
  *
  * @author Ben Litchfield
  */
-@Command(name = "pdftoimage", header = "Converts a PDF document to image(s)", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "render", header = "Converts a PDF document to image(s)", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
 public final class PDFToImage implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java     
Sat Sep 19 08:30:40 2026        (r1938363)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java     
Sat Sep 19 10:47:52 2026        (r1938364)
@@ -47,7 +47,7 @@ import picocli.CommandLine.Option;
  *
  * @author Ben Litchfield
  */
-@Command(name = "texttopdf", header = "Creates a PDF document from text", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
+@Command(name = "fromtext", header = "Creates a PDF document from text", 
versionProvider = Version.class, mixinStandardHelpOptions = true)
 public class TextToPDF implements Callable<Integer>
 {
     /**

Modified: 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java
==============================================================================
--- 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java   
    Sat Sep 19 08:30:40 2026        (r1938363)
+++ 
pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java   
    Sat Sep 19 10:47:52 2026        (r1938364)
@@ -42,7 +42,7 @@ import picocli.CommandLine.Parameters;
  *
  * @author Michael Traut
  */
-@Command(name = "writedecodeddoc", header = "Writes a PDF document with all 
streams decoded", versionProvider = Version.class, mixinStandardHelpOptions = 
true)
+@Command(name = "decode", header = "Writes a PDF document with all streams 
decoded", versionProvider = Version.class, mixinStandardHelpOptions = true)
 public class WriteDecodedDoc implements Callable<Integer>
 {
     // Expected for CLI app to write to System.out/System.err

Reply via email to