Package org.apache.fop.apps

Examples of org.apache.fop.apps.FopFactory


            Document testDoc = builder.parse(testFile);
           
            XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/base14kerning");
            String s = xo.str();
            boolean base14kerning = ("true".equalsIgnoreCase(s));
            FopFactory effFactory = (base14kerning ? fopFactoryWithBase14Kerning : fopFactory);
           
            //Setup Transformer to convert the testcase XML to XSL-FO
            Transformer transformer = getTestcase2FOStylesheet().newTransformer();
            Source src = new DOMSource(testDoc);
           
            //Setup Transformer to convert the area tree to a DOM
            TransformerHandler athandler = tfactory.newTransformerHandler();
            athandler.setResult(domres);
           
            //Setup FOP for area tree rendering
            FOUserAgent ua = effFactory.newFOUserAgent();
            ua.setBaseURL(testFile.getParentFile().toURL().toString());
            XMLRenderer atrenderer = new XMLRenderer();
            atrenderer.setUserAgent(ua);
            atrenderer.setContentHandler(athandler);
            ua.setRendererOverride(atrenderer);
            fop = effFactory.newFop(ua);
           
            SAXResult fores = new SAXResult(fop.getDefaultHandler());
            transformer.transform(src, fores);
        } finally {
            ElementListObserver.removeObserver(elCollector);
View Full Code Here


            convertAttributeToProperty(attributes, attributeName,
                    attributeValue);
        }
       
        String attributeNS;
        FopFactory factory = getFObj().getUserAgent().getFactory();
        for (int i = 0; i < attributes.getLength(); i++) {
            /* convert all attributes with the same namespace as the fo element for this fObj */
            attributeNS = attributes.getURI(i);
            attributeName = attributes.getQName(i);
            attributeValue = attributes.getValue(i);
            if (attributeNS == null || attributeNS.length() == 0) {
                convertAttributeToProperty(attributes, attributeName, attributeValue);
            } else if (!factory.isNamespaceIgnored(attributeNS)) {
                ElementMapping mapping = factory.getElementMappingRegistry().getElementMapping(
                        attributeNS);
                if (mapping != null) {
                    QName attName = new QName(attributeNS, attributeName);
                    if (mapping.isAttributeProperty(attName)
                            && mapping.getStandardPrefix() != null) {
View Full Code Here

    }

    public void testSVGNoViewbox() throws Exception {
        String uri = "test/resources/images/circles.svg";

        FopFactory ff = FopFactory.newInstance();
        ff.setSourceResolution(96);
        ff.setTargetResolution(300);

        FOUserAgent userAgent = ff.newFOUserAgent();

        ImageManager manager = ff.getImageManager();
        ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext());
        assertNotNull("ImageInfo must not be null", info);

        Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM,
                userAgent.getImageSessionContext());
View Full Code Here

        assertEquals(612000, info.getSize().getHeightMpt());
    }

    public void testSVGWithReferences() throws Exception {
        String uri = "test/resources/fop/svg/images.svg";
        FopFactory ff = FopFactory.newInstance();
        FOUserAgent userAgent = ff.newFOUserAgent();

        ImageManager manager = ff.getImageManager();
        ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext());
        assertNotNull("ImageInfo must not be null", info);

        Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM,
                userAgent.getImageSessionContext());
View Full Code Here

     * @throws FOPException in case of an error during processing
     */
    public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out)
                throws FOPException {

        FopFactory factory = userAgent.getFactory();
        Fop fop;
        if (out != null) {
            fop = factory.newFop(outputFormat, userAgent, out);
        } else {
            fop = factory.newFop(outputFormat, userAgent);
        }

        // if base URL was not explicitly set in FOUserAgent, obtain here
        if (fop.getUserAgent().getBaseURL() == null && sourcefile != null) {
            String baseURL = null;
View Full Code Here

            convertAttributeToProperty(attributes, attributeName,
                    attributeValue);
        }

        String attributeNS;
        FopFactory factory = getFObj().getUserAgent().getFactory();
        for (int i = 0; i < attributes.getLength(); i++) {
            /* convert all attributes with the same namespace as the fo element
             * the "xml:lang" property is a special case */
            attributeNS = attributes.getURI(i);
            attributeName = attributes.getQName(i);
            attributeValue = attributes.getValue(i);
            if (attributeNS == null || attributeNS.length() == 0
                    || "xml:lang".equals(attributeName)) {
                convertAttributeToProperty(attributes, attributeName, attributeValue);
            } else if (!factory.isNamespaceIgnored(attributeNS)) {
                ElementMapping mapping = factory.getElementMappingRegistry().getElementMapping(
                        attributeNS);
                QName attr = new QName(attributeNS, attributeName);
                if (mapping != null) {
                    if (mapping.isAttributeProperty(attr)
                            && mapping.getStandardPrefix() != null) {
View Full Code Here

   * @throws IOException
   */
  public static void main(String[] args) throws FOPException, TransformerException, IOException {
    // Step 1: Construct a FopFactory
    // (reuse if you plan to render multiple documents!)
    FopFactory fopFactory = FopFactory.newInstance();

    // Step 2: Set up output stream.
    // Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
    OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(
        "."+File.separator+"resources"+File.separator+"pdfs"+File.separator+
        "example_02.pdf")));

    try {
        // Step 3: Construct fop with desired output format
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

        // Step 4: Setup JAXP using identity transformer
        TransformerFactory factory = TransformerFactory.newInstance();
        //with XSLT:
        Source xslt = new StreamSource(new File(
View Full Code Here

   * @throws SAXException
   */
  public static void main(String[] args) throws TransformerException, IOException, ParserConfigurationException, SAXException {
    // Step 1: Construct a FopFactory
    // (reuse if you plan to render multiple documents!)
    FopFactory fopFactory = FopFactory.newInstance();

    // Step 2: Set up output stream.
    // Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
    OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(
        "."+File.separator+"resources"+File.separator+"pdfs"+File.separator+
        "quotation.pdf")));

    try {
        // Step 3: Construct fop with desired output format
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
        StreamResult xmlOutput = new StreamResult(new StringWriter());

        // Step 4: Setup JAXP using identity transformer
        TransformerFactory factory = TransformerFactory.newInstance();
        //with XSLT:
View Full Code Here

   * @throws IOException
   */
  public static void main(String[] args) throws FOPException, TransformerException, IOException {
    // Step 1: Construct a FopFactory
    // (reuse if you plan to render multiple documents!)
    FopFactory fopFactory = FopFactory.newInstance();

    // Step 2: Set up output stream.
    // Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
    OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(EXAMPLE_FILENAME_PDF)));

    try {
        // Step 3: Construct fop with desired output format
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

        // Step 4: Setup JAXP using identity transformer
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(); // identity transformer

View Full Code Here

    //IOUtils.copy(xmlInputStream,xmlOutputStream);
   
   
    // Step 1: Construct a FopFactory
    // (reuse if you plan to render multiple documents!)
    FopFactory fopFactory = FopFactory.newInstance();

    // Step 2: Set up output stream.
    // Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
    OutputStream fopOutputStream = new BufferedOutputStream(new FileOutputStream(new File(
        "."+File.separator+"resources"+File.separator+"pdfs"+File.separator+
        "example_03.pdf")));

    try {
        // Step 3: Construct fop with desired output format
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, fopOutputStream);

        // Step 4: Setup JAXP using identity transformer
        TransformerFactory factory = TransformerFactory.newInstance();
        //with XSLT:
        Source xslt = new StreamSource(new File(
View Full Code Here

TOP

Related Classes of org.apache.fop.apps.FopFactory

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.