class PdfInformationPanel extends JPanel implements PropertyChangeListener {

    /**
     * A serial version id
     */
    private static final long serialVersionUID = -4171577284617028707L;

    /**
     * The file name of the PDF we're going to label.
     */
    String filename = "";

    /**
     * the label containing the metadata
     */
    JLabel label = new JLabel();

    /**
     * the scrollpane to scroll through the label
     */
    JScrollPane scrollpane = new JScrollPane();

    /**
     * the panel to witch the scrollpane will be added.
     */
    JPanel panel = new JPanel();

    /**
     * Construct the information label (actually it's a JPanel).
     */
    public PdfInformationPanel() {
        try {
            this.setLayout(new BorderLayout());
            label.setHorizontalAlignment(SwingConstants.CENTER);
            panel.setLayout(new BorderLayout());
            this.add(panel, BorderLayout.CENTER);
            scrollpane.setPreferredSize(new Dimension(200, 200));
            panel.add(scrollpane, BorderLayout.CENTER);
            scrollpane.setViewportView(label);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Reads a PDF file for retrieving its metadata.
     *
     * @param file File
     */
    public void createTextFromPDF(File file) {
        if (file.exists()) {
            int page = 1;
            PdfReader reader = null;

            try (RandomAccessFileOrArray raf = new RandomAccessFileOrArray(file.getAbsolutePath())) {
                reader = new PdfReader(raf, null);
                Map<String, String> pdfinfo = reader.getInfo();

                StringBuilder sb = new StringBuilder();
                sb.append("<html>=== Document Information ===<p>");
                sb.append(reader.getCropBox(page).getHeight()).append("*").append(reader.getCropBox(page).getWidth())
                        .append("<p>");
                sb.append("PDF Version: ").append(reader.getPdfVersion()).append("<p>");
                sb.append("Number of pages: ").append(reader.getNumberOfPages()).append("<p>");
                sb.append("Number of PDF objects: ").append(reader.getXrefSize()).append("<p>");
                sb.append("File length: ").append(reader.getFileLength()).append("<p>");
                sb.append("Encrypted= ").append(reader.isEncrypted()).append("<p>");
                if (pdfinfo.get("Title") != null) {
                    sb.append("Title= ").append(pdfinfo.get("Title")).append("<p>");
                }
                if (pdfinfo.get("Author") != null) {
                    sb.append("Author= ").append(pdfinfo.get("Author")).append("<p>");
                }
                if (pdfinfo.get("Subject") != null) {
                    sb.append("Subject= ").append(pdfinfo.get("Subject")).append("<p>");
                }
                if (pdfinfo.get("Producer") != null) {
                    sb.append("Producer= ").append(pdfinfo.get("Producer")).append("<p>");
                }
                if (pdfinfo.get("ModDate") != null) {
                    sb.append("ModDate= ").append(PdfDate.decode(pdfinfo.get("ModDate"))
                            .getTime()).append("<p>");
                }
                if (pdfinfo.get("CreationDate") != null) {
                    sb.append("CreationDate= ").append(PdfDate.decode(
                                    pdfinfo.get("CreationDate"))
                            .getTime()).append("<p>");
                }
                sb.append("</html>");
                label.setText(sb.toString());
            } catch (IOException ex) {
                label.setText("");
            }
        }
    }

    /**
     * @param evt PropertyChangeEvent
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
    public void propertyChange(PropertyChangeEvent evt) {<FILL_FUNCTION_BODY>}
}

        filename = evt.getPropertyName();
        if (filename.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
            File file = (File) evt.getNewValue();
            if (file != null) {
                this.createTextFromPDF(file);
                this.repaint();
            }
        }
    
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID