Java 类net.sf.jasperreports.engine.export.JRPdfExporterParameter 实例源码

项目:spring4-understanding    文件:JasperReportsUtilsTests.java   
@Test
public void renderAsPdfWithExporterParameters() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Map<JRExporterParameter, Object> exporterParameters = new HashMap<JRExporterParameter, Object>();
    exporterParameters.put(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_6.toString());
    JasperReportsUtils.renderAsPdf(getReport(), getParameters(), getData(), os, exporterParameters);
    byte[] output = os.toByteArray();
    assertPdfOutputCorrect(output);
    assertTrue(new String(output).contains("PDF-1.6"));
}
项目:class-guard    文件:JasperReportsUtilsTests.java   
public void testRenderAsPdfWithExporterParameters() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Map<JRExporterParameter, Object> exporterParameters = new HashMap<JRExporterParameter, Object>();
    exporterParameters.put(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_6);
    JasperReportsUtils.renderAsPdf(getReport(), getParameters(), getData(), os, exporterParameters);
    byte[] output = os.toByteArray();
    assertPdfOutputCorrect(output);
    assertTrue(new String(output).contains("PDF-1.6"));
}
项目:nextreports-server    文件:JasperReportsUtil.java   
@SuppressWarnings("deprecation")
private static byte[] getBytes(JRAbstractExporter exporter, ByteArrayOutputStream baos,
                                  JasperPrint jasperPrint) throws JRException {

       printNextReportsParameters();

       // for csv delimiter
       //exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ";");
       exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
       exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);

       if (exporter instanceof JRPdfExporter) {
           exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, encoding);

           // create embedded pdf font (like in nextreports)
           if (embeddedFont != null) {
               HashMap<FontKey, PdfFont> fontMap = new HashMap<FontKey, PdfFont>();
               FontKey key = new FontKey("Arial", false, false);
               PdfFont font = new PdfFont(embeddedFont, BaseFont.IDENTITY_H, true);
               fontMap.put(key, font);
               exporter.setParameter(JRPdfExporterParameter.FONT_MAP, fontMap);
           }
       } else {
           exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
       }

       exporter.exportReport();
       return baos.toByteArray();
   }
项目:omr    文件:JasperTeste.java   
public static void createPDF() throws FileNotFoundException, JRException, IOException {
    // TODO Auto-generated method stub

    InputStream jrxmlStream = new FileInputStream("/home/darcio/workspace/modules/JazzAV/bsn/src/main/resources/modeloAdes1.jrxml");

    JasperReport compiled = JasperCompileManager.compileReport(jrxmlStream);


    Map rootMap = new HashMap();
    JasperPrint jasperPrint = JasperFillManager.fillReport(compiled, rootMap, new JREmptyDataSource());

    int pageIndex = 0;

    JRPdfExporter exporter = new JRPdfExporter();


    exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint);

    exporter.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("/home/darcio/workspace/modules/JazzAV/bsn/src/main/resources/modeloAdes1.pdf"));



    exporter.exportReport();


}
项目:omr    文件:JasperTeste3.java   
public static void createPDF() throws FileNotFoundException, JRException, IOException {
    // TODO Auto-generated method stub

    InputStream jrxmlStream = new FileInputStream("/home/darcio/workspace/modules/JazzAV/bsn/src/main/resources/modeloAdes1.jrxml");

    JasperReport compiled = JasperCompileManager.compileReport(jrxmlStream);


    Map rootMap = new HashMap();
    JasperPrint jasperPrint = JasperFillManager.fillReport(compiled, rootMap, new JREmptyDataSource());

    int pageIndex = 0;

    JRPdfExporter exporter = new JRPdfExporter();


    exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint);

    exporter.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("/home/darcio/workspace/modules/JazzAV/bsn/src/main/resources/modeloAdes1.pdf"));



    exporter.exportReport();


}
项目:omr    文件:JasperTeste2.java   
public static void createPDF() throws FileNotFoundException, JRException, IOException {
    // TODO Auto-generated method stub

    InputStream jrxmlStream = new FileInputStream("/home/darcio/workspace/modules/JazzAV/bsn/src/main/resources/modeloAdes1.jrxml");

    JasperReport compiled = JasperCompileManager.compileReport(jrxmlStream);


    Map rootMap = new HashMap();
    JasperPrint jasperPrint = JasperFillManager.fillReport(compiled, rootMap, new JREmptyDataSource());

    int pageIndex = 0;

    JRPdfExporter exporter = new JRPdfExporter();


    exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint);

    exporter.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("/home/darcio/workspace/modules/JazzAV/bsn/src/main/resources/modeloAdes1.pdf"));



    exporter.exportReport();


}
项目:ireport-fork    文件:PdfExportParametersPanel.java   
public void load() {
    setInit(true);
    Preferences pref = IReportManager.getPreferences();


    JRPropertiesUtil jrPropUtils = IRLocalJasperReportsContext.getUtilities();

    Misc.setComboboxSelectedTagValue(jComboBoxPDFVersion, pref.get(JRPdfExporterParameter.PROPERTY_PDF_VERSION, jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDF_VERSION)));
    Misc.setComboboxSelectedTagValue(jComboBoxPdfA, pref.get(JRPdfExporterParameter.PROPERTY_PDFA_CONFORMANCE, jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDFA_CONFORMANCE)));

    jTextFieldICC.setText(pref.get(JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH, Misc.nvl(jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH),"")));

    jCheckBoxCreatingBatchModeBookmarks.setSelected( pref.getBoolean(JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS)));
    jCheckBoxCompressed.setSelected( pref.getBoolean(JRPdfExporterParameter.PROPERTY_COMPRESSED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_COMPRESSED)));
    jCheckBoxForceLinebreakPolicy.setSelected( pref.getBoolean(JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY)));
    jCheckBoxForceSVGShapes.setSelected( pref.getBoolean(JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES)));
    jCheckBoxIsTagged.setSelected( pref.getBoolean(JRPdfExporterParameter.PROPERTY_TAGGED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_TAGGED)));

    jComboBoxEncryption.setSelectedIndex(0);
    if (pref.getBoolean(JRPdfExporterParameter.PROPERTY_ENCRYPTED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_ENCRYPTED)))
    {
        jComboBoxEncryption.setSelectedIndex(1);
    }
    if (pref.getBoolean(JRPdfExporterParameter.PROPERTY_128_BIT_KEY, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_128_BIT_KEY)))
    {
        jComboBoxEncryption.setSelectedIndex(2);
    }
    jTextFieldMetadataAuthor.setText(pref.get("export.pdf.METADATA_AUTHOR", ""));
    jTextFieldMetadataCreator.setText(pref.get("export.pdf.METADATA_CREATOR", ""));
    jTextFieldMetadataKeywords.setText(pref.get("export.pdf.METADATA_KEYWORDS", ""));
    jTextFieldMetadataSubject.setText(pref.get("export.pdf.METADATA_SUBJECT", ""));
    jTextFieldMetadataTitle.setText(pref.get("export.pdf.METADATA_TITLE", ""));
    jTextFieldOwnerPassword.setText(pref.get("export.pdf.OWNER_PASSWORD", ""));
    jTextFieldUserPassword.setText(pref.get("export.pdf.USER_PASSWORD", ""));
    jTextFieldTagLanguage.setText(pref.get("export.pdf.TAG_LANGUAGE", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_TAG_LANGUAGE)));
    jTextAreaPDFJavascript.setText(pref.get("export.pdf.PDF_JAVASCRIPT", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT)));

    int documentPermissions = pref.getInt("export.pdf.PERMISSIONS",0);
    jCheckBoxAllawDegradedPrinting.setSelected( (documentPermissions & PdfWriter.ALLOW_DEGRADED_PRINTING) > 0);
    jCheckBoxAllowAssembly.setSelected( (documentPermissions & PdfWriter.ALLOW_ASSEMBLY) > 0);
    jCheckBoxAllowCopy.setSelected( (documentPermissions & PdfWriter.ALLOW_COPY) > 0);
    jCheckBoxAllowFillIn.setSelected( (documentPermissions & PdfWriter.ALLOW_FILL_IN) > 0);
    jCheckBoxAllowModifyAnnotations.setSelected( (documentPermissions & PdfWriter.ALLOW_MODIFY_ANNOTATIONS) > 0);
    jCheckBoxAllowModifyContents.setSelected( (documentPermissions & PdfWriter.ALLOW_MODIFY_CONTENTS) > 0);
    jCheckBoxAllowPrinting.setSelected( (documentPermissions & PdfWriter.ALLOW_PRINTING) == PdfWriter.ALLOW_PRINTING);
    jCheckBoxAllowScreenReaders.setSelected( (documentPermissions & PdfWriter.ALLOW_SCREENREADERS) > 0);
    setInit(false);
}
项目:ireport-fork    文件:PdfExportParametersPanel.java   
public void store() {

        Preferences pref = IReportManager.getPreferences();

        Tag t = (Tag) jComboBoxPDFVersion.getSelectedItem();
        if (t.getValue() == null) {
            pref.remove(JRPdfExporterParameter.PROPERTY_PDF_VERSION);
        } else {
            pref.put(JRPdfExporterParameter.PROPERTY_PDF_VERSION, ""+t.getValue());
        }

        pref.putBoolean(JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS , jCheckBoxCreatingBatchModeBookmarks.isSelected());
        pref.putBoolean(JRPdfExporterParameter.PROPERTY_COMPRESSED , jCheckBoxCompressed.isSelected());
        pref.putBoolean(JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY , jCheckBoxForceLinebreakPolicy.isSelected());
        pref.putBoolean(JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES , jCheckBoxForceSVGShapes.isSelected());
        pref.putBoolean(JRPdfExporterParameter.PROPERTY_TAGGED , jCheckBoxIsTagged.isSelected());

        int index = jComboBoxEncryption.getSelectedIndex();
        pref.putBoolean(JRPdfExporterParameter.PROPERTY_ENCRYPTED , (index != 0));
        pref.putBoolean(JRPdfExporterParameter.PROPERTY_128_BIT_KEY , (index == 2));

        pref.put("export.pdf.METADATA_AUTHOR" , jTextFieldMetadataAuthor.getText());
        pref.put("export.pdf.METADATA_CREATOR" , jTextFieldMetadataCreator.getText());
        pref.put("export.pdf.METADATA_KEYWORDS" , jTextFieldMetadataKeywords.getText());
        pref.put("export.pdf.METADATA_SUBJECT" , jTextFieldMetadataSubject.getText());

        pref.put("export.pdf.METADATA_TITLE" , jTextFieldMetadataTitle.getText());
        pref.put("export.pdf.OWNER_PASSWORD" , jTextFieldOwnerPassword.getText());
        pref.put("export.pdf.USER_PASSWORD" , jTextFieldUserPassword.getText());
        pref.put("export.pdf.TAG_LANGUAGE" , jTextFieldTagLanguage.getText());
        pref.put("export.pdf.PDF_JAVASCRIPT" , jTextAreaPDFJavascript.getText());

        t = (Tag) jComboBoxPdfA.getSelectedItem();
        if (t.getValue() == null) {
            pref.remove(JRPdfExporterParameter.PROPERTY_PDFA_CONFORMANCE);
        } else {
            pref.put(JRPdfExporterParameter.PROPERTY_PDFA_CONFORMANCE,""+t.getValue());
        }

        pref.put(JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH , jTextFieldICC.getText());


        int documentPermissions = 0;
        if (jCheckBoxAllawDegradedPrinting.isSelected()) documentPermissions |= PdfWriter.ALLOW_DEGRADED_PRINTING;
        if (jCheckBoxAllowAssembly.isSelected()) documentPermissions |= PdfWriter.ALLOW_ASSEMBLY;
        if (jCheckBoxAllowCopy.isSelected()) documentPermissions |= PdfWriter.ALLOW_COPY;
        if (jCheckBoxAllowFillIn.isSelected()) documentPermissions |= PdfWriter.ALLOW_FILL_IN;
        if (jCheckBoxAllowModifyAnnotations.isSelected()) documentPermissions |= PdfWriter.ALLOW_MODIFY_ANNOTATIONS;
        if (jCheckBoxAllowModifyContents.isSelected()) documentPermissions |= PdfWriter.ALLOW_MODIFY_CONTENTS;
        if (jCheckBoxAllowPrinting.isSelected()) documentPermissions |= PdfWriter.ALLOW_PRINTING;
        if (jCheckBoxAllowScreenReaders.isSelected()) documentPermissions |= PdfWriter.ALLOW_SCREENREADERS;

        pref.putInt("export.pdf.PERMISSIONS" , documentPermissions);
    }
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configurePdfExporter(JRExporter exporter, SimpleJasperReportsContext context) {

        Preferences pref = IReportManager.getPreferences();
        JRPropertiesUtil jrPropUtils = JRPropertiesUtil.getInstance(context);


        String pdfVersion = pref.get(JRPdfExporterParameter.PROPERTY_PDF_VERSION, null);
        if (pdfVersion != null && pdfVersion.length()==1) context.setValue( JRPdfExporterParameter.PROPERTY_PDF_VERSION  , ""+pdfVersion.charAt(0));

        boolean b = pref.getBoolean(JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS));
        context.setValue( JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS , new Boolean(b));

        context.setValue( JRPdfExporterParameter.PROPERTY_COMPRESSED , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_COMPRESSED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_COMPRESSED))));
        context.setValue( JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY))));
        context.setValue( JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES))));
        context.setValue( JRPdfExporterParameter.PROPERTY_TAGGED , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_TAGGED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_TAGGED))));
        context.setValue( JRPdfExporterParameter.PROPERTY_ENCRYPTED , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_ENCRYPTED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_ENCRYPTED))));
        context.setValue( JRPdfExporterParameter.PROPERTY_128_BIT_KEY , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_128_BIT_KEY, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_128_BIT_KEY))));

        if (pref.get("export.pdf.METADATA_AUTHOR", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_AUTHOR , pref.get("export.pdf.METADATA_AUTHOR", ""));
        }
        if (pref.get("export.pdf.METADATA_CREATOR", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_CREATOR , pref.get("export.pdf.METADATA_CREATOR", ""));
        }
        if (pref.get("export.pdf.METADATA_KEYWORDS", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_KEYWORDS , pref.get("export.pdf.METADATA_KEYWORDS", ""));
        }
        if (pref.get("export.pdf.METADATA_SUBJECT", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_SUBJECT , pref.get("export.pdf.METADATA_SUBJECT", ""));
        }
        if (pref.get("export.pdf.METADATA_TITLE", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_TITLE , pref.get("export.pdf.METADATA_TITLE", ""));
        }
        if (pref.get("export.pdf.OWNER_PASSWORD", "").length() > 0)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_OWNER_PASSWORD , pref.get("export.pdf.OWNER_PASSWORD", ""));
        }
        if (pref.get("export.pdf.USER_PASSWORD", "").length() > 0)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_USER_PASSWORD , pref.get("export.pdf.USER_PASSWORD", ""));
        }
        if (pref.get("export.pdf.TAG_LANGUAGE", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_TAG_LANGUAGE)) != null)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_TAG_LANGUAGE ,pref.get("export.pdf.TAG_LANGUAGE", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_TAG_LANGUAGE)));
        }
        if (pref.get("export.pdf.PDF_JAVASCRIPT", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT)) != null)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT ,pref.get("export.pdf.PDF_JAVASCRIPT", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT)));
        }
        if (pref.getInt("export.pdf.PERMISSIONS",0) != 0)
        {
            exporter.setParameter(JRPdfExporterParameter.PERMISSIONS ,pref.getInt("export.pdf.PERMISSIONS",0));
        }


        String pdfa = pref.get(JRPdfExporterParameter.PROPERTY_PDFA_CONFORMANCE,jrPropUtils.getProperty(JRPdfExporterParameter.PDFA_CONFORMANCE_NONE));
        if (pdfa != null)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_PDFA_CONFORMANCE ,pdfa);
        }

        String pdfaICC = pref.get(JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH,jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH));
        if (pdfaICC != null && !pdfaICC.equals(""))
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH ,pdfaICC);
        }
    }