1

I have Netbeans Maven project. I have created my own fonts jar file, because Jasper Reports does not supports Cp1257. I have installed my jar to local maven repo, dependency added via add dependency. While running in Netbeans I have no problems - the reports are created with font that is declared in dependency and exported to PDF correctly, but after creating executable jar with maven assembly plugin it looks like my dependency somehow disapears or becomes unreachable, because . I see my fonts file in dependencies list of Netbeans Maven project. If you need more code or smth please let me know I will add code needed. Thanks in advance.

jasperreports_extension.properties

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory`
net.sf.jasperreports.extension.simple.font.families.ireportfamily1463309406404=fonts/fontsfamily1463309406404.xml

fontsfamily1463309406404.xml

<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
   <fontFamily name="Times New Roman">
       <normal><![CDATA[fonts/times.ttf]]></normal>
       <bold><![CDATA[fonts/timesbd.ttf]]></bold>
       <italic><![CDATA[fonts/timesbi.ttf]]></italic>
       <boldItalic><![CDATA[fonts/timesi.ttf]]></boldItalic>
       <pdfEncoding><![CDATA[Cp1257]]></pdfEncoding>
       <pdfEmbedded><![CDATA[true]]></pdfEmbedded>
   </fontFamily>
</fontFamilies>

CLASS

StyleBuilder plainStyle = DynamicReports.stl.style().setFontName("Times New Roman");

POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>MYAPPNAME</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <repositories>
</repositories>
    <dependencies>
...
<dependency>
            <groupId>my.fonts</groupId>
            <artifactId>fonts2</artifactId>
            <version>1.1</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>forms.Login</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>create-my-bundle</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>   
        </plugins>
    </build>
    <name>MYAPPNAME</name>
</project>
JavaNewbie
  • 21
  • 4
  • Does this answer your question? http://stackoverflow.com/questions/35023908/jasperreports-extension-properties-overwritten-by-maven-assembly-plugin Meaning is the `jasperreports_extension.properties` file being overwritten during packaging? – Tunaki May 24 '16 at 18:07
  • Why Cp1257 and not Idenity-H? – Petter Friberg May 24 '16 at 18:53
  • Thanks for answers. I will definately try Tunakis suggestion. Petter, Cp1257 is my encoding, I have thoughts that maybe it is the problem, but why it works in Netbeans, but doesn't after compiling? Enimga. I have tried export not to PDF, but to docx and rtf and it works just fine. Mistery... – JavaNewbie May 24 '16 at 18:58
  • Added font with Identity-H. Nothing. Still the same, no Baltic character only in PDF, but in docx and rtf they exists – JavaNewbie May 25 '16 at 16:20
  • maven-shade-plugin doesn't creates jar executable jar. I have looked into executable jar file whick was created with assembly plugin. There is a file called default.jasperreports.properties. In this file there is section # Font settings. I have changed default Cp1252 encoding to Cp1257 and the required characters showed up in pdf. Still jar file doesn't reach my font, but at least I can see required characters in pdf. – JavaNewbie May 25 '16 at 17:01

0 Answers0