23. FAQS

How to prevent NaN values in numeric fields

If you are using the format-number function or another numeric function on a non numeric field (or a numeric field that is empty) you will get the value NaN in your report. If you want to remove the NaN values you can use the j4lext:replaceStr function to replace them with an empty string.

For example if your current area is based on a XML node that has a child node called QUANTITY, which you want to format using the format-number function you can use the following xpath expression:

j4lext:replaceStr(format-number(QUANTITY, '##.0'),'NaN',' ')

this would prevent the NaN values in case the QUANTITY node is empty (empty string). Note however if you use functions with the j4lext prefix you must use the J4L FOP server, if you use another XSL-FO processor these functions are not available.

How to enable the designer console

Edit the file fodesigner.ini in the installation directory, add the line

    -consoleLog

after

    -startup

plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar

Restart the designer, now the designer console will be shown, where you can eventually see error messages.

How to debug Oracle APEX requests

If you are using Oracle APEX and:


How to enable Oracle APEX logging on Glassfish

You can enable 2 types of loggings:
  1.  In the ORDS configuration file default.xml set this value:

    <entry key="debug.debugger">true</entry>
  2. On the Glassfish administration console → Configurations → server-config → Logger settings, add the entry „oracle.dbtools“ and set the desired log level.

    The log file will located in the directory glassfish\domains\yourdomain\logs

How to create a user defined XPath function

If you want to create your own function the following example shows how to do it:

*/
public static
String toUpperCase(String input) { return input.toUpperCase();
}

}

Note: When you insert the function in the output, the function name will have the prefix j4luserext:

How to add new fonts to J4L FO Designer

J4L FO Designer supports the five built-in PDF base fonts (Helvetica, Times, Courier, Symbol and Zapfdingbats) which must be supported by any PDF reader.

However you can add new fonts using a TTF file in the following way:

  1. Open the FO Designer and select Tools -> TTF Font tool



    the Input File must point to your TTF file and the Output XML file to the output metrics file (you can select any name you like).

  2. Click on „Create XML“ and close the dialog.
  3. Edit the created XML metrics file and make sure the font-name element has the same value as the node. For example:

    <font- metrics
    metrics-version="2" type="TYPE0">
    <font-name>Comic
    Sans MS</font-name>
    <full-name>Comic
    MS</full-name>
    <family-name>Comic
    Sans MS</family-name>

  4. Now you have to tell J4L FO Designer to use the XML metrics file you created. You do this by editing the file located in the root J4L FO Designer directory.



    You have to add these lines:

    <font metrics-url="file:///c:/yourdirectory/comic.xml" kerning="yes" embed-url="file:///C:/windows/fonts/comic.ttf">
    <font-triplet name="Comic Sans MS" style="normal" weight="normal"/> </font>

    note you have to change the the embed-url, the metrics-url and the name values. The name must be the same family-name value from step 3.
  5. Now you can start the J4L FO Designer and open the font dialog of any field, the new font will be available in the font selection dialog:



    Note about microsoft TTF files


    If you want to know if you may use microsoft TTF files in your PDF Document you need to:
    1. Download the Microsoft Font properties extension (https://www.microsoft.com/en-us/Typography/TrueTypeProperty21.aspx)
    2. Install the software
    3. Located the TTF File you want to use and select right mouse click, properties. If the properties extension has been installed you will see a new tab called „Embedding“ where you can see the license type for embedding the fonts in documents.



How to add new fonts to Oracle ORDS

Once you added the new fonts to the designer as explained in the previous FAQ, the next step is adding it to the runtime server. This section will show how to add new fonts to Oracle ORDS.

This would add Verdana font support to your reports.


How does the designer deal with namespaces

The xsl-fo file generated by the designer is not namespace aware. This means the XML to PDF conversion will fail in Apache FOP if your input file contains namespace information. In order to avoid this error you have to:

How does support for international character sets work

You can use J4L FO Designer with any language, the following features support internationalization:

How to add my own xslfo attributes to the fields

In most cases FO Designer will generate the xsl-fo output so you do not have to worry about the details of the language. However if you are familiar with xsl-fo and you want to add some additional attributes to the fo:blocks created by FO Designer you can use the property shown below:

How to add page numbers and page total count

You can add page numbers and page total counts in the page header and page footer areas using the following value for the field:

Page <fo:page-number></fo:page-number> of <fo:page-number-citation ref-id='last-page'/>

the text <fo:page-number></fo:page-number> stands for the current page number and the text <fo:page-number-citationref-id='last-page'/> will be replaced with the total page count.