Package org.mapfish.print.config

Examples of org.mapfish.print.config.PDFConfig


    public void addRequiredValues(@Nonnull final Values sourceValues) {
        Object taskDirectory = sourceValues.getObject(TASK_DIRECTORY_KEY, Object.class);
        MfClientHttpRequestFactory requestFactory = sourceValues.getObject(CLIENT_HTTP_REQUEST_FACTORY_KEY,
                MfClientHttpRequestFactory.class);
        Template template = sourceValues.getObject(TEMPLATE_KEY, Template.class);
        PDFConfig pdfConfig = sourceValues.getObject(PDF_CONFIG, PDFConfig.class);
        String subReportDir = sourceValues.getObject(SUBREPORT_DIR, String.class);

        this.values.put(TASK_DIRECTORY_KEY, taskDirectory);
        this.values.put(CLIENT_HTTP_REQUEST_FACTORY_KEY, requestFactory);
        this.values.put(TEMPLATE_KEY, template);
View Full Code Here


        JRPdfExporter exporter = new JRPdfExporter(print.context);

        exporter.setParameter(JRExporterParameter.JASPER_PRINT, print.print);
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
        exporter.setParameter(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_7);
        final PDFConfig pdfConfig = print.values.getObject(Values.PDF_CONFIG, PDFConfig.class);
        exporter.setParameter(JRPdfExporterParameter.IS_COMPRESSED, pdfConfig.isCompressed());
        exporter.setParameter(JRPdfExporterParameter.METADATA_AUTHOR, pdfConfig.getAuthor());
        exporter.setParameter(JRPdfExporterParameter.METADATA_CREATOR, pdfConfig.getCreator());
        exporter.setParameter(JRPdfExporterParameter.METADATA_SUBJECT, pdfConfig.getSubject());
        exporter.setParameter(JRPdfExporterParameter.METADATA_TITLE, pdfConfig.getTitle());
        exporter.setParameter(JRPdfExporterParameter.METADATA_KEYWORDS, pdfConfig.getKeywordsAsString());

        exporter.exportReport();
    }
View Full Code Here

        attributeMap.put("subject", subjectKey);
        final PdfConfigurationProcessor pdfConfigurationProcessor = new PdfConfigurationProcessor();
        pdfConfigurationProcessor.setUpdates(attributeMap);
        PdfConfigurationProcessor.In in = new PdfConfigurationProcessor.In();
        in.values = new Values();
        in.pdfConfig = new PDFConfig();

        final String updatedTitle = "updatedTitle";
        final String updatedSubject = "updatedSubject";
        in.values.put(titleKey, updatedTitle);
        in.values.put(subjectKey, updatedSubject);
View Full Code Here

        attributeMap.put("keywords", keywordsKey);
        final PdfConfigurationProcessor pdfConfigurationProcessor = new PdfConfigurationProcessor();
        pdfConfigurationProcessor.setUpdates(attributeMap);
        PdfConfigurationProcessor.In in = new PdfConfigurationProcessor.In();
        in.values = new Values();
        in.pdfConfig = new PDFConfig();

        final ArrayList<String> keywordList = Lists.newArrayList("1", " 2", " 3\n");
        in.values.put(keywordsKey, keywordList);
        pdfConfigurationProcessor.execute(in, null);
        assertEquals("1,2,3", in.pdfConfig.getKeywordsAsString());
View Full Code Here

        final String titleKey = "titleAtt";
        final PdfConfigurationProcessor pdfConfigurationProcessor = new PdfConfigurationProcessor();
        pdfConfigurationProcessor.setUpdates(attributeMap);
        PdfConfigurationProcessor.In in = new PdfConfigurationProcessor.In();
        in.values = new Values();
        in.pdfConfig = new PDFConfig();

        attributeMap.put("title", titleKey + ".xxx");
        pdfConfigurationProcessor.setUpdates(attributeMap);
        in.values.put(titleKey, new CustomTitleAtt());
        pdfConfigurationProcessor.execute(in, null);
View Full Code Here

        final String titleKey = "titleAtt";
        final PdfConfigurationProcessor pdfConfigurationProcessor = new PdfConfigurationProcessor();
        pdfConfigurationProcessor.setUpdates(attributeMap);
        PdfConfigurationProcessor.In in = new PdfConfigurationProcessor.In();
        in.values = new Values();
        in.pdfConfig = new PDFConfig();

        attributeMap.put("title", titleKey + ".value");
        pdfConfigurationProcessor.setUpdates(attributeMap);
        in.values.put(titleKey, new CustomTitleAtt());
        pdfConfigurationProcessor.execute(in, null);
View Full Code Here

    @Test
    public void testPdfConfigDefaults() throws Exception {
        final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config-defaults.yaml"));
        final Template rawTemplate = config.getTemplate("main");
        final PDFConfig pdfConfigSpy = Mockito.spy(rawTemplate.getPdfConfig());
        Template templateSpy = Mockito.spy(rawTemplate);
        Mockito.when(templateSpy.getPdfConfig()).thenReturn(pdfConfigSpy);

        final Map<String, Template> templates = config.getTemplates();
        templates.put("main", templateSpy);
        config.setTemplates(templates);

        PJsonObject requestData = loadJsonRequestData();
        OutputStream outputStream = new ByteArrayOutputStream();
        OutputFormat format = this.outputFormat.get("pdfOutputFormat");
        format.print(requestData, config,
                getFile(JasperReportPDFOutputFormatTest.class, BASE_DIR), getTaskDirectory(),
                outputStream);
        assertAllMethodsCalled(pdfConfigSpy);
        assertEquals(false, pdfConfigSpy.isCompressed());
        assertEquals("Mapfish Print", pdfConfigSpy.getAuthor());
        assertEquals("Mapfish Print", pdfConfigSpy.getCreator());
        assertEquals("Mapfish Print", pdfConfigSpy.getKeywordsAsString());
        assertEquals("Mapfish Print", pdfConfigSpy.getTitle());
        assertEquals("Mapfish Print", pdfConfigSpy.getSubject());
    }
View Full Code Here

    @Test
    public void testPdfConfigValuesFromConfig() throws Exception {
        final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config-settings-in-config.yaml"));
        final Template rawTemplate = config.getTemplate("main");
        final PDFConfig pdfConfigSpy = Mockito.spy(rawTemplate.getPdfConfig());
        Template templateSpy = Mockito.spy(rawTemplate);
        Mockito.when(templateSpy.getPdfConfig()).thenReturn(pdfConfigSpy);

        final Map<String, Template> templates = config.getTemplates();
        templates.put("main", templateSpy);
        config.setTemplates(templates);

        PJsonObject requestData = loadJsonRequestData();
        OutputStream outputStream = new ByteArrayOutputStream();
        OutputFormat format = this.outputFormat.get("pdfOutputFormat");
        format.print(requestData, config,
                getFile(JasperReportPDFOutputFormatTest.class, BASE_DIR), getTaskDirectory(),
                outputStream);
        assertAllMethodsCalled(pdfConfigSpy);
        assertEquals(true, pdfConfigSpy.isCompressed());
        assertEquals("Config Author", pdfConfigSpy.getAuthor());
        assertEquals("Config Creator", pdfConfigSpy.getCreator());
        assertEquals("Config Keywords", pdfConfigSpy.getKeywordsAsString());
        assertEquals("Config Title", pdfConfigSpy.getTitle());
        assertEquals("Config Subject", pdfConfigSpy.getSubject());
    }
View Full Code Here

    @Test
    public void testPdfConfigValuesFromTemplate() throws Exception {
        final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config-settings-in-template.yaml"));
        final Template rawTemplate = config.getTemplate("main");
        final PDFConfig pdfConfigSpy = Mockito.spy(rawTemplate.getPdfConfig());
        Template templateSpy = Mockito.spy(rawTemplate);
        Mockito.when(templateSpy.getPdfConfig()).thenReturn(pdfConfigSpy);

        final Map<String, Template> templates = config.getTemplates();
        templates.put("main", templateSpy);
        config.setTemplates(templates);

        PJsonObject requestData = loadJsonRequestData();
        OutputStream outputStream = new ByteArrayOutputStream();
        OutputFormat format = this.outputFormat.get("pdfOutputFormat");
        format.print(requestData, config,
                getFile(JasperReportPDFOutputFormatTest.class, BASE_DIR), getTaskDirectory(),
                outputStream);
        assertAllMethodsCalled(pdfConfigSpy);
        assertEquals(true, pdfConfigSpy.isCompressed());
        assertEquals("Template Author", pdfConfigSpy.getAuthor());
        assertEquals("Template Creator", pdfConfigSpy.getCreator());
        assertEquals("Template Keywords", pdfConfigSpy.getKeywordsAsString());
        assertEquals("Template Title", pdfConfigSpy.getTitle());
        assertEquals("Template Subject", pdfConfigSpy.getSubject());
    }
View Full Code Here

    @Test
    public void testPdfConfigValuesInTemplateOverrideValuesInConfig() throws Exception {
        final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config-template-override-config.yaml"));
        final Template rawTemplate = config.getTemplate("main");
        final PDFConfig pdfConfigSpy = Mockito.spy(rawTemplate.getPdfConfig());
        Template templateSpy = Mockito.spy(rawTemplate);
        Mockito.when(templateSpy.getPdfConfig()).thenReturn(pdfConfigSpy);

        final Map<String, Template> templates = config.getTemplates();
        templates.put("main", templateSpy);
        config.setTemplates(templates);

        PJsonObject requestData = loadJsonRequestData();
        OutputStream outputStream = new ByteArrayOutputStream();
        OutputFormat format = this.outputFormat.get("pdfOutputFormat");
        format.print(requestData, config,
                getFile(JasperReportPDFOutputFormatTest.class, BASE_DIR), getTaskDirectory(),
                outputStream);
        assertAllMethodsCalled(pdfConfigSpy);
        assertEquals(false, pdfConfigSpy.isCompressed());
        assertEquals("Template Author", pdfConfigSpy.getAuthor());
        assertEquals("Config Creator", pdfConfigSpy.getCreator());
        assertEquals("Config Keywords", pdfConfigSpy.getKeywordsAsString());
        assertEquals("Template Title", pdfConfigSpy.getTitle());
        assertEquals("Config Subject", pdfConfigSpy.getSubject());
    }
View Full Code Here

TOP

Related Classes of org.mapfish.print.config.PDFConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.