Top Description Inners Fields Constructors Methods
org.apache.pdfbox.debugger

public Class PDFDebugger

extends JFrame
implements Callable<Integer>, HyperlinkListener
Class Inheritance
All Implemented Interfaces
javax.swing.event.HyperlinkListener, java.util.EventListener, java.util.concurrent.Callable
Annotations
@SuppressWarnings:serial, squid:MaximumInheritanceDepth, squid:S1948
@Command
name:pdfdebugger
description:Analyzes and inspects the internal structure of a PDF document
Imports
java.awt.BorderLayout, .Color, .Component, .Cursor, .Dimension, .FileDialog, .Frame, .Rectangle, .Toolkit, java.awt.datatransfer.DataFlavor, .Transferable, .UnsupportedFlavorException, java.awt.event.ActionEvent, .InputEvent, .KeyEvent, .WindowEvent, java.awt.print.PrinterException, .PrinterJob, java.io.ByteArrayOutputStream, .File, .FileInputStream, .IOException, .InputStream, .PrintStream, java.lang.reflect.Method, java.net.URI, .URISyntaxException, .URL, java.nio.charset.StandardCharsets, java.util.Arrays, .HashSet, .List, .Properties, .Set, java.util.concurrent.Callable, .TimeUnit, javax.imageio.spi.IIORegistry, javax.print.attribute.HashPrintRequestAttributeSet, .PrintRequestAttributeSet, javax.print.attribute.standard.Sides, javax.swing.AbstractAction, .Action, .Box, .JComponent, .JDialog, .JEditorPane, .JFrame, .JLabel, .JMenu, .JMenuBar, .JMenuItem, .JOptionPane, .JPanel, .JPasswordField, .JScrollPane, .KeyStroke, .TransferHandler, .UIManager, javax.swing.border.BevelBorder, javax.swing.event.HyperlinkEvent, .HyperlinkListener, .TreeSelectionEvent, javax.swing.filechooser.FileFilter, .FileNameExtensionFilter, javax.swing.tree.TreePath, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.Loader, org.apache.pdfbox.cos.COSArray, .COSBase, .COSBoolean, .COSDictionary, .COSFloat, .COSInteger, .COSName, .COSNull, .COSObject, .COSStream, .COSString, org.apache.pdfbox.debugger.colorpane.CSArrayBased, .CSDeviceN, .CSIndexed, .CSSeparation, org.apache.pdfbox.debugger.flagbitspane.FlagBitsPane, org.apache.pdfbox.debugger.fontencodingpane.FontEncodingPaneController, org.apache.pdfbox.debugger.pagepane.PagePane, org.apache.pdfbox.debugger.signaturepane.SignaturePane, org.apache.pdfbox.debugger.streampane.StreamPane, org.apache.pdfbox.debugger.stringpane.StringPane, org.apache.pdfbox.debugger.treestatus.TreeStatus, .TreeStatusPane, org.apache.pdfbox.debugger.ui.ArrayEntry, .DocumentEntry, .ErrorDialog, .FileOpenSaveDialog, .ImageTypeMenu, .LogDialog, .MapEntry, .OSXAdapter, .PDFTreeCellRenderer, .PDFTreeModel, .PageEntry, .PrintDpiMenu, .ReaderBottomPanel, .RecentFiles, .RenderDestinationMenu, .RotationMenu, .TextDialog, .Tree, .TreeViewMenu, .ViewMenu, .WindowPrefs, .XrefEntries, .XrefEntry, .ZoomMenu, org.apache.pdfbox.filter.FilterFactory, org.apache.pdfbox.io.IOUtils, .RandomAccessReadBuffer, org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.common.PDPageLabels, org.apache.pdfbox.pdmodel.encryption.AccessPermission, .InvalidPasswordException, org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK, .PDDeviceRGB, org.apache.pdfbox.pdmodel.interactive.viewerpreferences.PDViewerPreferences, org.apache.pdfbox.printing.Orientation, .PDFPageable, picocli.CommandLine, .CommandLine.Command, .CommandLine.Option, .CommandLine.Parameters, .CommandLine.Spec, .CommandLine.Model.CommandSpec

PDF Debugger.
Authors
wurtz, Ben Litchfield, Khyrul Bashar

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract static class
PDFDebugger.DocumentOpener

Internal class to avoid double code in password entry loop.

Field Summary

Modifier and TypeField and Description
public static final Properties
private String
private String
private PDDocument
private final JPanel
private JMenu
private JMenuItem
private JMenuItem
private JMenuItem
private File
private static final boolean
private JScrollPane
private JSplitPane
private JTextPane
private static Log
private static final String
private static final Set<COSName>
private String
private static final FileFilter
private JMenuItem
private RecentFiles
private JMenu
private JMenuItem
private JMenuItem
private int
pack-priv CommandLine.Model.CommandSpec
private static final Set<COSName>
private ReaderBottomPanel
private TreeStatusPane
private final PrintStream
private Tree
pack-priv boolean
private boolean
private WindowPrefs
Inherited from javax.swing.JFrame:
accessibleContextrootPanerootPaneCheckingEnabled

Constructor Summary

AccessConstructor and Description
public
PDFDebugger()

Constructor.

public
PDFDebugger(String
initial view mode for the tree view on the left hand side.
initialViewMode
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private void
public Integer
call()

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

private String
convertToString(Object selectedNode)

private JMenu
private JMenu
private JMenu
private void
public JMenu

Returns:

the File menu
getFindMenu
()

Returns the File menu.

public JMenuItem

Returns:

the Find menu
getFindMenuItem
()

Returns the Edit > Find > Find menu item.

public JMenuItem

Returns:

the FindNext menu
getFindNextMenuItem
()

Returns the Edit > Find > Find Next menu item.

public JMenuItem

Returns:

the FindPrevious menu
getFindPreviousMenuItem
()

Returns the Edit > Find > Find Previous menu item.

private COSName
getNodeKey(Object selectedNode)

public static String

Returns:

a page label or null if not available.
getPageLabel
(PDDocument
the current document
document
,
int
0-based page number.
pageIndex
)

Convenience method to get the page label if available.

public String
getTreeViewMode()

Provide the current view mode of the tree view.

private COSBase
public boolean
public void
hyperlinkUpdate(HyperlinkEvent
the event responsible for the update
he
)

Implements javax.swing.event.HyperlinkListener.hyperlinkUpdate.

Called when a hypertext link is updated.

private void
initComponents()

This method is called from within the constructor to initialize the form.

protected void
initGlobalEventHandlers()

Initialize application global event handlers.

public void
private boolean
private boolean
private boolean
private boolean
isFlagNode(Object selectedNode, Object parentNode)

private boolean
isFont(Object selectedNode)

private boolean
private boolean
isOtherColorSpace(Object selectedNode)

private boolean
isPage(Object selectedNode)

private boolean
isSignature(Object selectedNode, Object parentNode)

private boolean
private boolean
isStream(Object selectedNode)

private boolean
isString(Object selectedNode)

private void
private void
loadConfiguration()

Loads the local configuration file, if any.

public static void
main(String[]
the command line arguments
args
)

Entry point.

private void
private void
osxOpenFiles(String filename)

This method is called via reflection on Mac OS X.

private void
osxQuit()

This method is called via reflection on Mac OS X.

protected void
performApplicationExit()

Exit the application after the window is closed.

private void
private void
readPDFFile(String filePath, String password)

private void
readPDFFile(final File file, String password)

private void
readPDFurl(final String urlString, String password)

private void
private void
public void
setTreeViewMode(String
the view mode to be set
viewMode
)

Set the current view mode of the tree view.

private void
showColorPane(Object
the special color space containing node.
csNode
)

Show a Panel describing color spaces in more detail and interactive way.

private void
showFlagPane(Object parentNode, Object selectedNode)

private void
showFont(Object selectedNode, TreePath path)

private void
showPage(Object selectedNode)

private void
showSignaturePane(Object selectedNode)

private void
private void
showString(Object selectedNode)

private void
textDialog(String title, URL resource)

Inherited from javax.swing.JFrame:
addImplcreateRootPaneframeInitgetAccessibleContextgetContentPanegetDefaultCloseOperationgetGlassPanegetGraphicsgetJMenuBargetLayeredPanegetRootPanegetTransferHandlerisDefaultLookAndFeelDecoratedisRootPaneCheckingEnabledparamStringprocessWindowEventremoverepaintsetContentPanesetDefaultCloseOperationsetDefaultLookAndFeelDecoratedsetGlassPanesetIconImagesetJMenuBarsetLayeredPanesetLayoutsetRootPanesetRootPaneCheckingEnabledsetTransferHandlerupdate

Field Detail

configurationback to summary
public static final Properties configuration
currentFilePathback to summary
private String currentFilePath
currentTreeViewModeback to summary
private String currentTreeViewMode
documentback to summary
private PDDocument document
documentPanelback to summary
private final JPanel documentPanel
findMenuback to summary
private JMenu findMenu
findMenuItemback to summary
private JMenuItem findMenuItem
findNextMenuItemback to summary
private JMenuItem findNextMenuItem
findPreviousMenuItemback to summary
private JMenuItem findPreviousMenuItem
infileback to summary
private File infile
Annotations
@Parameters
paramLabel:inputfile
arity:0..1
description:the PDF file to be loaded
IS_MAC_OSback to summary
private static final boolean IS_MAC_OS
jScrollPaneRightback to summary
private JScrollPane jScrollPaneRight
jSplitPaneback to summary
private JSplitPane jSplitPane
jTextPaneback to summary
private JTextPane jTextPane
LOGback to summary
private static Log LOG
OS_NAMEback to summary
private static final String OS_NAME
OTHERCOLORSPACESback to summary
private static final Set<COSName> OTHERCOLORSPACES
passwordback to summary
private String password
Annotations
@Option
names:-password
description:password to decrypt the document
arity:0..1
interactive:true
PDF_FILTERback to summary
private static final FileFilter PDF_FILTER
printMenuItemback to summary
private JMenuItem printMenuItem
recentFilesback to summary
private RecentFiles recentFiles
recentFilesMenuback to summary
private JMenu recentFilesMenu
reopenMenuItemback to summary
private JMenuItem reopenMenuItem
saveAsMenuItemback to summary
private JMenuItem saveAsMenuItem
shortcutKeyMaskback to summary
private int shortcutKeyMask
specback to summary
pack-priv CommandLine.Model.CommandSpec spec
Annotations
@Spec
SPECIALCOLORSPACESback to summary
private static final Set<COSName> SPECIALCOLORSPACES
statusBarback to summary
private ReaderBottomPanel statusBar
statusPaneback to summary
private TreeStatusPane statusPane
SYSERRback to summary
private final PrintStream SYSERR
Annotations
@SuppressWarnings:squid:S106
treeback to summary
private Tree tree
usageHelpRequestedback to summary
pack-priv boolean usageHelpRequested
Annotations
@Option
names:-h, --help
usageHelp:true
description:display this help message
viewstructureback to summary
private boolean viewstructure
Annotations
@Option
names:-viewstructure
description:activate structure mode on startup
windowPrefsback to summary
private WindowPrefs windowPrefs

Constructor Detail

PDFDebuggerback to summary
public PDFDebugger()

Constructor.

PDFDebuggerback to summary
public PDFDebugger(String initialViewMode)

Constructor.

Parameters
initialViewMode:String

initial view mode for the tree view on the left hand side.

Method Detail

addRecentFileItemsback to summary
private void addRecentFileItems()
callback to summary
public Integer call()

Implements java.util.concurrent.Callable.call.

Doc from java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

Returns:Integer

computed result

Annotations
@Override
convertToStringback to summary
private String convertToString(Object selectedNode)
createEditMenuback to summary
private JMenu createEditMenu()
createFileMenuback to summary
private JMenu createFileMenu()
createFindMenuback to summary
private JMenu createFindMenu()
exitMenuItemActionPerformedback to summary
private void exitMenuItemActionPerformed(ActionEvent ignored)
getFindMenuback to summary
public JMenu getFindMenu()

Returns the File menu.

Returns:JMenu

the File menu

getFindMenuItemback to summary
public JMenuItem getFindMenuItem()

Returns the Edit > Find > Find menu item.

Returns:JMenuItem

the Find menu

getFindNextMenuItemback to summary
public JMenuItem getFindNextMenuItem()

Returns the Edit > Find > Find Next menu item.

Returns:JMenuItem

the FindNext menu

getFindPreviousMenuItemback to summary
public JMenuItem getFindPreviousMenuItem()

Returns the Edit > Find > Find Previous menu item.

Returns:JMenuItem

the FindPrevious menu

getNodeKeyback to summary
private COSName getNodeKey(Object selectedNode)
getPageLabelback to summary
public static String getPageLabel(PDDocument document, int pageIndex)

Convenience method to get the page label if available.

Parameters
document:PDDocument

the current document

pageIndex:int

0-based page number.

Returns:String

a page label or null if not available.

getTreeViewModeback to summary
public String getTreeViewMode()

Provide the current view mode of the tree view. see TreeViewMenu for valid values

getUnderneathObjectback to summary
private COSBase getUnderneathObject(Object selectedNode)
hasDocumentback to summary
public boolean hasDocument()
hyperlinkUpdateback to summary
public void hyperlinkUpdate(HyperlinkEvent he)

Implements javax.swing.event.HyperlinkListener.hyperlinkUpdate.

Doc from javax.swing.event.HyperlinkListener.hyperlinkUpdate.

Called when a hypertext link is updated.

Parameters
he:HyperlinkEvent

the event responsible for the update

Annotations
@Override
initComponentsback to summary
private void initComponents()

This method is called from within the constructor to initialize the form.

initGlobalEventHandlersback to summary
protected void initGlobalEventHandlers()

Initialize application global event handlers. Protected to allow subclasses to override this method if they don't want the global event handler overridden.

Annotations
@SuppressWarnings:WeakerAccess
initTreeback to summary
public void initTree()
isAnnotback to summary
private boolean isAnnot(Object obj)
isCIDFontback to summary
private boolean isCIDFont(COSDictionary dic)
isEncryptback to summary
private boolean isEncrypt(Object obj)
isFlagNodeback to summary
private boolean isFlagNode(Object selectedNode, Object parentNode)
isFontback to summary
private boolean isFont(Object selectedNode)
isFontDescriptorback to summary
private boolean isFontDescriptor(Object obj)
isOtherColorSpaceback to summary
private boolean isOtherColorSpace(Object selectedNode)
isPageback to summary
private boolean isPage(Object selectedNode)
isSignatureback to summary
private boolean isSignature(Object selectedNode, Object parentNode)
isSpecialColorSpaceback to summary
private boolean isSpecialColorSpace(Object selectedNode)
isStreamback to summary
private boolean isStream(Object selectedNode)
isStringback to summary
private boolean isString(Object selectedNode)
jTree1ValueChangedback to summary
private void jTree1ValueChanged(TreeSelectionEvent evt)
loadConfigurationback to summary
private void loadConfiguration()

Loads the local configuration file, if any.

mainback to summary
public static void main(String[] args)

Entry point.

Parameters
args:String[]

the command line arguments

openMenuItemActionPerformedback to summary
private void openMenuItemActionPerformed(ActionEvent evt)
osxOpenFilesback to summary
private void osxOpenFiles(String filename)

This method is called via reflection on Mac OS X.

osxQuitback to summary
private void osxQuit()

This method is called via reflection on Mac OS X.

performApplicationExitback to summary
protected void performApplicationExit()

Exit the application after the window is closed. This is protected to let subclasses override the behavior.

Annotations
@SuppressWarnings:WeakerAccess
printMenuItemActionPerformedback to summary
private void printMenuItemActionPerformed(ActionEvent evt)
readPDFFileback to summary
private void readPDFFile(String filePath, String password) throws IOException, URISyntaxException
readPDFFileback to summary
private void readPDFFile(final File file, String password) throws IOException, URISyntaxException
readPDFurlback to summary
private void readPDFurl(final String urlString, String password) throws IOException, URISyntaxException
replaceRightComponentback to summary
private void replaceRightComponent(Component pane)
saveAsMenuItemActionPerformedback to summary
private void saveAsMenuItemActionPerformed(ActionEvent evt)
setTreeViewModeback to summary
public void setTreeViewMode(String viewMode)

Set the current view mode of the tree view. see TreeViewMenu for valid values

Parameters
viewMode:String

the view mode to be set

showColorPaneback to summary
private void showColorPane(Object csNode) throws IOException

Show a Panel describing color spaces in more detail and interactive way.

Parameters
csNode:Object

the special color space containing node.

showFlagPaneback to summary
private void showFlagPane(Object parentNode, Object selectedNode)
showFontback to summary
private void showFont(Object selectedNode, TreePath path)
showPageback to summary
private void showPage(Object selectedNode)
showSignaturePaneback to summary
private void showSignaturePane(Object selectedNode)
showStreamback to summary
private void showStream(COSStream stream, TreePath path) throws IOException
showStringback to summary
private void showString(Object selectedNode)
textDialogback to summary
private void textDialog(String title, URL resource)
org.apache.pdfbox.debugger back to summary

pack-priv abstract Class PDFDebugger.DocumentOpener

extends Object
Class Inheritance

Internal class to avoid double code in password entry loop.

Field Summary

Modifier and TypeField and Description
pack-priv String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract PDDocument

Returns:

the PDDocument instance
open
()

Override to load the actual input type (File, URL, stream), don't call it directly!

pack-priv final PDDocument

Returns:

the PDDocument instance
parse
()

Call this!

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

passwordback to summary
pack-priv String password

Constructor Detail

DocumentOpenerback to summary
pack-priv DocumentOpener(String password)

Method Detail

openback to summary
pack-priv abstract PDDocument open() throws IOException, URISyntaxException

Override to load the actual input type (File, URL, stream), don't call it directly!

Returns:PDDocument

the PDDocument instance

Exceptions
IOException:
Cannot read document
parseback to summary
pack-priv final PDDocument parse() throws IOException, URISyntaxException

Call this!

Returns:PDDocument

the PDDocument instance

Exceptions
IOException:
Cannot read document