[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 <br>/fonts/times/C0FT0008<br><br>Then I generate .fo \
files like that:<br>ARIAL: <fo:block font-family="arial" font-style="normal" \
font-size="8" font-weight="normal">Arial 8</fo:block><br>TIMES: \
<fo:block font-family="times" font-style="normal" font-size="8" \
font-weight="normal">Arial 8</fo:block><br><br>And \
xconf:<br>ARIAL:<br><afp-font name="arial" type="raster" codepage="T1001250" \
encoding="Cp1250" embed-url="/fonts-encoded/arial/"><br><afp-raster-font \
size="8" characterset="C0FT0008"/><br><br>TIMES:<br><afp-font name="times" \
type="raster" codepage="T1001250" encoding="Cp1250" \
embed-url="/fonts-encoded/times/"><br><afp-raster-font size="8" \
characterset="C0FT0008"/><br><br><br>Then generate two afps with a for \
loop:<br>try{<br> fop_factory = FopFactory.newInstance();<br> \
fop_factory.setUserConfig(config);<br> bw = new BufferedOutputStream(new \
FileOutputStream(new File(out_file)));<br> fop = \
fop_factory.newFop(MimeConstants.MIME_AFP, bw);<br> transformer_factory = \
TransformerFactory.newInstance();<br> transformer = \
transformer_factory.newTransformer();<br> fo_file = new StreamSource(new \
InputStreamReader(new FileInputStream(fo_file_name), "UTF-8"));<br> res_file = \
new SAXResult(fop.getDefaultHandler());<br><div><span> \
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;"> } 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;"> 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;"> 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;"> 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;"> } 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 \
<fixitf3lix@yahoo.it><br> <b><span style="font-weight: bold;">A:</span></b> \
"fop-users@xmlgraphics.apache.org" <fop-users@xmlgraphics.apache.org> <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><fo:block \
font-family="GalaxiePolarisCondensed-Light-T1001250" font-style="normal" \
font-size="6" font-weight="normal">GalaxiePolarisCondensed-Light \
6</fo:block><br><br>here's an exctract from my .xconf:<br><renderer \
mime="application/x-afp"><br> <images mode="b+w" \
bits-per-pixel="8"/><br> \
<renderer-resolution>240</renderer-resolution><br> \
<line-width-correction>2.5</line-width-correction><br> \
<fonts><br><font><br><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/"><br><afp-raster-font \
size="6" characterset="C0FT0006"/><br></afp-font><br><font-triplet \
name="GalaxiePolarisCondensed-Light-T1001250" style="normal" \
weight="normal"/><br><font-triplet name="any" style="normal" \
weight="normal"/><br></font><br></fonts><br></renderer><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