當前位置: 首頁>>代碼示例>>Java>>正文


Java FopFactory.newInstance方法代碼示例

本文整理匯總了Java中org.apache.fop.apps.FopFactory.newInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java FopFactory.newInstance方法的具體用法?Java FopFactory.newInstance怎麽用?Java FopFactory.newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.fop.apps.FopFactory的用法示例。


在下文中一共展示了FopFactory.newInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: export

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public void export(OutputStream out) throws FOPException, IOException, TransformerException {
    FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

    // Setup XSLT
    TransformerFactory Factory = TransformerFactory.newInstance();
    Transformer transformer = Factory.newTransformer(xsltSource);

    // Set the value of a <param> in the stylesheet
    transformer.setParameter("versionParam", "2.0");

    // Setup input for XSLT transformation
    Reader reader = composeXml();
    Source src = new StreamSource(reader);

    // Resulting SAX events (the generated FO) must be piped through to
    // FOP
    Result res = new SAXResult(fop.getDefaultHandler());

    // Start XSLT transformation and FOP processing
    transformer.transform(src, res);

    reader.close();
    out.flush();
}
 
開發者ID:ManyDesigns,項目名稱:Portofino,代碼行數:27,代碼來源:FormPdfExporter.java

示例2: render

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
/**
 * <p>render</p>
 *
 * @param in a {@link java.io.Reader} object.
 * @param out a {@link java.io.OutputStream} object.
 * @param xslt a {@link java.io.Reader} object.
 * @throws org.opennms.reporting.availability.render.ReportRenderException if any.
 */
public void render(Reader in, OutputStream out, Reader xslt) throws ReportRenderException {
    try {

        FopFactory fopFactory = FopFactory.newInstance();
        fopFactory.setStrictValidation(false);
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

        TransformerFactory tfact = TransformerFactory.newInstance();
        Transformer transformer = tfact.newTransformer(new StreamSource(xslt));
        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
        transformer.transform(new StreamSource(in), new SAXResult(fop.getDefaultHandler()));

    } catch (TransformerConfigurationException tce) {
        log.fatal("TransformerConfigurationException", tce);
        throw new ReportRenderException(tce);
    } catch (TransformerException te) {
        log.fatal("TransformerException", te);
        throw new ReportRenderException(te);
    } catch (FOPException e) {
        log.fatal("FOPException", e);
        throw new ReportRenderException(e);
    }
}
 
開發者ID:vishwaabhinav,項目名稱:OpenNMS,代碼行數:32,代碼來源:PDFReportRenderer.java

示例3: initFopFactoryFromJar

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public FopFactory initFopFactoryFromJar() throws IOException, SAXException, ConfigurationException {

        FopFactory fopFactory = FopFactory.newInstance();

        FOURIResolver uriResolver = (FOURIResolver) fopFactory.getURIResolver();

        if (context != null) {
            uriResolver.setCustomURIResolver(new CustomResolver(context));
        } else {
            uriResolver.setCustomURIResolver(new CustomResolver());
        }

        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
        Configuration cfg = builder.build(getClass().getResourceAsStream("fop-pdf-thai.xml"));
        fopFactory.setUserConfig(cfg);

        return fopFactory;
    }
 
開發者ID:jampajeen,項目名稱:fop-pdf-thai,代碼行數:19,代碼來源:FopPdfThai.java

示例4: export

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public void export(OutputStream out) throws FOPException, IOException, TransformerException {
    FopFactory fopFactory = FopFactory.newInstance();

    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

    // Setup XSLT
    TransformerFactory Factory = TransformerFactory.newInstance();
    Transformer transformer = Factory.newTransformer(xsltSource);

    // Set the value of a <param> in the stylesheet
    transformer.setParameter("versionParam", "2.0");

    // Setup input for XSLT transformation
    Reader reader = composeXml();
    Source src = new StreamSource(reader);

    // Resulting SAX events (the generated FO) must be piped through to
    // FOP
    Result res = new SAXResult(fop.getDefaultHandler());

    // Start XSLT transformation and FOP processing
    transformer.transform(src, res);

    reader.close();
    out.flush();
}
 
開發者ID:hongliangpan,項目名稱:manydesigns.cn,代碼行數:27,代碼來源:FormPdfExporter.java

示例5: resolveView

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public void resolveView(ServletRequest request, ServletResponse response, Preferences preferences, Object viewData) throws Exception {
    InputStream is = new ByteArrayInputStream(((String) viewData).getBytes("UTF-8"));
    
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    
    FopFactory fopFactory = FopFactory.newInstance();
    fopFactory.setStrictValidation(false);
    FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
    
    TransformerFactory tfact = TransformerFactory.newInstance();
    Transformer transformer = tfact.newTransformer();
    Source src = new StreamSource(is);
    Result res = new SAXResult(fop.getDefaultHandler());
    transformer.transform(src, res);
    
    byte[] contents = out.toByteArray();
    response.setContentLength(contents.length);
    response.getOutputStream().write(contents);

}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:22,代碼來源:OnmsPdfViewResolver.java

示例6: testDocumentHandlerLevel

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
@Test
public void testDocumentHandlerLevel() throws Exception {
    FopFactory fopFactory = FopFactory.newInstance();
    RendererFactory factory = fopFactory.getRendererFactory();
    FOUserAgent ua;
    IFDocumentHandler handler;
    IFDocumentHandler overrideHandler;

    ua = fopFactory.newFOUserAgent();
    handler = factory.createDocumentHandler(ua, MimeConstants.MIME_PDF);

    ua = fopFactory.newFOUserAgent();
    overrideHandler = new PDFDocumentHandler();
    overrideHandler.setContext(new IFContext(ua));
    ua.setDocumentHandlerOverride(overrideHandler);
    handler = factory.createDocumentHandler(ua, null);
    assertTrue(handler == overrideHandler);

    ua = fopFactory.newFOUserAgent();
    try {
        handler = factory.createDocumentHandler(ua, "invalid/format");
        fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException uoe) {
        //expected
    }
}
 
開發者ID:pellcorp,項目名稱:fop,代碼行數:27,代碼來源:RendererFactoryTestCase.java

示例7: readInput

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
protected void readInput(PipelineContext context, ProcessorInput input, Config config, OutputStream outputStream) {
    try {
        // Setup FOP to output PDF
        final FopFactory fopFactory = FopFactory.newInstance();
        final FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

        final URL configFileUrl = this.getClass().getClassLoader().getResource("fop-userconfig.xml");
        if (configFileUrl == null) {
            logger.warn("FOP config file not found. Please put a fop-userconfig.xml file in your classpath for proper display of UTF-8 characters.");
        } else {
            final File userConfigXml = new File(configFileUrl.getFile());
            fopFactory.setUserConfig(userConfigXml);
        }

        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, outputStream);

        // Send data to FOP
        readInputAsSAX(context, INPUT_DATA, new ForwardingXMLReceiver(fop.getDefaultHandler()));
    } catch (Exception e) {
        throw new OXFException(e);
    }
}
 
開發者ID:evlist,項目名稱:orbeon-forms,代碼行數:23,代碼來源:XSLFOSerializer.java

示例8: getFactoryInstance

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
/** Returns an instance of the FopFactory class. FOP documentation recommends
 * the reuse of the factory instance because of the startup time.
 * @return FopFactory The FopFactory instance
 */
public static FopFactory getFactoryInstance() {
    if (fopFactory == null) {
        synchronized (ApacheFopWorker.class) {
            if (fopFactory != null) {
                return fopFactory;
            }

            try {
                String ofbizHome = System.getProperty("ofbiz.home");
                File userConfigFile = FileUtil.getFile(ofbizHome + fopPath + "/fop.xconf");
                if (userConfigFile.exists()) {
                    fopFactory = FopFactory.newInstance(userConfigFile);
                } else {
                    Debug.logWarning("FOP configuration file not found: " + userConfigFile, module);
                }
                File fontBaseFile = FileUtil.getFile(ofbizHome + fopFontBaseProperty);
                if (fontBaseFile.isDirectory()) {
                    fopFactory.getFontManager().setResourceResolver(ResourceResolverFactory.createDefaultInternalResourceResolver(fontBaseFile.toURI()));
                } else {
                    Debug.logWarning("FOP font base URL not found: " + fontBaseFile, module);
                }
                Debug.logInfo("FOP FontBaseURL: " + fopFactory.getFontManager().getResourceResolver().getBaseURI(), module);
            } catch (Exception e) {
                Debug.logWarning(e, "Error reading FOP configuration: ", module);
            }
        }
    }
    return fopFactory;
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:34,代碼來源:ApacheFopWorker.java

示例9: testDocu

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public void testDocu() throws IOException, NodeException, PinException, TransformerException, SAXException {
    FopFactory fopFactory = FopFactory.newInstance(new File(Resources.getRoot(), "docu/fop.xconf"));

    File maven = Resources.getRoot().getParentFile().getParentFile().getParentFile();
    File target = new File(maven, "target/docu");
    File images = new File(target, "img");
    images.mkdirs();
    for (Language l : Lang.getBundle().getSupportedLanguages()) {
        // set language
        Lang.setActualRuntimeLanguage(l);
        final String basename = "Documentation_" + l.getName();
        // write xml
        File xml = new File(target, basename + ".xml");
        try (Writer w = new OutputStreamWriter(new FileOutputStream(xml), "UTF-8")) {
            writeXML(w, images, l.getName());
        }

        // start xslt transformation
        File xslFO = new File(target, basename + ".fo");
        File xslt = new File(Resources.getRoot(), "docu/elem2fo.xslt");
        startXalan(xml, xslt, xslFO);

        // write pdf
        File pdf = new File(target, basename + ".pdf");
        startFOP(fopFactory, xslFO, pdf);
    }
}
 
開發者ID:hneemann,項目名稱:Digital,代碼行數:28,代碼來源:DocuTest.java

示例10: doStart

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
@Override
protected void doStart() throws Exception {
    super.doStart();

    if (fopFactory == null && userConfigURL == null) {
        fopFactory = FopFactory.newInstance(new URI("./"));
    } else if (fopFactory != null && userConfigURL != null) {
        throw new FopConfigException("More than one configuration. "
                + "You can configure fop either by config file or by supplying FopFactory but not both.");
    } else if (fopFactory == null && userConfigURL != null) {
        InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), userConfigURL);
        fopFactory = FopFactory.newInstance(new URI(userConfigURL), is);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:15,代碼來源:FopEndpoint.java

示例11: export

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public void export(OutputStream outputStream) throws FOPException,
        IOException, TransformerException {
    FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, outputStream);

    // Setup XSLT
    TransformerFactory Factory = TransformerFactory.newInstance();
    Transformer transformer = Factory.newTransformer(xsltSource);

    // Set the value of a <param> in the stylesheet
    transformer.setParameter("versionParam", "2.0");

    // Setup input for XSLT transformation
    Reader reader = composeXml();
    Source src = new StreamSource(reader);

    // Resulting SAX events (the generated FO) must be piped through to
    // FOP
    Result res = new SAXResult(fop.getDefaultHandler());

    // Start XSLT transformation and FOP processing
    transformer.transform(src, res);
    reader.close();

    outputStream.flush();
}
 
開發者ID:ManyDesigns,項目名稱:Portofino,代碼行數:28,代碼來源:TableFormPdfExporter.java

示例12: getFopFactory

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public FopFactory getFopFactory(String configName) throws Exception {
  FopFactory fopFactory = fopFactoryCache.get(configName);
  if (fopFactory == null) {
    String fopConfig = fopConfigs.get(configName);
    if (fopConfig == null) {
      throw new XSLWebException("FOP Configuration \"" + configName + "\" not configured in webapp.xml");        
    }      
    fopFactory = FopFactory.newInstance(getHomeDir().toURI(), IOUtils.toInputStream(fopConfig, "UTF-8"));      
    fopFactoryCache.put(configName, fopFactory);
  }
  return fopFactory;
}
 
開發者ID:Armatiek,項目名稱:xslweb,代碼行數:13,代碼來源:WebApp.java

示例13: writeOutputStream

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public static InputStream writeOutputStream(String fo,String outputFormat, OutputStream pdfOUT)
    throws  TransformerFactoryConfigurationError, TransformerConfigurationException, TransformerException
    {
  	  try
  	  {
     	  FopFactory fopFactory = FopFactory.newInstance();
   	  
         FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
         // configure foUserAgent as desired

        
	InputStream templateIS;
	//out = new BufferedOutputStream(pdfOUT);

            // Construct FOP with desired output format
            //private FopFactory fopFactory = FopFactory.newInstance();
            Fop fop = fopFactory.newFop(outputFormat, foUserAgent,pdfOUT );

            // Setup JAXP using identity transformer
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer(); // identity transformer
            
            // Setup input stream
            templateIS = Text.toInputStream(fo);
            Source src = new StreamSource(templateIS);

            // Resulting SAX events (the generated FO) must be piped through to FOP
            Result res = new SAXResult(fop.getDefaultHandler());
            
            // Start XSLT transformation and FOP processing
            transformer.transform(src, res);
	return templateIS;
  	  }
  	  catch(FOPException e)
  	  {
  		  throw new SystemException(e.getMessage(),e);
  	  }
}
 
開發者ID:nyla-solutions,項目名稱:nyla,代碼行數:39,代碼來源:FOP.java

示例14: getFactoryInstance

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
/** Returns an instance of the FopFactory class. FOP documentation recommends
 * the reuse of the factory instance because of the startup time.
 * @return FopFactory The FopFactory instance
 */
public static FopFactory getFactoryInstance() {
    if (fopFactory == null) {
        synchronized (ApacheFopWorker.class) {
            if (fopFactory != null) {
                return fopFactory;
            }
            // Create the factory
            fopFactory = FopFactory.newInstance();

            // Limit the validation for backwards compatibility
            fopFactory.setStrictValidation(false);

            try {
                String ofbizHome = System.getProperty("ofbiz.home");
                String fopPath = UtilProperties.getPropertyValue("fop.properties", "fop.path", ofbizHome + "/framework/webapp/config");
                File userConfigFile = FileUtil.getFile(fopPath + "/fop.xconf");
                if (userConfigFile.exists()) {
                    fopFactory.setUserConfig(userConfigFile);
                } else {
                    Debug.logWarning("FOP configuration file not found: " + userConfigFile, module);
                }
                String fopFontBaseProperty = UtilProperties.getPropertyValue("fop.properties", "fop.font.base.url", ofbizHome + "/framework/webapp/config/");
                File fontBaseFile = FileUtil.getFile(fopFontBaseProperty);
                if (fontBaseFile.isDirectory()) {
                    fopFactory.getFontManager().setFontBaseURL(fontBaseFile.toURI().toURL().toString());
                } else {
                    Debug.logWarning("FOP font base URL not found: " + fontBaseFile, module);
                }
                Debug.logInfo("FOP FontBaseURL: " + fopFactory.getFontManager().getFontBaseURL(), module);
            } catch (Exception e) {
                Debug.logWarning(e, "Error reading FOP configuration: ", module);
            }
        }
    }
    return fopFactory;
}
 
開發者ID:jamesyong,項目名稱:o3erp,代碼行數:41,代碼來源:ApacheFopWorker.java

示例15: export

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public void export(OutputStream outputStream) throws FOPException,
        IOException, TransformerException {
    FopFactory fopFactory = FopFactory.newInstance();

    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, outputStream);

    // Setup XSLT
    TransformerFactory Factory = TransformerFactory.newInstance();
    Transformer transformer = Factory.newTransformer(xsltSource);

    // Set the value of a <param> in the stylesheet
    transformer.setParameter("versionParam", "2.0");

    // Setup input for XSLT transformation
    Reader reader = composeXml();
    Source src = new StreamSource(reader);

    // Resulting SAX events (the generated FO) must be piped through to
    // FOP
    Result res = new SAXResult(fop.getDefaultHandler());

    // Start XSLT transformation and FOP processing
    transformer.transform(src, res);
    reader.close();

    outputStream.flush();
}
 
開發者ID:hongliangpan,項目名稱:manydesigns.cn,代碼行數:28,代碼來源:TableFormPdfExporter.java


注:本文中的org.apache.fop.apps.FopFactory.newInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。