xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arian <armyofda12mnk...@gmail.com>
Subject Re: how to embed fonts via java, using fop trunk
Date Thu, 25 Mar 2010 21:07:52 GMT
Reopening this thread... curious if anyone could help...

I've made a simple java app (using FOP Trunk), and I point to a relative
location where my .xml config file is...
So in c:/dev/eclipse-workspace/pdf_project_test/, i have:

xml_xsl_files/            (where i load the xml and xsl files to form the
xml_xsl_files/images/ (for the xsl files images)
fonts/                        (for the ttf fonts the .fo file refers to)
images/                    (i had to copy the images folder here, more info
on this later)
bin/                          (Eclipse .java/.class files for the project)


fopFactory.setUserConfig("config/user_config.xml"); //config file in the
c:/dev/eclipse-workspace/pdf_project_test/config folder

This works, however i point to abs dir that xml...
I changed the xml to point relatively in the folder via:
   <font-base>.</font-base> <!-- not needed it seems, but added it -->
                <directory recursive="true">fonts</directory> <!-- points
relatively now, was set to c:/dev/eclipse-workspace/pdf_project_test/fonts
before -->
This now works ... But I dont want to use a .xml config file. I just want to
point to the fonts folder, (but I couldnt get that to work, hence why I went
the config file route above)?
Ive tried this relative path to no avail:

        FOUserAgent userAgent = fopFactory.newFOUserAgent();
//? not sure if explicitly needed since .java is in that dir, but i tried
all combos i thought might be needed
        fopFactory.getFontManager().setFontBaseURL( "./fonts/" );

I've even tried abs paths like: fopFactory.getFontManager().setFontBaseURL(
"c:/dev/eclipse-workspace/pdf_project_test/fonts/" );
and various combos in there like
"file:///c:/dev/eclipse-workspace/pdf_project_test/fonts/". Again didnt
What kind of file uri's will resolve (just testing on windows for now) and
what is it relative too, the xsl file or the .java file?

A 2nd related question: I figured the .xsl file, which lies in
xml_xsl_files/... i got errors about the image locations, so the image
filepaths werent looking relative to the .xsl file but to the eclipse
projects location. So I had to move images/ out of xsl/ and into
pdf_project_test/. Not sure if this also is best solution, or can feed an
arg to make the xsl look in its own directory.

Thanks for any help on file paths,
PS I did read a few threads I saw but none worked for the setFontBaseURL
(one guy claimed the abs filepaths worked, and i used the same filepath
string structure he used (with "file:///c:/to/my/fonts/") but didnt work),
Lates... I can attach code later if needed as its only 75 lines long,

View raw message