Example usage for com.lowagie.text.pdf.codec Base64 encodeObject

List of usage examples for com.lowagie.text.pdf.codec Base64 encodeObject

Introduction

In this page you can find the example usage for com.lowagie.text.pdf.codec Base64 encodeObject.

Prototype

public static String encodeObject(java.io.Serializable serializableObject) 

Source Link

Document

Serializes an object and returns the Base64-encoded version of that serialized object.

Usage

From source file:org.pdfsam.plugin.vcomposer.GUI.VComposerMainGUI.java

License:Open Source License

public Node getJobNode(Node arg0, boolean savePasswords) throws SaveJobException {
    try {//from w w w .  j  av  a  2 s  .c o  m
        if (arg0 != null) {
            Element inputDocuments = ((Element) arg0).addElement("input-documents");
            PdfFile[] openFiles = inputPanel.getInputDocuments();
            if (openFiles != null && openFiles.length > 0) {
                for (PdfFile openFile : openFiles) {
                    if (openFile != null && openFile.getInputFile() != null) {
                        Element fileSource = ((Element) inputDocuments).addElement("source");
                        fileSource.addAttribute("value", openFile.getInputFile().getAbsolutePath());
                        if (savePasswords) {
                            fileSource.addAttribute("password",
                                    (openFile.getPassword() != null ? openFile.getPassword() : ""));
                        }
                    }
                }
            }

            Element outputDocument = ((Element) arg0).addElement("output-document");
            VisualPageListItem[] pages = ((VisualListModel) composerPanel.getThumbnailList().getModel())
                    .getElements();
            if (pages != null && pages.length > 0) {

                for (VisualPageListItem page : pages) {
                    Element outputFile = ((Element) outputDocument).addElement("page");
                    outputFile.setText(Base64.encodeObject(page));
                }
            }

            Element fileDestination = ((Element) arg0).addElement("destination");
            fileDestination.addAttribute("value", destinationFileText.getText());

            Element fileOverwrite = ((Element) arg0).addElement("overwrite");
            fileOverwrite.addAttribute("value", overwriteCheckbox.isSelected() ? TRUE : FALSE);

            Element fileCompress = ((Element) arg0).addElement("compressed");
            fileCompress.addAttribute("value", outputCompressedCheck.isSelected() ? TRUE : FALSE);

            Element pdfVersion = ((Element) arg0).addElement("pdfversion");
            pdfVersion.addAttribute("value", ((StringItem) versionCombo.getSelectedItem()).getId());
        }
        return arg0;
    } catch (Exception ex) {
        throw new SaveJobException(ex);
    }
}