You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Buzzy Spain <bs...@heartflow.com> on 2013/05/09 02:06:08 UTC
Subscript/Superscripts
Hi all,
I need to add text to a pdf that includes a number of superscript and
subscript characters. Is there a "right" way to do this? My assumption is
that drawing the string at some location and then drawing the
super/subscript at a reduced point size offset up or down is not best
practice. It will certainly be a pain...
The data I have is coming from a java String (UTF-16). The String literal
is being saved with an IDE that probably saves in a less preserving format
(UTF-8?). I can change the data source if it makes my life easier.
I am new to the world of PDFBox and the details of fonts so feel free to
start at the beginning and drive slowly. :)
Thanks,
Buzzy
Re: Subscript/Superscripts
Posted by Buzzy Spain <bs...@heartflow.com>.
A bit of mail client confusion on my part. Apologies for the bump.
On Thu, May 9, 2013 at 9:35 AM, Andreas Lehmkuehler <an...@lehmi.de>wrote:
> Hi,
>
> Am 09.05.2013 18:20, schrieb Buzzy Spain:
>
> Bump... haven't seen this go to the list yet...
>>
> What do you mean??
>
>
> On Wed, May 8, 2013 at 5:06 PM, Buzzy Spain <bs...@heartflow.com> wrote:
>>
>> Hi all,
>>>
>>> I need to add text to a pdf that includes a number of superscript and
>>> subscript characters. Is there a "right" way to do this? My assumption
>>> is
>>> that drawing the string at some location and then drawing the
>>> super/subscript at a reduced point size offset up or down is not best
>>> practice. It will certainly be a pain...
>>>
>>> The data I have is coming from a java String (UTF-16). The String
>>> literal
>>> is being saved with an IDE that probably saves in a less preserving
>>> format
>>> (UTF-8?). I can change the data source if it makes my life easier.
>>>
>>> I am new to the world of PDFBox and the details of fonts so feel free to
>>> start at the beginning and drive slowly. :)
>>>
>>> Thanks,
>>> Buzzy
>>>
>>>
>>
> BR
> Andreas Lehmkühler
>
Re: Subscript/Superscripts
Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,
Am 09.05.2013 18:20, schrieb Buzzy Spain:
> Bump... haven't seen this go to the list yet...
What do you mean??
> On Wed, May 8, 2013 at 5:06 PM, Buzzy Spain <bs...@heartflow.com> wrote:
>
>> Hi all,
>>
>> I need to add text to a pdf that includes a number of superscript and
>> subscript characters. Is there a "right" way to do this? My assumption is
>> that drawing the string at some location and then drawing the
>> super/subscript at a reduced point size offset up or down is not best
>> practice. It will certainly be a pain...
>>
>> The data I have is coming from a java String (UTF-16). The String literal
>> is being saved with an IDE that probably saves in a less preserving format
>> (UTF-8?). I can change the data source if it makes my life easier.
>>
>> I am new to the world of PDFBox and the details of fonts so feel free to
>> start at the beginning and drive slowly. :)
>>
>> Thanks,
>> Buzzy
>>
>
BR
Andreas Lehmkühler
Re: Subscript/Superscripts
Posted by Buzzy Spain <bs...@heartflow.com>.
Bump... haven't seen this go to the list yet...
On Wed, May 8, 2013 at 5:06 PM, Buzzy Spain <bs...@heartflow.com> wrote:
> Hi all,
>
> I need to add text to a pdf that includes a number of superscript and
> subscript characters. Is there a "right" way to do this? My assumption is
> that drawing the string at some location and then drawing the
> super/subscript at a reduced point size offset up or down is not best
> practice. It will certainly be a pain...
>
> The data I have is coming from a java String (UTF-16). The String literal
> is being saved with an IDE that probably saves in a less preserving format
> (UTF-8?). I can change the data source if it makes my life easier.
>
> I am new to the world of PDFBox and the details of fonts so feel free to
> start at the beginning and drive slowly. :)
>
> Thanks,
> Buzzy
>
Re: Subscript/Superscripts
Posted by Eliot Kimber <ek...@rsicms.com>.
The encoding of the string shouldn't matter--as long as the character that's
emitted into the PDF is the correct Unicode character and the font mapping
is to a Unicode font, then it will work. The only way the encoding could
matter is if you were manually constructing the bytes of the PDF, which you
are not (because PDFBox does that for you).
If you are not using a Unicode font then you will need to know which font
you are using and what character code from that font gives you the character
you want.
Cheers,
E.
On 5/9/13 12:52 PM, "Andreas Lehmkuehler" <an...@lehmi.de> wrote:
> Hi,
>
> Am 09.05.2013 02:06, schrieb Buzzy Spain:
>> Hi all,
>>
>> I need to add text to a pdf that includes a number of superscript and
>> subscript characters. Is there a "right" way to do this? My assumption is
>> that drawing the string at some location and then drawing the
>> super/subscript at a reduced point size offset up or down is not best
>> practice. It will certainly be a pain...
> The PDF format doesn't have any concept of formatted text. So your description
> is exactly what you have to do.
>
>> The data I have is coming from a java String (UTF-16). The String literal
>> is being saved with an IDE that probably saves in a less preserving format
>> (UTF-8?). I can change the data source if it makes my life easier.
>>
>> I am new to the world of PDFBox and the details of fonts so feel free to
>> start at the beginning and drive slowly. :)
> Have a look at [1], but be aware that the link will change, as our overhauled
> website will go live in a few days.
>
>> Thanks,
>> Buzzy
>
> BR
> Andreas Lehmkühler
> [1] http://pdfbox.apache.org/userguide/cookbook.html
>
--
Eliot Kimber
Senior Solutions Architect, RSI Content Solutions
"Bringing Strategy, Content, and Technology Together"
Main: 512.554.9368
www.rsicms.com
www.rsuitecms.com
Book: DITA For Practitioners, from XML Press,
http://xmlpress.net/publications/dita/practitioners-1/
Re: Subscript/Superscripts
Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,
Am 09.05.2013 02:06, schrieb Buzzy Spain:
> Hi all,
>
> I need to add text to a pdf that includes a number of superscript and
> subscript characters. Is there a "right" way to do this? My assumption is
> that drawing the string at some location and then drawing the
> super/subscript at a reduced point size offset up or down is not best
> practice. It will certainly be a pain...
The PDF format doesn't have any concept of formatted text. So your description
is exactly what you have to do.
> The data I have is coming from a java String (UTF-16). The String literal
> is being saved with an IDE that probably saves in a less preserving format
> (UTF-8?). I can change the data source if it makes my life easier.
>
> I am new to the world of PDFBox and the details of fonts so feel free to
> start at the beginning and drive slowly. :)
Have a look at [1], but be aware that the link will change, as our overhauled
website will go live in a few days.
> Thanks,
> Buzzy
BR
Andreas Lehmkühler
[1] http://pdfbox.apache.org/userguide/cookbook.html
Re: Subscript/Superscripts
Posted by Peter Murray-Rust <pm...@cam.ac.uk>.
As already mentioned you have to do the layout yourself. I have been doing
the reverse - interpreting sub/superscripts which gives some idea of the
relative font sizes, the changes in y and x coordinates, etc. Some people
put a lot of effort into this (e.g. in maths, where considerable kerning is
often practised).
Is it possible that using Unicode sub and superscripts (
http://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts ) might
give a quick solution? I don't like this myself because they would not be
easily searchable.
On Thu, May 9, 2013 at 1:06 AM, Buzzy Spain <bs...@heartflow.com> wrote:
> Hi all,
>
> I need to add text to a pdf that includes a number of superscript and
> subscript characters. Is there a "right" way to do this? My assumption is
> that drawing the string at some location and then drawing the
> super/subscript at a reduced point size offset up or down is not best
> practice. It will certainly be a pain...
>
> The data I have is coming from a java String (UTF-16). The String literal
> is being saved with an IDE that probably saves in a less preserving format
> (UTF-8?). I can change the data source if it makes my life easier.
>
> I am new to the world of PDFBox and the details of fonts so feel free to
> start at the beginning and drive slowly. :)
>
> Thanks,
> Buzzy
>
--
Peter Murray-Rust
Reader in Molecular Informatics
Unilever Centre, Dep. Of Chemistry
University of Cambridge
CB2 1EW, UK
+44-1223-763069