allcolor / YaHP-Converter

YaHP is a Java library that allows you to convert an HTML document into a PDF document.
GNU Lesser General Public License v2.1
56 stars 23 forks source link

unable to locate fonts #28

Closed ravieze closed 9 years ago

ravieze commented 9 years ago

hi,

i m trying to load fonts from a folder in jar file. SO this is what i m doing..

    URL url = getClass().getClassLoader().getResource(templateName); 
    int lastIndex = url.toString().lastIndexOf("/");
    String rootFolder = url.toString().substring(0, lastIndex);
    properties.put(IHtmlToPdfTransformer.FOP_TTF_FONT_PATH, rootFolder + "/fonts/");
            converter.convertToPdf( html.toString(),
                            new IHtmlToPdfTransformer.PageSize(21, 29.5, 1, 1, 1.5, 1.2),
                            headerFooterList,
                            rootFolder + "/fonts/",
                            out,
                            properties);

the rootFolder is resolving to: vfszip:/C:/inst/JBoss/5.1.0.GA/server/default/deploy/abc.ear/lib/core.jar in run time. (our ear files donot explode in runtime).

Now we are unable to locate fonts from the fonts folder which is in a jar file.

if i have the folder in file system its working fine.. but how can i refer it from a jar file?

allcolor commented 9 years ago

That doesn't work, the folder must be a real folder (accessible via java.io.File).

2014-11-24 16:12 GMT+01:00 ravieze notifications@github.com:

hi,

i m trying to load fonts from a folder in jar file. SO this is what i m doing..

URL url = getClass().getClassLoader().getResource(templateName);
int lastIndex = url.toString().lastIndexOf("/");
String rootFolder = url.toString().substring(0, lastIndex);
properties.put(IHtmlToPdfTransformer.FOP_TTF_FONT_PATH, rootFolder + "/fonts/");
        converter.convertToPdf( html.toString(),
                        new IHtmlToPdfTransformer.PageSize(21, 29.5, 1, 1, 1.5, 1.2),
                        headerFooterList,
                        rootFolder + "/fonts/",
                        out,
                        properties);

the rootFolder is resolving to: vfszip:/C:/inst/JBoss/ 5.1.0.GA/server/default/deploy/abc.ear/lib/core.jar in run time. (our ear files donot explode in runtime).

Now we are unable to locate fonts from the fonts folder which is in a jar file.

if i have the folder in file system its working fine.. but how can i refer it from a jar file?

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/28.

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)