xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luis Bernardo <lmpmberna...@gmail.com>
Subject Re: How to use native text with EPSDocumentGraphics2D?
Date Thu, 15 Mar 2012 00:36:34 GMT

There is bug that makes the EPS file invalid. Until the bug is fixed you 
can manually fix the EPS file.

The problem is with the font. For the example below open the EPS file 
and search for

null 12 F

replace that with

/Helvetica 12 F


On 3/6/12 7:07 PM, Thomas Smith wrote:
> 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 <http://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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: general-help@xmlgraphics.apache.org


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message