OK, my code is OK, but my fop config file didn't have an entry for the at-xml renderer. I simply duplicated the pdf renderer and the fonts are fine.

On 06/03/2011 03:19 PM, Rob Sargent wrote:
Never mind. My first cut at putting the interface into the getMethod
call was broken. Obviously reflection requires the interface explicitly,
not the implementation.



On 06/03/2011 11:17 AM, Rob Sargent wrote:
I'm having trouble with XMLRender.mimicRenderer(Render) using fop-1.0

Unfortunately I have to do this all via reflection: Here's the broken
part:

    Method getRendererFactory =
    userAgent.getClass().getMethod("getRendererFactory", null);
    Object rendererFactory = getRendererFactory.invoke(userAgent, null);
    Method createRenderer =
    rendererFactory.getClass().getMethod("createRenderer",
    userAgent.getClass(),
    String.class);
    Object targetRenderer = createRenderer.invoke(rendererFactory,
    userAgent, AbstractFop9xStage.FOP_MIMETYPE_DEFAULT);

    //Now the special renderer for the intermediate file (AreaText style)
    Class xmlRendererClass =
    getFopClassLoader().loadClass("org.apache.fop.render.xml.XMLRenderer");
    Constructor xmlRendererConstructor =
    xmlRendererClass.getConstructor(null);
    Object xmlRenderer = xmlRendererConstructor.newInstance(null);
    Method mimicMethod = xmlRendererClass.getMethod("mimicRenderer",
    targetRenderer.getClass());
    mimicMethod.invoke(xmlRenderer, targetRenderer);

    //Make sure special renderer is used
    Method setRendererMethod =
    userAgent.getClass().getMethod("setRendererOverride",
    xmlRenderer.getClass());
    setRendererMethod.invoke(userAgent, xmlRenderer);

The error is:

    java.lang.NoSuchMethodException:
    
org.apache.fop.render.xml.XMLRenderer.mimicRenderer(org.apache.fop.render.intermediate.IFRenderer)

I'm not sure why I'm getting the IFRenderer, but I've checked that
that class is an implementation of Renderer so I don't understand the
error. If I don't enter the broken block the pdf is generated
correctly. (I only want to enter the broken block when I'm trying to
use the same fop to spit out a portion of the document: a table of
which I need to find the on-page size.)

On 06/02/2011 03:46 PM, Rob Sargent wrote:
Naturally I should have been more clear in my original posting: I'm
using the AreaTree (application/X-fop-areatree) intermediate format
not the IF form (application/X-fop-intermediate-format). the AT form
gives me an easy answer to content length. I've also re-read the doc
on AT and have some hope of resolving the problem. We'll see.

On 06/02/2011 09:57 AM, Rob Sargent wrote:
Chris,

Thanks. This looks like what I need. Now I have to work it into my
switch-hitting fop runner!

Cheers,

rjs


On 06/02/2011 09:35 AM, Chris Bowditch wrote:
On 02/06/2011 08:47, mehdi houshmand wrote:
Hi Rob,

Hi Rob,

Mehdi is right that the problem when generating IF is down to the
way the fop.xconf is organized by Renderer. The command line option
he mentions is the way to resolve this from the command line. The
API code we use to set the Mimic Renderer (the renderer from which
to lookup configuration for the IF Renderer in the fop.xconf) is
shown below:

IFDocumentHandler targetHandler =
m_factory.getRendererFactory().createDocumentHandler(m_foUserAgent,
mimeType);

IFSerializer ifSerializer = new IFSerializer();
ifSerializer.setContext(new IFContext(m_foUserAgent));
ifSerializer.mimicDocumentHandler(targetHandler);

HTH,

Chris

I just tested this on my system and I was finding the same results as
you... When I set the output format to IF, FOP wasn't working. So
anyway, I fixed it by setting the output MIME type, which is done via
the command line as such:

./fop -c fop.xconf test.fo -if<insert mime-type> output.if

so in my case it was:

./fop -c fop.xconf test.fo -if application/pdf output.if

When you think about it, it does make sense. You refer to fonts in
the
fop.xconf as a child of their rendering output, which allows you to
distinguish different font files according to the document output
format. There wouldn't be any way of FOP knowing your desired FINAL
output format if you were processing to IF.

How you do that using FOPs API, I don't know, but I can't imagine
that
would be hard to find out.

Mehdi

On 1 June 2011 19:18, Rob Sargent<[email protected]> wrote:
Again with thanks to Jeremias, I'm successfully sizing the
region-before for
dynamically generated tables. I'm doing this via and xslt
extension function
(Xalan style).

The xslt extension calls my sizing function which employs fop-1.0 to
generate an IF from the given dom.Node. I notice that during the
function's
invocation of fop-1.0 that the named fonts are not found and are
substituted
with "any" in the resultant intermediate format output, with
font-size=1000
(!!!!), with log messages like 'Font "Optima-Oblique,normal,700"
not found.
Substituting with "any,normal,700'. I'm doubly confused because
the fo is
ultimately processed to pdf by the same fop-1.0.

I have to confess that I'm invoking fop reflectively since we
have many
versions in play and I need each to have their own classpath.
That said the
same invocation happens for both the extension and the final
processing.
Here's part of the where the font path is set:

final Method setFontBaseURLMethod =
fopFactoryClass.getMethod("setFontBaseURL", new
Class[]{String.class});
String fontsURL = "file://" + bundlePath + fopHome + "/fonts";
setFontBaseURLMethod.invoke(fopFactory, new Object[]{fontsURL});

I suspect there is some subtle distinction between generating IF
and PDF
output?

I get good results with this if the caller of my function is
processed with
fop-1.0. If the caller is processed by fop-0.95 the estimated
size is much
too large and I mis-size the region. In both cases the IF has
'font-name="any"' so I'm a little surprised it work at all?!

Any pointers on where I've messed up would be greatly appreciated.

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

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


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





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


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


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


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

Reply via email to