Hi all!
Documentation says that you have to do this to include the configuration file in the program:
----
import org.apache.fop.apps.Options;
/*..*/
userConfigFile = new File(userConfig);
options = new Options(userConfigFile);
----
On java FOP 0.20.5 but this does not exists on NFOP.
Would it be difficult to port?
I need this in order to generate barcodes. I need to add a new font to the userconfig and the application is embedded into mine. So need to load the configuration.
Is there any workaound?
Thank you
Logged In: YES
user_id=973000
Originator: NO
--------
org.apache.fop.configuration.ConfigurationReader reader = new org.apache.fop.configuration.ConfigurationReader(
new org.xml.sax.InputSource(new java.io.FileInputStream("userconfig.xml")));
reader.start();
--------
This code should be executed only once (on application startup, for example).
Logged In: NO
I'm getting error with this...
"No se puede continuar: Le format du chemin d'accès donné n'est pas pris en charge."
It's a mix of spanish an french, sorry:
"The format of the path of access is not supported"
I tried some and does not work...
-----------------------------------
<configuration>
<fonts>
<font metrics-file="file://BARCODE12.xml"
kerning="yes"
embed-file="file://c:/Windows/fonts/N01BC12M.TTF">
<font-triplet name="Barcode12" style="normal" weight="normal"/>
</font>
</fonts>
</configuration>
Logged In: YES
user_id=973000
Originator: NO
Try this:
---------------
<font metrics-file="file://C:\App\fonts\arial.xml" kerning="yes"
embed-file="file://C:\Windows\Fonts\arial.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
</font>
---------------
or (if "arial.xml" is stored in the same dir, where userconfig.xml):
---------------
<font metrics-file="arial.xml" kerning="yes"
embed-file="file://C:\Windows\Fonts\arial.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
</font>
---------------
Logged In: NO
Ok man. But this does not work...
The user config is loaded correctly but inside userconfig.xml fails on:
metrics-file="file:///BARCODE12.xml"
with:
----------------------------------
building formatting object tree
setting up fonts
'Prueba1.4.exe' : chargé 'c:\windows\assembly\gac\mscorlib.resources\1.0.5000.0_fr_b77a5c561934e089\mscorlib.resources.dll', aucun symbole chargé.
No se puede continuar: Le format du chemin d'accès donné n'est pas pris en charge.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[] str, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOAccess.AddExpressions(String[] value, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
at java.io.File.getAbsolutePath()
at java.io.File.getCanonicalPath()
at java.io.File..ctor(String dirPath, String name)
at java.io.File..ctor(String path)
at org.apache.fop.tools.URLBuilder.buildURL(String spec) in C:\work\alex\nfop\tools\URLBuilder.java:line 76
at org.apache.fop.tools.URLBuilder.buildURL(URL baseURL, String spec) in C:\work\alex\nfop\tools\URLBuilder.java:line 98
at org.apache.fop.configuration.FontInfo.getMetricsFile() in C:\work\alex\nfop\configuration\FontInfo.java:line 85
at org.apache.fop.render.pdf.FontSetup.addConfiguredFonts(FontInfo fontInfo, Int32 num) in C:\work\alex\nfop\render\pdf\FontSetup.java:line 201
at org.apache.fop.render.pdf.FontSetup.setup(FontInfo fontInfo) in C:\work\alex\nfop\render\pdf\FontSetup.java:line 179
at org.apache.fop.render.PrintRenderer.setupFontInfo(FontInfo fontInfo) in C:\work\alex\nfop\render\PrintRenderer.java:line 447
at org.apache.fop.apps.StreamRenderer.startRenderer() in C:\work\alex\nfop\apps\StreamRenderer.java:line 187
at org.apache.fop.fo.FOTreeBuilder.startDocument() in C:\work\alex\nfop\fo\FOTreeBuilder.java:line 240
at org.apache.xerces.parsers.AbstractSAXParser.startDocument(XMLLocator locator, String encoding, Augmentations augs) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\parsers\AbstractSAXParser.java:line 275
at org.apache.xerces.impl.XMLNamespaceBinder.startDocument(XMLLocator locator, String encoding, Augmentations augs) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\impl\XMLNamespaceBinder.java:line 444
at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(XMLLocator locator, String encoding, Augmentations augs) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\impl\dtd\XMLDTDValidator.java:line 644
at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(String name, XMLResourceIdentifier identifier, String encoding) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\impl\XMLDocumentScannerImpl.java:line 431
at org.apache.xerces.impl.XMLEntityManager.startEntity(String name, XMLInputSource xmlInputSource, Boolean literal, Boolean isExternal) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\impl\XMLEntityManager.java:line 878
at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLInputSource xmlInputSource) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\impl\XMLEntityManager.java:line 741
at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLInputSource inputSource) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\impl\XMLDocumentScannerImpl.java:line 260
at org.apache.xerces.parsers.DTDConfiguration.parse(Boolean complete) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\parsers\DTDConfiguration.java:line 498
at org.apache.xerces.parsers.DTDConfiguration.parse(XMLInputSource source) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\parsers\DTDConfiguration.java:line 580
at org.apache.xerces.parsers.XMLParser.parse(XMLInputSource inputSource) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\parsers\XMLParser.java:line 152
at org.apache.xerces.parsers.AbstractSAXParser.parse(InputSource inputSource) in C:\work\alex\nfop\xerces-2_0_2\src\org\apache\xerces\parsers\AbstractSAXParser.java:line 1169
at org.apache.fop.apps.Driver.render(XMLReader parser, InputSource source) in C:\work\alex\nfop\apps\Driver.java:line 504
at org.apache.fop.apps.Driver.run() in C:\work\alex\nfop\apps\Driver.java:line 582
at Prueba1._4.Form1.GeneratePDF(String foFile, String pdfFile) in C:\Documents and Settings\gaguilar\Bureau\Prueba1.4\Form1.vb:line 110
at Prueba1._4.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\gaguilar\Bureau\Prueba1.4\Form1.vb:line 95
---------------
Any clue on this?
Logged In: NO
And If I use relative paths it complains saying (none protocol used)
Logged In: NO
This is what happens using relative paths...
----
Failed to read a font metrics file: Invalid font metrics file: BARCODE12.xml (aucun protocole)
----
===Failed to read a font metrics file: Invalid font metrics file: BARCODE12.xml (none protocol)
Logged In: YES
user_id=973000
Originator: NO
>Ok man. But this does not work...
It works for me.
Probably you have a wrong config or another version of j#-runtime.
Send me your userconfig.xml, BARCODE12.xml and N01BC12M.TTF.ttf on hugbug@public-files.de.
I'll check it out.
Logged In: NO
The problem is at buildURL:
----
if (spec == null) throw new NullPointerException("spec must not be null");
File f = new File(spec);
if (f.exists()) {
return new URL(f.toString());
} else {
URL u1 = new URL(spec);
return u1;
}
----
if at file you use a ftp:// or http:// it fails because can't open the file with the protocol
if you don't use it, it fails at URL(f.toString()) because can't construct the URL without the protocol
I can send you the complete project if you want but I touched the paths so you must touch the xmls
Logged In: NO
Setting it as:
if (spec == null) throw new NullPointerException("spec must not be null");
File f = new File(spec);
if (f.exists()) {
return new URL("file://" + f.toString());
} else {
URL u1 = new URL(spec);
return u1;
}
Works but it's not ideal solution...
Logged In: YES
user_id=973000
Originator: NO
Relative paths actually do not work. I forget to add, that I set the variable "fontBaseDir" in the config-file, if I use font-filenames without paths:
------------
<configuration>
<entry>
<key>fontBaseDir</key>
<value>file://C:\app\fonts\</value>
</entry>
<fonts>
<font metrics-file="arial.xml" kerning="yes">
<font-triplet name="Arial" style="normal" weight="normal"/>
</font>
</fonts>
</configuration>
-----------
The good news is that the "fontBaseDir"-variable can be set at run-time:
----------
ConfigurationReader reader = new ConfigurationReader(
new InputSource(new java.io.FileInputStream(Path.Combine(nFopConfigDir, "userconfig.xml"))));
reader.start();
if (Configuration.getBaseURL() == null)
{
Configuration.put("baseDir", "file://" + nFopConfigDir + "\\");
}
----------
In this example I use "baseDir" instead of "baseFontDir". If "baseDir" set and "baseFontDir" is not, the "baseDir" is used for fonts also. You can set both variables, if you need them to have different values.