diff --git a/README.rst b/README.rst index 8363bb2..031a1f0 100755 --- a/README.rst +++ b/README.rst @@ -47,10 +47,10 @@ reporting. .. |TestsCI| image:: https://github.com/acesseonline/pyreportjasper/workflows/Tests/badge.svg?branch=master .. _TestsCI: https://github.com/acesseonline/pyreportjasper/actions?query=workflow%3ATests -.. |pyversions| image:: https://img.shields.io/badge/python-3.8%20or%20higher-blue.svg -.. |javaversions| image:: https://img.shields.io/badge/java-9%20or%20higher-purple.svg -.. |jvm| image:: https://img.shields.io/badge/jvm-Open%20%7C%20Oracle%20%7C%20Corretto-purple.svg -.. |platform| image:: https://img.shields.io/badge/platform-linux%20%7C%20windows%20%7C%20mac-lightgrey +.. |pyversions| image:: https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue.svg +.. |javaversions| image:: https://img.shields.io/badge/java-%3E=9%20and%20%3C=20-blue.svg +.. |jvm| image:: https://img.shields.io/badge/jvm-Open%20%7C%20Oracle%20%7C%20Corretto-blue.svg +.. |platform| image:: https://img.shields.io/badge/platform-Linux%20%7C%20Windows%20%7C%20Mac-lightgrey .. _GNU GENERAL PUBLIC LICENSE: https://github.com/acesseonline/pyreportjasper/blob/master/LICENSE .. _Python Docs: https://pyreportjasper.readthedocs.io/en/latest/ .. |license| image:: https://img.shields.io/badge/License-GPLv3-blue.svg diff --git a/docs/source/api.rst b/docs/source/api.rst index 60b0f4c..b2d85cc 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -335,6 +335,10 @@ Class Report Export the report in ``pdf`` format + .. py:classmethod:: export_html() + + Export the report in ``html`` format + .. py:classmethod:: export_rtf() Export the report in ``rtf`` format diff --git a/example_custom_font/README.md b/example_custom_font/README.md new file mode 100644 index 0000000..93c6892 --- /dev/null +++ b/example_custom_font/README.md @@ -0,0 +1,42 @@ +# Adding font + +To use a font, simply install it on the operating system and use it in your report. If that doesn't work, you have the option to add a .jar file with the fonts you want to use along with the library. I've shown below how to do it. + + +## Step 1 - Understanding the structure + +In the project repository, there's a folder with the base structure to perform the procedure. After cloning the repository, inside the folder where you cloned it, navigate to the **example_custom_font** directory + +``` +.. ++-- example_custom_font +| +-- src +| +-- fonts +| +-- myfontcustom +| +-- CaskaydiaCoveNerdFont-Bold.ttf +| +-- CaskaydiaCoveNerdFont-BoldItalic.ttf +| +-- CaskaydiaCoveNerdFont-Italic.ttf +| +-- CaskaydiaCoveNerdFont-Regular.ttf +| +-- fontsfamily1703017000639.xml +| +-- jasperreports_extension.properties +``` + +## Step 2 - Changes +1) Within the **fonts** folder, change the name of the folder `myfontcustom` to the name you want to use for the font in the report. + +2) Copy the `.ttf` font files to the folder from the previous step. Specifically, the font files for `Regular`, `Bold`, `BoldItalic`, and `Italic`. Modify the corresponding file names within the `fontsfamily1703017000639.xml` file in their respective tags. + +3) Using your preferred editor, open the file `fontsfamily1703017000639.xml`. Replace wherever you find the name `myfontcustom` with the same name you gave in step 1 of this section. + + +## Step 3 - Generating `.jar` file. + +Compress the `fonts` folder along with the file `jasperreports_extension.properties`. Then, change the extension from `.zip` to `.jar` and name the `.jar` file with the same name as in `step 1` of the previous section, `Step 2 - Changes`. + +## Step 4 - Using the generated `.jar` with the library. + +Save the generated `.jar` in a folder of your choice, and in the `resource` parameter of the library, specify the folder where the `.jar` is located. Assign the font name in the report (`.jrxml`) and make good use of it. + +## Reference + +For further details, visit: [https://jasperreports.sourceforge.net/sample.reference/fonts/#fonts](https://jasperreports.sourceforge.net/sample.reference/fonts/#fonts) \ No newline at end of file diff --git a/example_custom_font/src/fonts/fontsfamily1703017000639.xml b/example_custom_font/src/fonts/fontsfamily1703017000639.xml new file mode 100644 index 0000000..fbd5a4b --- /dev/null +++ b/example_custom_font/src/fonts/fontsfamily1703017000639.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Bold.ttf b/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Bold.ttf new file mode 100644 index 0000000..ca620d6 Binary files /dev/null and b/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Bold.ttf differ diff --git a/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-BoldItalic.ttf b/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-BoldItalic.ttf new file mode 100644 index 0000000..4d9c1a8 Binary files /dev/null and b/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-BoldItalic.ttf differ diff --git a/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Italic.ttf b/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Italic.ttf new file mode 100644 index 0000000..e0b4238 Binary files /dev/null and b/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Italic.ttf differ diff --git a/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Regular.ttf b/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Regular.ttf new file mode 100644 index 0000000..2b3870a Binary files /dev/null and b/example_custom_font/src/fonts/myfontcustom/CaskaydiaCoveNerdFont-Regular.ttf differ diff --git a/example_custom_font/src/jasperreports_extension.properties b/example_custom_font/src/jasperreports_extension.properties new file mode 100644 index 0000000..492fce0 --- /dev/null +++ b/example_custom_font/src/jasperreports_extension.properties @@ -0,0 +1,2 @@ +net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory +net.sf.jasperreports.extension.simple.font.families.ireportfamily1703017000639=fonts/fontsfamily1703017000639.xml diff --git a/example_custom_font/test/custom_font.jrxml b/example_custom_font/test/custom_font.jrxml new file mode 100644 index 0000000..7ed790e --- /dev/null +++ b/example_custom_font/test/custom_font.jrxml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example_custom_font/test/test_custom_font.py b/example_custom_font/test/test_custom_font.py new file mode 100644 index 0000000..db1c5cd --- /dev/null +++ b/example_custom_font/test/test_custom_font.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +import os +from pyreportjasper import PyReportJasper + +def processing(): + REPORTS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__))) + input_file = os.path.join(REPORTS_DIR, 'custom_font.jrxml') + output_file = os.path.join(REPORTS_DIR, 'output', 'custom_font') + pyreportjasper = PyReportJasper() + pyreportjasper.config( + input_file, + output_file, + output_formats=["pdf"] + ) + pyreportjasper.process_report() + +processing() \ No newline at end of file diff --git a/pyreportjasper/report.py b/pyreportjasper/report.py index 53e2331..a2e7bdd 100644 --- a/pyreportjasper/report.py +++ b/pyreportjasper/report.py @@ -39,6 +39,7 @@ def __init__(self, config: Config, input_file): if self.config.jvm_classpath is None: jpype.startJVM("-Djava.system.class.loader=org.update4j.DynamicClassLoader", "-Dlog4j.configurationFile={}".format(os.path.join(self.LIB_PATH, 'log4j2.xml')), + "--illegal-access=warn", "-Xmx{}".format(self.config.jvm_maxmem), classpath=classpath)