You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Michael Lindeboom <mi...@bms.com> on 2005/12/21 21:56:17 UTC

Looking for PDF selectable text from PDFTranscoder

I am testing the PDFTranscoder. I see through he following example 
(http://xmlgraphics.apache.org/fop/dev/svg/text.pdf) that the text is 
selectable in some cases. Is there a transcoder setting that is required 
to generate selectable text in the resulting PDF document?

So far the SVG content that I have tried to transform to PDF does not 
have selectable text. Note: My examples also have some unicode for 
chinese characters.

My code is below.

        InputStream ins = new 
ByteArrayInputStream(svglabel.renderLabelContent().getBytes());
        PDFTranscoder t = new PDFTranscoder();
        t.addTranscodingHint(PDFTranscoder.KEY_EXECUTE_ONLOAD, new 
Boolean(true));
        t.addTranscodingHint(PDFTranscoder.KEY_STROKE_TEXT, new 
Boolean(true));
        TranscoderInput input = new TranscoderInput(ins);
        OutputStream ostream = new FileOutputStream(svgFile.getFile());
        TranscoderOutput output = new TranscoderOutput(ostream);
        t.transcode(input, output);
        ostream.flush();
        ostream.close();


Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Looking for PDF selectable text from PDFTranscoder

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
The first problem you'll have to fix is to set KEY_STROKE_TEXT to false.
Otherwise, all text is painted as shapes and is therefore not selectable.
However, not all text is per se selectable. Some more complex text
operations cannot (yet) be rendered using text operations. Furthermore,
we have some problems getting text painted as text at all. It depends on
the version in use. I expect this situation to get better with the next
Batik release.

There's another problem. You mention that you're using chinese
characters. Even if the text is painted as text you will currently not
be able to select the text because of a missing feature in FOP's PDF
library. Furthermore, it would only work if you properly register and
provide the necessary TrueType fonts as described in [1]. But again, due
to the missing feature that doesn't bring you closer to your goal.

[1] http://wiki.apache.org/xmlgraphics-fop/SvgNotes/PdfTranscoderTrueTypeEmbedding

So, I'm afraid you're currently out of luck and won't be able to achieve
selectable text. There's work planned to fix the problem with TrueType
fonts but I currently can't give an exact timeframe.

On 21.12.2005 21:56:17 Michael Lindeboom wrote:
> I am testing the PDFTranscoder. I see through he following example 
> (http://xmlgraphics.apache.org/fop/dev/svg/text.pdf) that the text is 
> selectable in some cases. Is there a transcoder setting that is required 
> to generate selectable text in the resulting PDF document?
> 
> So far the SVG content that I have tried to transform to PDF does not 
> have selectable text. Note: My examples also have some unicode for 
> chinese characters.
> 
> My code is below.
> 
>         InputStream ins = new 
> ByteArrayInputStream(svglabel.renderLabelContent().getBytes());
>         PDFTranscoder t = new PDFTranscoder();
>         t.addTranscodingHint(PDFTranscoder.KEY_EXECUTE_ONLOAD, new 
> Boolean(true));
>         t.addTranscodingHint(PDFTranscoder.KEY_STROKE_TEXT, new 
> Boolean(true));
>         TranscoderInput input = new TranscoderInput(ins);
>         OutputStream ostream = new FileOutputStream(svgFile.getFile());
>         TranscoderOutput output = new TranscoderOutput(ostream);
>         t.transcode(input, output);
>         ostream.flush();
>         ostream.close();
> 
> 
> Michael


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org