Package org.apache.fop.apps

Examples of org.apache.fop.apps.FOUserAgent


            return;
        }
        int xOffset = pdfInfo.currentXPosition;
        int yOffset = pdfInfo.currentYPosition;

        FOUserAgent userAgent = context.getUserAgent();
        final float deviceResolution = userAgent.getTargetResolution();
        if (log.isDebugEnabled()) {
            log.debug("Generating SVG at " + deviceResolution + "dpi.");
        }

        final float uaResolution = userAgent.getSourceResolution();
        SVGUserAgent ua = new SVGUserAgent(userAgent, new AffineTransform());

        //Scale for higher resolution on-the-fly images from Batik
        double s = uaResolution / deviceResolution;
        AffineTransform resolutionScaling = new AffineTransform();
        resolutionScaling.scale(s, s);

        //Controls whether text painted by Batik is generated using text or path operations
        boolean strokeText = false;
        Configuration cfg = pdfInfo.cfg;
        if (cfg != null) {
            strokeText = cfg.getChild("stroke-text", true).getValueAsBoolean(strokeText);
        }

        BridgeContext ctx = new PDFBridgeContext(ua,
                (strokeText ? null : pdfInfo.fi),
                userAgent.getFactory().getImageManager(),
                userAgent.getImageSessionContext(),
                new AffineTransform());

        //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
        //to it.
        Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
View Full Code Here


   
    @Override
    public void transform() throws Exception {
        FopFactory fopFactory = FopFactory.newInstance();
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

        OutputStream out = new FileOutputStream(target);
        out = new BufferedOutputStream(out);
       
        try {
View Full Code Here

    private static Logger logger = Logger.getLogger(XmlTransformer.class.getName());
   
    @Override
    public void transform() throws Exception {
        FopFactory fopFactory = FopFactory.newInstance();
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

        OutputStream out = new FileOutputStream(target);
        out = new BufferedOutputStream(out);
       
        try {
View Full Code Here

    return null;
  }

  public File postProcessResult(File result) throws MojoExecutionException {
    final FopFactory fopFactory = FopFactory.newInstance();
    final FOUserAgent userAgent = fopFactory.newFOUserAgent();

    // First transform the cover page
    transformCover();

    // Get properties file from webhelp war
    String warBasename = result.getName().substring(0, result.getName().lastIndexOf('.'));
 
    Properties properties = new Properties();
    InputStream is;
   
    try {
        File f = new File(projectBuildDirectory, "autopdf/pdf.properties");
        is = new FileInputStream( f );
        properties.load(is);
    }
    catch ( Exception e ) {
        System.out.println("Got an Exception: " + e.getMessage());         
    }

    // FOUserAgent can be used to set PDF metadata
    Configuration configuration = loadFOPConfig();
    InputStream in = null;
    OutputStream out = null;
    File targetPdfFile = null;
    try
    {
      String baseURL = sourceDirectory.toURI().toURL().toExternalForm();
      baseURL = baseURL.replace("file:/", "file:///");

      userAgent.setBaseURL(baseURL);
      if (getLog().isDebugEnabled()) {
          getLog().debug("Absolute path is "+baseURL);
      }
      in = new FileInputStream(result);
View Full Code Here

    //  my own version of loadFOPConfig.  Really, I should be able to
    //  overwrite that method.
    //
    public void postProcessResult(File result) throws MojoExecutionException {
        final FopFactory fopFactory = FopFactory.newInstance();
        final FOUserAgent userAgent = fopFactory.newFOUserAgent();

        // First transform the cover page
        transformCover();

        // FOUserAgent can be used to set PDF metadata
        Configuration configuration = loadFOPConfig();
        InputStream in = null;
        OutputStream out = null;

        try
            {
                String baseURL = sourceDirectory.toURI().toURL().toExternalForm();
                baseURL = baseURL.replace("file:/", "file:///");

                userAgent.setBaseURL(baseURL);
                System.err.println ("Absolute path is "+baseURL);

                in = openFileForInput(result);
                out = openFileForOutput(getOutputFile(result));
                fopFactory.setUserConfig(configuration);
View Full Code Here

    public static Fop createFopInstance(OutputStream out, String outputFormat) throws FOPException {
        if (UtilValidate.isEmpty(outputFormat)) {
            outputFormat = MimeConstants.MIME_PDF;
        }
        FopFactory fopFactory = getFactoryInstance();
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        Fop fop;
        if (out != null) {
            fop = fopFactory.newFop(outputFormat, foUserAgent, out);
        } else {
            fop = fopFactory.newFop(outputFormat, foUserAgent);
View Full Code Here

                prop = FixedLength.getInstance(numPart.doubleValue(), unitPart);
            }
            break;

        case TOK_COLORSPEC:
            FOUserAgent ua = (propInfo == null)
                ? null
                : (propInfo.getFO() == null ? null : propInfo.getFO().getUserAgent());
            prop = new ColorProperty(ua, currentTokenValue);
            break;
View Full Code Here

        SAXParser parser;
        parser = spf.newSAXParser();
        foReader = parser.getXMLReader();

        FopFactory fopFactory = FopFactory.newInstance();
        FOUserAgent ua = fopFactory.newFOUserAgent();
        tableHandler = new TableHandler(ua);
        ua.setFOEventHandlerOverride(tableHandler);

        Fop fop = fopFactory.newFop(ua);

        foReader.setContentHandler(fop.getDefaultHandler());
        foReader.setDTDHandler(fop.getDefaultHandler());
View Full Code Here

            backgroundPositionVertical = pList.get(
                    Constants.PR_BACKGROUND_POSITION_VERTICAL).getLength();
           
            //Additional processing: preload image
            String url = ImageFactory.getURL(backgroundImage);
            FOUserAgent userAgent = fobj.getUserAgent();
            ImageFactory fact = userAgent.getFactory().getImageFactory();
            fopimage = fact.getImage(url, userAgent);
            if (fopimage == null) {
                Property.log.error("Background image not available: " + backgroundImage);
            } else {
                // load dimensions
View Full Code Here

                throws PropertyException {
        padding[side] = pList.get(paddingProp).getCondLength();
        // If style = none, force width to 0, don't get Color (spec 7.7.20)
        int style = pList.get(styleProp).getEnum();
        if (style != Constants.EN_NONE) {
            FOUserAgent ua = (pList == null)
                    ? null
                    : (pList.getFObj() == null ? null : pList.getFObj().getUserAgent());
            setBorderInfo(new BorderInfo(style,
                pList.get(widthProp).getCondLength(),
                pList.get(colorProp).getColor(ua)), side);
View Full Code Here

TOP

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

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.