xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Smith <thomat...@gmail.com>
Subject How to use native text with EPSDocumentGraphics2D?
Date Tue, 06 Mar 2012 19:07:08 GMT
Hi,

I'd like to use XML Graphics Commons's EPSDocumentGraphics2D to generate
output that includes the text as text, not as rendered shapes.  Is there a
straightforward way to do that?

I've tried including both xmlgraphics-commons-1.4.jar and fop-1.0.jar in my
project, and using the NativeTextHandler class from org.apache.fop.render.ps,
like this...

 OutputStream out = new FileOutputStream("mini-test.eps");
EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
g2d.setGraphicContext(new GraphicContext());
g2d.setCustomTextHandler(new NativeTextHandler(g2d, null));
g2d.setupDocument(out, 200, 100);
g2d.setFont(new Font("Helvetica", Font.PLAIN, 12));
g2d.drawString("Hi there", 50, 50);
g2d.finish();
out.close();

But it generates invalid EPS files, like the one attached.  Here's the
output from Adobe Acrobat Pro...

%%[ Error: typecheck; OffendingCommand: findfont ]%%

Stack:
/Font
-null-


%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
%%[ Warning: PostScript error. No PDF file produced. ] %%


If I leave out the NativeTextHandler line, it generates valid EPS files,
but you can't e.g. copy and paste the text from the file.

Any help appreciated!
I'm not on the mailing list, so please CC me...
-Thomas

Mime
View raw message