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


Java FopFactory.setStrictValidation方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: getFopFactory

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public FopFactory getFopFactory(Document testDoc) {
    boolean base14KerningEnabled = isBase14KerningEnabled(testDoc);
    FopFactory effFactory = getFopFactory(base14KerningEnabled);

    boolean strictValidation = isStrictValidation(testDoc);
    effFactory.setStrictValidation(strictValidation);

    return effFactory;
}
 
開發者ID:pellcorp,項目名稱:fop,代碼行數:10,代碼來源:TestAssistant.java

示例4: print

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
public String print(String location) throws IOException, EngineException, SAXException, TransformerConfigurationException, TransformerFactoryConfigurationError, TransformerException, ParserConfigurationException {
	try {	
		//create the result repository
		outputFolder = location + "/ConvertigoPrint";
		File repository = new File(outputFolder);
		if (!repository.exists()) {
			repository.mkdir();
		}
		
		outputFileName = outputFolder + "\\" + projectName + extension;
		outputFile = new File(outputFileName);
		updateStatus("Setting up printing",20);
		
		// Construct/Configure a FopFactory
		FopFactory fopFactory = FopFactory.newInstance();
		fopFactory.setBaseURL(Engine.TEMPLATES_PATH + "/doc/");
		fopFactory.setStrictValidation(false);
		
		// Configure foUserAgent as desired
		FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
		foUserAgent.setBaseURL(Engine.TEMPLATES_PATH + "/doc/");
		foUserAgent.setAuthor("Convertigo EMS");
		
		// Setup output
		out = new FileOutputStream(outputFile);
		out = new java.io.BufferedOutputStream(out);
		
		// Construct fop with desired output format
		Fop fop = fopFactory.newFop(outputMime, foUserAgent, out);
		
		updateStatus("Analysing project",40);
		
		//Transform the project into a source
		Document document = XMLUtils.createDom("java");
		Element convertigoElement = document.createElement("convertigo");
		convertigoElement.setAttribute("exported", new Date().toString());
		convertigoElement.setAttribute("studio", product);
		convertigoElement.setAttribute("engine", com.twinsoft.convertigo.engine.Version.version);
		convertigoElement.setAttribute("beans", com.twinsoft.convertigo.beans.Version.version);
		//work around to let the external-graphics tag to read relative path
		//TODO configure fopFactory or/and foUserAgent
		convertigoElement.setAttribute("path", Engine.TEMPLATES_PATH+"/doc/");
		document.appendChild(convertigoElement);
		ProjectUtils.getFullProjectDOM(document, projectName, ExportOption.bIncludeDisplayName, ExportOption.bIncludeCompiledValue);
		Source src=new DOMSource(document);
		
		updateStatus("Printing in progress",60);
		
		// Setup XSLT
		String templateFileName = Engine.TEMPLATES_PATH + "/doc/doc.fo.xml";
		File foFile = new File(templateFileName);
		localizedDir = Engine.TEMPLATES_PATH+ "/doc/";
		Source xsltSrc = new StreamSource(new FileInputStream(foFile), localizedDir);
		TransformerFactory transformerFactory = TransformerFactory.newInstance();
		Transformer transformer = transformerFactory.newTransformer(xsltSrc);
		
		updateStatus(70);
		
		// Resulting SAX events (the generated FO) must be piped through to FOP
		DefaultHandler fopHandler=fop.getDefaultHandler();
		Result res = new SAXResult(fopHandler);
		
		// Start XSLT transformation and FOP processing
		transformer.transform(src,res);
		
		return outputFileName;		
	} finally {							
		if (out != null) {
			out.close();
		}
	}		
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:73,代碼來源:ConvertigoPrint.java

示例5: generatePDF

import org.apache.fop.apps.FopFactory; //導入方法依賴的package包/類
/**
 * Takes a DOM structure and renders a PDF
 * 
 * @param doc
 *        DOM structure
 * @param xslFileName
 *        XSL file to use to translate the DOM document to FOP
 */
@SuppressWarnings("unchecked")
protected void generatePDF(Document doc, OutputStream streamOut)
{
	String xslFileName = "participants-all-attrs.xsl";
	Locale currentLocale = rb.getLocale();
	if (currentLocale!=null){
		String fullLocale = currentLocale.toString();
		xslFileName = "participants-all-attrs_" + fullLocale + ".xsl";
		InputStream inputStream = getClass().getClassLoader().getResourceAsStream(xslFileName);
		if (inputStream == null){
			xslFileName = "participants-all-attrs_" + currentLocale.getCountry() + ".xsl";
			inputStream = getClass().getClassLoader().getResourceAsStream(xslFileName);
			if (inputStream == null){
				//We use the default file
				xslFileName = "participants-all-attrs.xsl";
			}
		}

		IOUtils.closeQuietly(inputStream);
	}
	String configFileName = "userconfig.xml";
	DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
	InputStream configInputStream = null;
	try 
	{
		configInputStream = getClass().getClassLoader().getResourceAsStream(configFileName);
		Configuration cfg = cfgBuilder.build(configInputStream);
		
		FopFactory fopFactory = FopFactory.newInstance();
		fopFactory.setUserConfig(cfg);
		fopFactory.setStrictValidation(false);
		FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
		if (!StringUtils.isEmpty(ServerConfigurationService.getString("pdf.default.font"))) {
		    // this allows font substitution to support i18n chars in PDFs - SAK-21909
		    FontQualifier fromQualifier = new FontQualifier();
		    fromQualifier.setFontFamily("DEFAULT_FONT");
		    FontQualifier toQualifier = new FontQualifier();
		    toQualifier.setFontFamily(ServerConfigurationService.getString("pdf.default.font", "Helvetica"));
		    FontSubstitutions result = new FontSubstitutions();
		    result.add(new FontSubstitution(fromQualifier, toQualifier));
		    fopFactory.getFontManager().setFontSubstitutions(result);
		}
		Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, streamOut);
		InputStream in = getClass().getClassLoader().getResourceAsStream(xslFileName);
		Transformer transformer = transformerFactory.newTransformer(new StreamSource(in));
		transformer.setParameter("titleName", rb.getString("sitegen.siteinfolist.title.name"));
		transformer.setParameter("titleSection", rb.getString("sitegen.siteinfolist.title.section"));
		transformer.setParameter("titleId", rb.getString("sitegen.siteinfolist.title.id"));
		transformer.setParameter("titleCredit", rb.getString("sitegen.siteinfolist.title.credit"));
		transformer.setParameter("titleRole", rb.getString("sitegen.siteinfolist.title.role"));
		transformer.setParameter("titleStatus", rb.getString("sitegen.siteinfolist.title.status"));

		Source src = new DOMSource(doc);
		transformer.transform(src, new SAXResult(fop.getDefaultHandler()));
	}
	catch (Exception e)
	{
		log.warn(this+".generatePDF(): " + e);
		return;
	}
	finally
	{
		IOUtils.closeQuietly(configInputStream);
	}
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:74,代碼來源:SiteInfoToolServlet.java


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