M
M
MaxLich2018-03-05 09:53:43
Java
MaxLich, 2018-03-05 09:53:43

How to write paths to fonts and images in JasperReports template files?

Hello. It is necessary to implement the creation and saving of reports in the program. At the moment, a self-written implementation is used. I want to replace it with JasperReports. The report template was compiled, everything seems to be fine, but there is a problem with fonts and pictures. The module responsible for the graphical interface is pulled up separately for me. Actually, everything is in it. I import it as a jar-nick (via gradle, pull from local maven repository). I also tried to place fonts in the resources of the GUI module and in a separate folder of the final project (which is used to build the running application - AWP). The path also tried to prescribe differently: "../config/font/ARIAL.TTF", "./config/font/ARIAL.TTF", "config/font/ARIAL.TTF", "./font/ARIAL. TTF". Folder "config"
The whole tag I use to change the font looks like this:

<style name="Default" isDefault="true" pdfFontName="../config/font/ARIAL.TTF" pdfEncoding="Cp1251"/>

I haven't gotten to the pictures yet, but I think it's the same there. But you can still somehow do without them, but you can’t do without fonts.
PS In another, test project, the path is written like this: "./ARIAL.TTF", and the font file is located in the root of the resource folder. And everything works. Apparently, the problem is due to the fact that I take everything from the jar, and not directly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxLich, 2018-03-05
@MaxLich

This path helped: "config/font/ARIAL.TTF", however, the file is located in the main project, which is not very logical and convenient. But in that folder there was already some kind of font, which means that this is already being practiced (the project is not mine, I came to such a one).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question