You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Clay Leeds <cl...@medata.com> on 2004/09/17 21:08:30 UTC

Barcodes in FO output using a font

I need to add a barcode to my fo:region-after. If this were a static 
barcode (i.e., one barcode per document), I would be just use 
Barcode4J[1]. But since part of the barcode indicates the current page 
number (d'oh!), I don't believe I can use Barcode4J for this purpose 
(Jeremias, please correct me if I'm wrong :-D). I believe this means I 
need to apply a barcode *font* to a <fo:page-number/> element. Unless 
there's a way to dynamically feed <fo:page-number/> to Barcode4J (which 
I don't think is possible), I think I'll have to use a font like this:

<fo:block 
font-family="barcode_font">F62P<fo:page-number/>-0704</fo:block>

(I have to admit, that I haven't tried with Barcode4J yet, but it's 
downloading now!)

On the FONT front, was anyone successfully used barcode fonts with FOP? 
Where can I obtain barcode fonts? I found a link[2] and I'll try some 
of the files there.

UPDATE: I've been trying, but I'm getting errors ('[ERROR] unknown font 
Code128JK_A,normal,normal so defaulted font to any' or '[ERROR] unknown 
font FREE3OF9,normal,normal so defaulted font to any', depending on the 
FONT I'm trying to use). I downloaded a barcode font from here[3], and 
followed the instructions on the FOP Font Page[4].

Here's the relevant portion of my conf/userconfig.xml file:

<entry>
   <key>fontBaseDir</key>
   <value>/Users/Shared/_WebDLs/barcode_fonts</value>
</entry>

<fonts>
<!-- snipped commented section(s) -->
  <font metrics-file="A8______.XML" 
embed-file="barfonts/pfb/A8______.pfm" kerning="yes">
     <font-triplet name="Code128JK_A" style="normal" weight="normal"/>
  </font>
  <font metrics-file="FREE3OF9.XML" embed-file="free3of9/FREE3OF9.TTF" 
kerning="yes">
     <font-triplet name="FREE3OF9" style="normal" weight="normal"/>
  </font>
</fonts>

This is the relevant XSL-FO for using the PFM:

<fo:block 
font-family="Code128JK_A">F62P<fo:page-number/>-0704</fo:block>

Since I was having trouble using the PostScript font, I tried using 
TTF. This is the relevant XSL-FO for using the TTF:

<fo:block font-family="FREE3OF9">F62P<fo:page-number/>-0704</fo:block>

Please let me know if I need to provide any other info.

Web Maestro Clay

[1] Barcode4J
http://barcode4j.krysalis.org/

[2] GPL Barcode fonts
http://user.it.uu.se/~jan/barfonts/

[3] Free 3of9 Barcode font
http://www.squaregear.net/fonts/free3of9.shtml

[4] FOP Fonts Page
http://xml.apache.org/fop/fonts.html


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: Barcodes in FO output using a font

Posted by Clay Leeds <cl...@medata.com>.
On Sep 17, 2004, at 12:57 PM, Jeremias Maerki wrote:
> On 17.09.2004 21:08:30 Clay Leeds wrote:
>> On the FONT front, was anyone successfully used barcode fonts with 
>> FOP?
>> Where can I obtain barcode fonts? I found a link[2] and I'll try some
>> of the files there.
>
> I've tried both 3 of 9 fonts from [2] and [3] and the Code128 font from
> [2]. All work fine, although the TTF font causes two warnings because 
> of
> missing TTF tables.

Works for me now, see below...

>> UPDATE: I've been trying, but I'm getting errors ('[ERROR] unknown 
>> font
>> Code128JK_A,normal,normal so defaulted font to any' or '[ERROR] 
>> unknown
>> font FREE3OF9,normal,normal so defaulted font to any', depending on 
>> the
>> FONT I'm trying to use). I downloaded a barcode font from here[3], and
>> followed the instructions on the FOP Font Page[4].
>>
>> Here's the relevant portion of my conf/userconfig.xml file:
>>
>> <entry>
>>    <key>fontBaseDir</key>
>>    <value>/Users/Shared/_WebDLs/barcode_fonts</value>
>> </entry>
>>
>> <fonts>
>> <!-- snipped commented section(s) -->
>>   <font RENAME_FILE_TO_USE_metrics-file="A8______.XML"
>> embed-file="barfonts/pfb/A8______.pfm" kerning="yes">
>
> embed-file takes the PFB, not the PFM!!! The PFM is only for generating
> the font metrics XML. The PFB contains the actual font.

Thanks! I didn't know which part I needed to include there. Now that I 
look back at the Fonts page, there is an example which has .pfb. Sorry.

> It doesn't make a big difference but set kerning to "no".

Done!

>>      <font-triplet name="Code128JK_A" style="normal" weight="normal"/>
>>   </font>
>>   <font RENAME_FILE_TO_USE_metrics-file="FREE3OF9.XML" 
>> RENAME_FILE_TO_USE_embed-file="free3of9/FREE3OF9.TTF"
>> kerning="yes">
>>      <font-triplet name="FREE3OF9" style="normal" weight="normal"/>
>>   </font>
>> </fonts>
>>
>> This is the relevant XSL-FO for using the PFM:
>>
>> <fo:block
>> font-family="Code128JK_A">F62P<fo:page-number/>-0704</fo:block>
>
> Works for me.
>>
>> Since I was having trouble using the PostScript font, I tried using
>> TTF. This is the relevant XSL-FO for using the TTF:
>>
>> <fo:block font-family="FREE3OF9">F62P<fo:page-number/>-0704</fo:block>
>>
>> Please let me know if I need to provide any other info.
>
> Dumb question: Have you supplied the userconfig.xml on the 
> command-line?
> That's my only explanation for your problem. If I omit the
> userconfig.xml I get your error messages. Besides that I've done 
> nothing
> special while generating the XML metrics. I've used practically the 
> same
> configuration (including fontBaseDir). I've even copied snippets from
> your e-mail to reproduce the problems.
>
> Jeremias Maerki

That was the culprit, so I guess it wasn't a dumb question. It was me 
being dumb not including the config file. My only 'excuse' is to say 
that I've never had to use a config file before now (although I'll be 
using it in the future to play with strokeSVGText...)

Thanks Jeremias!

Web Maestro Clay


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: Barcodes in FO output using a font

Posted by Jeremias Maerki <de...@greenmail.ch>.
On 17.09.2004 21:08:30 Clay Leeds wrote:
> I need to add a barcode to my fo:region-after. If this were a static 
> barcode (i.e., one barcode per document), I would be just use 
> Barcode4J[1]. But since part of the barcode indicates the current page 
> number (d'oh!), I don't believe I can use Barcode4J for this purpose 
> (Jeremias, please correct me if I'm wrong :-D).

No, you can't. The FOP extension doesn't have access to the page number
ATM.

> I believe this means I 
> need to apply a barcode *font* to a <fo:page-number/> element. Unless 
> there's a way to dynamically feed <fo:page-number/> to Barcode4J (which 
> I don't think is possible), I think I'll have to use a font like this:
> 
> <fo:block 
> font-family="barcode_font">F62P<fo:page-number/>-0704</fo:block>
> 
> (I have to admit, that I haven't tried with Barcode4J yet, but it's 
> downloading now!)
> 
> On the FONT front, was anyone successfully used barcode fonts with FOP? 
> Where can I obtain barcode fonts? I found a link[2] and I'll try some 
> of the files there.

I've tried both 3 of 9 fonts from [2] and [3] and the Code128 font from
[2]. All work fine, although the TTF font causes two warnings because of
missing TTF tables.

> UPDATE: I've been trying, but I'm getting errors ('[ERROR] unknown font 
> Code128JK_A,normal,normal so defaulted font to any' or '[ERROR] unknown 
> font FREE3OF9,normal,normal so defaulted font to any', depending on the 
> FONT I'm trying to use). I downloaded a barcode font from here[3], and 
> followed the instructions on the FOP Font Page[4].
> 
> Here's the relevant portion of my conf/userconfig.xml file:
> 
> <entry>
>    <key>fontBaseDir</key>
>    <value>/Users/Shared/_WebDLs/barcode_fonts</value>
> </entry>
> 
> <fonts>
> <!-- snipped commented section(s) -->
>   <font metrics-file="A8______.XML" 
> embed-file="barfonts/pfb/A8______.pfm" kerning="yes">

embed-file takes the PFB, not the PFM!!! The PFM is only for generating
the font metrics XML. The PFB contains the actual font.

It doesn't make a big difference but set kerning to "no".

>      <font-triplet name="Code128JK_A" style="normal" weight="normal"/>
>   </font>
>   <font metrics-file="FREE3OF9.XML" embed-file="free3of9/FREE3OF9.TTF" 
> kerning="yes">
>      <font-triplet name="FREE3OF9" style="normal" weight="normal"/>
>   </font>
> </fonts>
> 
> This is the relevant XSL-FO for using the PFM:
> 
> <fo:block 
> font-family="Code128JK_A">F62P<fo:page-number/>-0704</fo:block>

Works for me.
> 
> Since I was having trouble using the PostScript font, I tried using 
> TTF. This is the relevant XSL-FO for using the TTF:
> 
> <fo:block font-family="FREE3OF9">F62P<fo:page-number/>-0704</fo:block>
> 
> Please let me know if I need to provide any other info.

Dumb question: Have you supplied the userconfig.xml on the command-line?
That's my only explanation for your problem. If I omit the
userconfig.xml I get your error messages. Besides that I've done nothing
special while generating the XML metrics. I've used practically the same
configuration (including fontBaseDir). I've even copied snippets from
your e-mail to reproduce the problems.

Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org