[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fop-user
Subject:    Re: embedding fop in java and create afp
From:       Francesco Nigro <fixitf3lix () yahoo ! it>
Date:       2013-04-12 15:19:00
Message-ID: 1365779940.27347.YahooMailNeo () web172303 ! mail ! ir2 ! yahoo ! com
[Download RAW message or body]

Hi,
is allowed to use different fonts, saved in different folders, but with the same \
name? I generate few afps with a for loop and the first has the right font, the other \
ones always use the first font.

For example I use times and arial, size 8;
font files are saved as 
/fonts/arial/C0FT0008  
/fonts/times/C0FT0008

Then I generate .fo files like that:
ARIAL:  <fo:block font-family="arial" font-style="normal" font-size="8" \
                font-weight="normal">Arial 8</fo:block>
TIMES:  <fo:block font-family="times" font-style="normal" font-size="8" \
font-weight="normal">Arial 8</fo:block>

And xconf:
ARIAL:
<afp-font name="arial" type="raster" codepage="T1001250" encoding="Cp1250" \
embed-url="/fonts-encoded/arial/"> <afp-raster-font size="8" \
characterset="C0FT0008"/>

TIMES:
<afp-font name="times" type="raster" codepage="T1001250" encoding="Cp1250" \
embed-url="/fonts-encoded/times/"> <afp-raster-font size="8" \
characterset="C0FT0008"/>


Then generate two afps with a for loop:
try{
  fop_factory = FopFactory.newInstance();
  fop_factory.setUserConfig(config);
  bw = new BufferedOutputStream(new FileOutputStream(new File(out_file)));
  fop = fop_factory.newFop(MimeConstants.MIME_AFP, bw);
  transformer_factory = TransformerFactory.newInstance();
  transformer = transformer_factory.newTransformer();
  fo_file = new StreamSource(new InputStreamReader(new FileInputStream(fo_file_name), \
"UTF-8"));  res_file = new SAXResult(fop.getDefaultHandler());

  transformer.transform(fo_file, res_file);
} catch(Exception e) {
 } finally {
    try {
      bw.flush();
      bw.close();
    } catch (Exception e) { }
}




What am I doing wrong?


Thank you very much






________________________________
 Da: Francesco Nigro <fixitf3lix@yahoo.it>
A: "fop-users@xmlgraphics.apache.org" <fop-users@xmlgraphics.apache.org> 
Inviato: Mercoledì 3 Aprile 2013 17:12
Oggetto: embedding fop in java and create afp
 


Hi all,
I've embedded fop 1.1 in my java program following this guide:
http://xmlgraphics.apache.org/fop/1.1/embedding.html

Everything is working and I don't have compile/runtime errors but afp files don't use \
the fonts configured, the same font is always displayed. If I use the binary \
distribution of fop (fop.bat) the afp files generated are correct, so the .fo file, \
.xconf and also fonts are valid.

PDFs are perfect, the issue is just with AFP.


here's an exctract from my .fo:
<fo:block font-family="GalaxiePolarisCondensed-Light-T1001250" font-style="normal" \
font-size="6" font-weight="normal">GalaxiePolarisCondensed-Light 6</fo:block>

here's an exctract from my .xconf:
<renderer mime="application/x-afp">
  <images mode="b+w"
 bits-per-pixel="8"/>
  <renderer-resolution>240</renderer-resolution>
  <line-width-correction>2.5</line-width-correction>
  <fonts>
<font>
<afp-font name="GalaxiePolarisCondensed-Light-T1001250" type="raster" \
codepage="T1001250" encoding="Cp1250" \
base-uri="../../data/fonts-encoded/GalaxiePolarisCondensed-Light-T1001250/" \
embed-url="../../data/fonts-encoded/GalaxiePolarisCondensed-Light-T1001250/"> \
<afp-raster-font size="6" characterset="C0FT0006"/> </afp-font>
<font-triplet name="GalaxiePolarisCondensed-Light-T1001250" style="normal" \
weight="normal"/> <font-triplet name="any" style="normal" weight="normal"/>
</font>
</fonts>
</renderer>


The steps to create the afp are always the same:
config_builder = new DefaultConfigurationBuilder();
config = config_builder.buildFromFile(new
 File(my_conf_file));
fop_factory = FopFactory.newInstance();
fop_factory.setUserConfig(config);
bw = new BufferedOutputStream(new FileOutputStream(new File(out_afp_file)));
fop = fop_factory.newFop("application/x-afp", bw);
transformer_factory = TransformerFactory.newInstance();
transformer = transformer_factory.newTransformer();
fo_file = new StreamSource(new InputStreamReader(new FileInputStream(in_fo_file), \
"UTF-8")); res_file = new SAXResult(fop.getDefaultHandler());
transformer.transform(fo_file, res_file);


I can't figure out what's wrong; can you point me in the right direction?

Thank you very much,
F.


[Attachment #3 (text/html)]

<html><body><div style="color:#000; background-color:#fff; font-family:times new \
roman, new york, times, serif;font-size:12pt">Hi,<br>is allowed to use different \
fonts, saved in different folders, but with the same name?<br>I generate few afps \
with a for loop and the first has the right font, the other ones always use the first \
font.<br><br>For example I use times and arial, size 8;<br>font files are saved as \
<br>/fonts/arial/C0FT0008&nbsp; <br>/fonts/times/C0FT0008<br><br>Then I generate .fo \
files like that:<br>ARIAL:&nbsp; &lt;fo:block font-family="arial" font-style="normal" \
font-size="8" font-weight="normal"&gt;Arial 8&lt;/fo:block&gt;<br>TIMES:  \
&lt;fo:block font-family="times" font-style="normal" font-size="8" \
font-weight="normal"&gt;Arial 8&lt;/fo:block&gt;<br><br>And \
xconf:<br>ARIAL:<br>&lt;afp-font name="arial" type="raster" codepage="T1001250" \
encoding="Cp1250" embed-url="/fonts-encoded/arial/"&gt;<br>&lt;afp-raster-font \
size="8"  characterset="C0FT0008"/&gt;<br><br>TIMES:<br>&lt;afp-font name="times" \
type="raster" codepage="T1001250" encoding="Cp1250" \
embed-url="/fonts-encoded/times/"&gt;<br>&lt;afp-raster-font size="8" \
characterset="C0FT0008"/&gt;<br><br><br>Then generate two afps with a for \
loop:<br>try{<br>&nbsp; fop_factory = FopFactory.newInstance();<br>&nbsp; \
fop_factory.setUserConfig(config);<br>&nbsp; bw = new BufferedOutputStream(new \
FileOutputStream(new File(out_file)));<br>&nbsp; fop = \
fop_factory.newFop(MimeConstants.MIME_AFP, bw);<br>&nbsp; transformer_factory = \
TransformerFactory.newInstance();<br>&nbsp; transformer = \
transformer_factory.newTransformer();<br>&nbsp; fo_file = new StreamSource(new \
InputStreamReader(new FileInputStream(fo_file_name), "UTF-8"));<br>&nbsp; res_file = \
new SAXResult(fop.getDefaultHandler());<br><div><span>&nbsp; \
transformer.transform(fo_file, res_file);</span></div><div style="color: rgb(0, 0, \
0); font-size: 16px; font-family: times new  roman,new york,times,serif; \
background-color: transparent; font-style: normal;">} catch(Exception e) {</div><div \
style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new \
york,times,serif; background-color: transparent; font-style: normal;">&nbsp;} finally \
{</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new \
roman,new york,times,serif; background-color: transparent; font-style: \
normal;">&nbsp; &nbsp; try {</div><div style="color: rgb(0, 0, 0); font-size: 16px; \
font-family: times new roman,new york,times,serif; background-color: transparent; \
font-style: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bw.flush();</div><div \
style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new \
york,times,serif; background-color: transparent; font-style: \
normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bw.close();</div><div style="color: rgb(0, 0, \
0); font-size: 16px; font-family: times new roman,new york,times,serif;  \
background-color: transparent; font-style: normal;">&nbsp;&nbsp;&nbsp; } catch \
(Exception e) { }</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: \
times new roman,new york,times,serif; background-color: transparent; font-style: \
normal;">}<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: \
times new roman,new york,times,serif; background-color: transparent; font-style: \
normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: \
times new roman,new york,times,serif; background-color: transparent; font-style: \
normal;"><br></div><br><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: \
times new roman,new york,times,serif; background-color: transparent; font-style: \
normal;">What am I doing wrong?</div><div style="color: rgb(0, 0, 0); font-size: \
16px; font-family: times new roman,new york,times,serif; background-color: \
transparent; font-style: normal;"><br></div><div style="color: rgb(0,  0, 0); \
font-size: 16px; font-family: times new roman,new york,times,serif; background-color: \
transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); \
font-size: 16px; font-family: times new roman,new york,times,serif; background-color: \
transparent; font-style: normal;">Thank you very much<br><span></span></div><div \
style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new \
york,times,serif; background-color: transparent; font-style: \
normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; \
font-family: times new roman,new york,times,serif; background-color: transparent; \
font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); \
font-size: 16px; font-family: times new roman,new york,times,serif; background-color: \
transparent; font-style: normal;"><span><br></span></div><div><br></div>  <div \
style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div  \
style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div \
dir="ltr"> <hr size="1">  <font face="Arial" size="2"> <b><span \
style="font-weight:bold;">Da:</span></b> Francesco Nigro \
&lt;fixitf3lix@yahoo.it&gt;<br> <b><span style="font-weight: bold;">A:</span></b> \
"fop-users@xmlgraphics.apache.org" &lt;fop-users@xmlgraphics.apache.org&gt; <br> \
<b><span style="font-weight: bold;">Inviato:</span></b> Mercoledì 3 Aprile 2013 \
17:12<br> <b><span style="font-weight: bold;">Oggetto:</span></b> embedding fop in \
java and create afp<br> </font> </div> <div class="y_msg_container"><br><meta \
http-equiv="x-dns-prefetch-control" content="off"><div id="yiv548007886"><div><div \
style="color:#000;background-color:#fff;font-family:times new roman, new york, times, \
serif;font-size:12pt;">Hi all,<br>I've embedded fop 1.1 in my java program following \
this guide:<br>http://xmlgraphics.apache.org/fop/1.1/embedding.html<br><br>Everything \
is working and I  don't have compile/runtime errors but afp files don't use the fonts \
configured, the same font is always displayed.<br>If I use the binary distribution of \
fop (fop.bat) the afp files generated are correct, so the .fo file, .xconf and also \
fonts are valid.<br><br>PDFs are perfect, the issue is just with \
AFP.<br><br><br>here's an exctract from my .fo:<br>&lt;fo:block \
font-family="GalaxiePolarisCondensed-Light-T1001250" font-style="normal" \
font-size="6" font-weight="normal"&gt;GalaxiePolarisCondensed-Light \
6&lt;/fo:block&gt;<br><br>here's an exctract from my .xconf:<br>&lt;renderer \
mime="application/x-afp"&gt;<br>&nbsp; &lt;images mode="b+w"  \
bits-per-pixel="8"/&gt;<br>&nbsp; \
&lt;renderer-resolution&gt;240&lt;/renderer-resolution&gt;<br>&nbsp; \
&lt;line-width-correction&gt;2.5&lt;/line-width-correction&gt;<br>&nbsp; \
&lt;fonts&gt;<br>&lt;font&gt;<br>&lt;afp-font \
name="GalaxiePolarisCondensed-Light-T1001250" type="raster" codepage="T1001250" \
encoding="Cp1250" base-uri="../../data/fonts-encoded/GalaxiePolarisCondensed-Light-T1001250/" \
embed-url="../../data/fonts-encoded/GalaxiePolarisCondensed-Light-T1001250/"&gt;<br>&lt;afp-raster-font \
size="6" characterset="C0FT0006"/&gt;<br>&lt;/afp-font&gt;<br>&lt;font-triplet \
name="GalaxiePolarisCondensed-Light-T1001250" style="normal" \
weight="normal"/&gt;<br>&lt;font-triplet name="any" style="normal" \
weight="normal"/&gt;<br>&lt;/font&gt;<br>&lt;/fonts&gt;<br>&lt;/renderer&gt;<br><br><br>The \
steps to create the afp are always the same:<br>config_builder = new \
DefaultConfigurationBuilder();<br>config = config_builder.buildFromFile(new  \
File(my_conf_file));<br>fop_factory = \
FopFactory.newInstance();<br>fop_factory.setUserConfig(config);<br>bw = new \
BufferedOutputStream(new FileOutputStream(new File(out_afp_file)));<br>fop = \
fop_factory.newFop("application/x-afp", bw);<br>transformer_factory = \
TransformerFactory.newInstance();<br>transformer = \
transformer_factory.newTransformer();<br>fo_file = new StreamSource(new \
InputStreamReader(new FileInputStream(in_fo_file), "UTF-8"));<br>res_file = new \
SAXResult(fop.getDefaultHandler());<br>transformer.transform(fo_file, \
res_file);<br><br><br>I can't figure out what's wrong; can you point me in the right \
direction?<br><br>Thank you very much,<br>F.<br></div></div></div><meta \
http-equiv="x-dns-prefetch-control" content="on"><br><br></div> </div> </div>  \
</div></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic