Example usage for com.itextpdf.text.pdf PdfWriter PDF_VERSION_1_7

List of usage examples for com.itextpdf.text.pdf PdfWriter PDF_VERSION_1_7

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfWriter PDF_VERSION_1_7.

Prototype

PdfName PDF_VERSION_1_7

To view the source code for com.itextpdf.text.pdf PdfWriter PDF_VERSION_1_7.

Click Source Link

Document

possible PDF version (catalog)

Usage

From source file:model.CCSignatureSettings.java

License:Open Source License

private void createConfigFile() {
    InitialConfigDialog icd = new InitialConfigDialog(null, true);
    icd.setLocationRelativeTo(null);//from   w  w  w .j  a v a2s  . c o m
    icd.setVisible(true);
    Locale locale = icd.getSelectedLocale();
    String fsettings = "aCCinaPDF.cfg";
    Properties propertiesWrite = new Properties();
    FileOutputStream fileOut;
    try {
        if (locale.equals(Bundle.getBundle().getLocale(Bundle.Locales.Portugues))) {
            propertiesWrite.setProperty("language", "pt-PT");
            Bundle.getBundle().setCurrentLocale(Bundle.Locales.Portugues);
        } else if (locale.equals(Bundle.getBundle().getLocale(Bundle.Locales.English))) {
            propertiesWrite.setProperty("language", "en-US");
            Bundle.getBundle().setCurrentLocale(Bundle.Locales.English);
        } else {
            propertiesWrite.setProperty("language", "en-US");
            Bundle.getBundle().setCurrentLocale(Bundle.Locales.English);
        }
        propertiesWrite.setProperty("renderQuality", String.valueOf(2));
        propertiesWrite.setProperty("pdfversion", "/1.7");
        propertiesWrite.setProperty("prefix", "aCCinatura");
        propertiesWrite.setProperty("fontLocation", "extrafonts" + File.separator + "verdana.ttf");
        propertiesWrite.setProperty("fontItalic", "true");
        propertiesWrite.setProperty("fontBold", "false");
        propertiesWrite.setProperty("textAlign", "0");
        propertiesWrite.setProperty("showName", "true");
        propertiesWrite.setProperty("showReason", "true");
        propertiesWrite.setProperty("showLocation", "true");
        propertiesWrite.setProperty("showDate", "true");
        propertiesWrite.setProperty("fontColor", "0");
        propertiesWrite.setProperty("signatureWidth", "403");
        propertiesWrite.setProperty("signatureHeight", "34");
        propertiesWrite.setProperty("pdfversion", String.valueOf(PdfWriter.PDF_VERSION_1_7));
        fileOut = new FileOutputStream(fsettings);
        propertiesWrite.store(fileOut, "Settings");
        fileOut.close();
        loadDefaults();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(AppearanceSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(AppearanceSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:view.SettingsDialog.java

License:Open Source License

private void loadSettings() {
    DefaultComboBoxModel dcbm = new DefaultComboBoxModel();
    dcbm.addElement(PdfWriter.PDF_VERSION_1_2);
    dcbm.addElement(PdfWriter.PDF_VERSION_1_3);
    dcbm.addElement(PdfWriter.PDF_VERSION_1_4);
    dcbm.addElement(PdfWriter.PDF_VERSION_1_5);
    dcbm.addElement(PdfWriter.PDF_VERSION_1_6);
    dcbm.addElement(PdfWriter.PDF_VERSION_1_7);
    jComboBox1.setModel(dcbm);/* ww  w.  ja  v  a  2  s .  co m*/

    String language = null;
    String renderQuality = null;
    String pdfVersion = null;
    String prefix = null;
    String signatureWidthString = null;
    String signatureHeightString = null;
    try {
        language = getConfigParameter("language");
        renderQuality = getConfigParameter("renderQuality");
        pdfVersion = getConfigParameter("pdfversion");
        prefix = getConfigParameter("prefix");
        signatureWidthString = getConfigParameter("signatureWidth");
        signatureHeightString = getConfigParameter("signatureHeight");
    } catch (IOException ex) {
        loadSettings();
        return;
    }

    if (pdfVersion == null || prefix == null || signatureWidthString == null || signatureHeightString == null) {
        loadSettings();
        return;
    }

    switch (language) {
    case "en-US":
        Bundle.getBundle().setCurrentLocale(Bundle.Locales.English);
        break;
    case "pt-PT":
        Bundle.getBundle().setCurrentLocale(Bundle.Locales.Portugues);
        break;
    default:
        Bundle.getBundle().setCurrentLocale(Bundle.Locales.English);
    }

    switch (Integer.valueOf(renderQuality)) {
    case 3:
        jComboBox2.setSelectedIndex(0);
        break;
    case 2:
        jComboBox2.setSelectedIndex(1);
        break;
    case 1:
        jComboBox2.setSelectedIndex(2);
        break;
    default:
        jComboBox2.setSelectedIndex(1);
    }

    switch (pdfVersion) {
    case "/1.2":
        jComboBox1.setSelectedIndex(0);
        break;
    case "/1.3":
        jComboBox1.setSelectedIndex(1);
        break;
    case "/1.4":
        jComboBox1.setSelectedIndex(2);
        break;
    case "/1.5":
        jComboBox1.setSelectedIndex(3);
        break;
    case "/1.6":
        jComboBox1.setSelectedIndex(4);
        break;
    case "/1.7":
        jComboBox1.setSelectedIndex(5);
        break;
    default:
        jComboBox1.setSelectedIndex(5);
    }
    int signatureWidth = Integer.parseInt(signatureWidthString);
    int signatureHeight = Integer.parseInt(signatureHeightString);
    tfPrefix.setText(prefix);
    tfHeight.setText(String.valueOf(signatureHeight));
    tfWidth.setText(String.valueOf(signatureWidth));
}