Java Mailing List Archive

http://www.java2.5341.com/

Home » fop-users-digest.xmlgraphics »

fop-users Digest 29 Dec 2012 21:15:04 -0000 Issue 2629

fop-users-digest-help

2012-12-29


Author LoginPost Reply

fop-users Digest 29 Dec 2012 21:15:04 -0000 Issue 2629

Topics (messages 36141 through 36143)

targetrenderer set to MIME_PNG fails in fop >=1.0 but succeeds in 0.95
 36141 by: Milo van der Zee

fop-ttfreader - output bounding box information for characters?
 36142 by: Alexey Neyman

Re: FOP command-line option in ant task
 36143 by: Walter Kruse

Administrivia:

---------------------------------------------------------------------
To post to the list, e-mail: fop-users@(protected)
To unsubscribe, e-mail: fop-users-digest-unsubscribe@(protected)
For additional commands, e-mail: fop-users-digest-help@(protected)

----------------------------------------------------------------------


Attachment: fop-users_36141.eml (zipped)
Dear FOP users,

I'm using FOP for a couple of years now and thought it was time to upgrade to version 1.1. Problem is that the rendering to PNG stopped functioning. It all still works with version 0.95.

PDF generation is still fine. The difference between PNG and PDF generation is the mime type of fop generated with the factory.
Strange thing is that the call to 'userAgent.getRendererOverride()' returns 'null' in version 1.1 and returned the expected PNGRenderer in version 0.95. Is this a bug or is something changed between versions in relation to PNG rendering?
From the debug info I see that the renderer does create a page. It seems like the link between the rendererImpl and the mime-type is not found. But where can I force that?

See code fragments below.

Thank you very much for any help.,
Milo van der Zee

some relevant code:
---------------------------------------
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
foUserAgent.setTargetResolution(document.getPreviewDPI());
ByteArrayOutputStream out = new ByteArrayOutputStream();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PNG, foUserAgent, out);
TransformerFactory factory = TransformerFactory.newInstance();
Source xslfo = DocumentGenerator.generateXslFo(document);
Transformer transformer = factory.newTransformer(xslfo);

SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setErrorHandler(new SaxParserErrorListener());
org.jdom.Document dataDocument = saxBuilder.build(new StringReader(dataString));
DOMSource src = new DOMSource((new DOMOutputter()).output(dataDocument));
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);

FOUserAgent userAgent = fop.getUserAgent();
PNGRenderer renderer = (PNGRenderer)userAgent.getRendererOverride();
---------------------------------------

---------------------------------------
I added this to my pom.xml:
---------------------------------------
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>${fop-version}</version>
<exclusions>
<!-- FOP has wrong dependancies on the avalon framework -->
<exclusion>
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- these two are to correct issues in fop dependency -->
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
<version>4.2.0</version>
</dependency>
---------------------------------------

---------------------------------------
Some debug info:
---------------------------------------
DEBUG org.apache.fop.util.ContentHandlerFactoryRegistry - Dynamically adding ContentHandlerFactory: org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory
DEBUG org.apache.fop.util.ContentHandlerFactoryRegistry - Dynamically adding ContentHandlerFactory: org.apache.fop.render.ps.extensions.PSExtensionHandlerFactory
DEBUG org.apache.fop.util.ContentHandlerFactoryRegistry - Dynamically adding ContentHandlerFactory: org.apache.fop.fo.extensions.xmp.XMPContentHandlerFactory
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for Renderer: org.apache.fop.render.txt.TXTRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for Renderer: org.apache.fop.render.bitmap.PNGRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for Renderer: org.apache.fop.render.bitmap.TIFFRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for Renderer: org.apache.fop.render.xml.XMLRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for Renderer: org.apache.fop.render.awt.AWTRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for Renderer: org.apache.fop.render.print.PrintRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for FOEventHandler: org.apache.fop.render.rtf.RTFFOEventHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for IFDocumentHandler: org.apache.fop.render.pdf.PDFDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for IFDocumentHandler: org.apache.fop.render.pcl.PCLDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for IFDocumentHandler: org.apache.fop.render.bitmap.TIFFDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for IFDocumentHandler: org.apache.fop.render.bitmap.PNGDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for IFDocumentHandler: org.apache.fop.render.ps.PSDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for IFDocumentHandler: org.apache.fop.render.afp.AFPDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker for IFDocumentHandler: org.apache.fop.render.intermediate.IFSerializerMaker
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding XMLHandler: org.apache.fop.render.pdf.PDFSVGHandler
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding XMLHandler: org.apache.fop.render.ps.PSSVGHandler
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding XMLHandler: org.apache.fop.render.java2d.Java2DSVGHandler
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding XMLHandler: org.apache.fop.render.pcl.PCLSVGHandler
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding XMLHandler: org.apache.fop.render.afp.AFPSVGHandler
DEBUG org.apache.fop.render.ImageHandlerRegistry - Dynamically adding ImageHandler: org.apache.fop.render.pdf.PDFImageHandlerGraphics2D
DEBUG org.apache.fop.render.ImageHandlerRegistry - Dynamically adding ImageHandler: org.apache.fop.render.pdf.PDFImageHandlerRenderedImage
...
DEBUG org.apache.fop.render.ImageHandlerRegistry - Dynamically adding ImageHandler: org.apache.fop.render.afp.AFPImageHandlerSVG
DEBUG org.apache.fop.render.AbstractConfigurator - userconfig is null
DEBUG org.apache.fop.render.AbstractConfigurator - userconfig is null
DEBUG org.apache.fop.fonts.FontInfo - Registering: any,normal,400 under F5
...
DEBUG org.apache.fop.fonts.FontInfo - Registering: Webdings,normal,400 under F170
DEBUG org.apache.fop.render.intermediate.IFRenderer - Rendering areas via IF document handler (org.apache.fop.render.intermediate.EventProducingFilter)...
DEBUG org.apache.fop.fo.FOTreeBuilder - Building formatting object tree
DEBUG org.apache.fop.image.loader.batik.PreloaderSVG - Error while trying to load stream as an SVG file: Invalid byte 1 of 1-byte UTF-8 sequence.
DEBUG org.apache.fop.image.loader.batik.PreloaderSVG - Error while trying to load stream as an SVG file: Invalid byte 1 of 1-byte UTF-8 sequence.
DEBUG org.apache.fop.area.AreaTreeHandler - Current heap size: 171055KB
DEBUG org.apache.fop.complexscripts.bidi.BidiResolver - BD: RESOLVE: org.apache.fop.fo.pagination.PageSequence@bc454f[@id=]
...
DEBUG org.apache.fop.layoutmgr.PageSequenceLayoutManager - Starting layout
...
DEBUG org.apache.fop.area.IDTracker - signalIDProcessed()
DEBUG org.apache.fop.render.bitmap.AbstractBitmapDocumentHandler - Don't know how to handle extension object. Ignoring: org.apache.xmlgraphics.xmp.Metadata@4ada6e (org.apache.xmlgraphics.xmp.Metadata)
INFO  org.apache.fop.apps.FOUserAgent - Rendered page #1.
DEBUG org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager - page finished: 1, current num: 1
...
DEBUG org.apache.fop.area.AreaTreeHandler - Pages rendered: 1
DEBUG org.apache.fop.area.AreaTreeHandler - Avg render time: 11734ms/page (5pages/min)




Attachment: fop-users_36142.eml (zipped)

Hi all,

 

As I mentioned in another email, I am trying to constrain FOP to use only local fonts (i.e. ones described in fop.cfg). For SVGs, I have a workaround:

- Generate fonts in SVG format using ttf2svg utility from Batik;

- Use an XSL stylesheet to embed all the fonts used by an SVG image into the image itself;

- Use such "preprocessed" SVG image as the input to FOP.

 

This does not work well with JEuclid, though. When JEuclid generates SVG from MathML, it performs font rendering - that is, replaces characters by actual paths. And again, it uses system fonts, not the fonts available in FOP - even if running as FOP plugin.

 

To work around this issue for MathML, I am currently switching from JEuclid to pMML2SVG (http://pmml2svg.sourceforge.net). It generates SVGs with text characters, not paths. But in order to do so, it needs font metrics. Unfortunately, font metrics produced by stock FOP TTFReader are not sufficient - this stylesheet also needs bounding box for each glyph. To obtain these, pMML2SVG currently packages an augmented TTFReader Java sources which are to be compiled and used in lieu of the stock one.

 

Given that the patch is very small and as far as I can tell, compatible with current users of font metrics (it just adds 4 attributes to glyph description), is it possible to integrate this support into stock FOP?

 

Patch from pMML2SVG, slightly modified to apply to FOP 1.1 sources, attached.

 

Regards,

Alexey.


Attachment: ttfreader.diff (zipped)
Attachment: fop-users_36143.eml (zipped)

<renderer mime="application/pdf">
  <encryption-params>
     <encryption-length>128</encryption-length>
     <user-password>testuserpass</user-password>
     <owner-password>testownerpass</owner-password>
     <noprint/>
     <nocopy/>
     <noedit/>
     <noannotations/>
     <nofillinforms/>
     <noaccesscontent/>
     <noassembledoc/>
     <noprinthq/>
  </encryption-params>
</renderer>

FOP command-line option in ant task



I build PDF from DocBook with Ant in Eclipse. All works well.

I want to pass the FOP command line args for -noprint, -nocopy, -noedit and -noannotations. I read about this in the FOP docs under security/encryption (http://xmlgraphics.apache.org/fop/0.95/pdfencryption.html). However, I cannot seem to find how to do this in my Ant build.xml

The built-in ant task (http://xmlgraphics.apache.org/fop/0.95/anttask.html) makes provision for indir, outdir etc. parameters. How do I include the FOP command-line options though ?

My target is as follows:

<target name="build-pdf" depends="depends"
        description="Generates PDF files from DocBook XML">
        <echo message="Running 'build-pdf' at ${timestamp}" />
        <echo message="******************************************" />
        <xslt style="${fo.stylesheet}" extension=".fo"
            basedir="${source.dir}" destdir="${fo.dir}">
            <classpath refid="xalan.classpath" />
            <include name="RubyRecipesForTesters.xml" />

        </xslt>
        <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
            <classpath>
                <fileset dir="${fop.home}/lib">
                    <include name="*.jar" />
                </fileset>
                <fileset dir="${fop.home}/build">
                    <include name="fop.jar" />
                    <include name="fop-hyph.jar" />
                </fileset>
            </classpath>
        </taskdef>
       

        <fop format="application/pdf" fofile="${fo.dir}/RubyRecipesForTesters.fo"
            outfile="${target.dir}/RubyRecipesForTesters.pdf"/>
        <copy file="${target.dir}/RubyRecipesForTesters.pdf" tofile="${publish.dir}/${pub.dir}/RubyRecipesforTesters.pdf"/>
    </target>

Thanks in advance
Walter Kruse

Re: FOP command-line option in ant task


The command-line and Ant task are completely different front-ends to FOP.
The Ant task did not get as much love as the command-line so may not
expose all features offered from the command-line. If you know a bit
about Java it should be fairly easy for you to extend the Ant task to
expose the features you're missing. We'll gladly consider any patch you
post to FOP's Bugzilla.

On 09.03.2011 07:09:37 Walter Kruse wrote:

>
> I build PDF from DocBook with Ant in Eclipse. All works well.
>
> I
> want to pass the FOP command line args for -noprint, -nocopy, -noedit
> and -noannotations. I read about this in the FOP docs under
> security/encryption (http://xmlgraphics.apache.org/fop/0.95/pdfencryption.html). However, I cannot seem to find how to do this in my
> Ant build.xml
>
> The built-in ant task (http://xmlgraphics.apache.org/fop/0.95/anttask.html) makes provision for indir, outdir
> etc. parameters. How do I include the FOP command-line options though ?
>
>
> My target is as follows:
>
> <target name="build-pdf" depends="depends"
>         description="Generates PDF files from DocBook XML">
>         <echo message="Running 'build-pdf' at ${timestamp}" />
>
>         <echo message="******************************************" />
>         <xslt style="${fo.stylesheet}" extension=".fo"
>             basedir="${source.dir}" destdir="${fo.dir}">
>
>             <classpath refid="xalan.classpath" />
>             <include name="RubyRecipesForTesters.xml" />
>
>         </xslt>
>         <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
>
>             <classpath>
>                 <fileset dir="${fop.home}/lib">
>                     <include name="*.jar" />
>                 </fileset>
>                 <fileset dir="${fop.home}/build">
>
>                     <include name="fop.jar" />
>                     <include name="fop-hyph.jar" />
>                 </fileset>
>             </classpath>
>         </taskdef>
>
>        
>
>         <fop format="application/pdf" fofile="${fo.dir}/RubyRecipesForTesters.fo"
>             outfile="${target.dir}/RubyRecipesForTesters.pdf"/>
>         <copy file="${target.dir}/RubyRecipesForTesters.pdf" tofile="${publish.dir}/${pub.dir}/RubyRecipesforTesters.pdf"/>
>
>     </target>
>
> Thanks in advance
> Walter Kruse
>      




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Re: FOP command-line option in ant task



In reply to this post by Walter Kruse-2
Hi Walter,

Have you tried running FOP from the command line? This is the
preferred way to run FOP as a stand alone application.  If you can
invest a little time to set this up you will be rewarded with the
ability to fully configure FOP.

If you think you are truly bound to the ant task, then a modest
modification to org.apache.fop.tools.anttasks.Fop to parse the
properties for the encryption parameters, as suggested by Jeremias.
This is handled from the command line arguments by
org.apache.fop.cli.CommandLineOptions, which you may want to use for
inspiration.

Good luck,

Peter


On Wed, Mar 9, 2011 at 6:09 AM, Walter Kruse <[hidden email]> wrote:

> I build PDF from DocBook with Ant in Eclipse. All works well.
>
> I want to pass the FOP command line args for -noprint, -nocopy, -noedit and
> -noannotations. I read about this in the FOP docs under security/encryption
> (http://xmlgraphics.apache.org/fop/0.95/pdfencryption.html). However, I
> cannot seem to find how to do this in my Ant build.xml
>
> The built-in ant task (http://xmlgraphics.apache.org/fop/0.95/anttask.html)
> makes provision for indir, outdir etc. parameters. How do I include the FOP
> command-line options though ?
>
> My target is as follows:
>
> <target name="build-pdf" depends="depends"
>         description="Generates PDF files from DocBook XML">
>         <echo message="Running 'build-pdf' at ${timestamp}" />
>         <echo message="******************************************" />
>         <xslt style="${fo.stylesheet}" extension=".fo"
>             basedir="${source.dir}" destdir="${fo.dir}">
>             <classpath refid="xalan.classpath" />
>             <include name="RubyRecipesForTesters.xml" />
>
>         </xslt>
>         <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
>             <classpath>
>                 <fileset dir="${fop.home}/lib">
>                     <include name="*.jar" />
>                 </fileset>
>                 <fileset dir="${fop.home}/build">
>                     <include name="fop.jar" />
>                     <include name="fop-hyph.jar" />
>                 </fileset>
>             </classpath>
>         </taskdef>
>
>
>         <fop format="application/pdf"
> fofile="${fo.dir}/RubyRecipesForTesters.fo"
>             outfile="${target.dir}/RubyRecipesForTesters.pdf"/>
>         <copy file="${target.dir}/RubyRecipesForTesters.pdf"
> tofile="${publish.dir}/${pub.dir}/RubyRecipesforTesters.pdf"/>
>     </target>
>
> Thanks in advance
> Walter Kruse
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
©2008 java2.5341.com - Jax Systems, LLC, U.S.A.