Category Archives: apache-fop

Issue in xsl stylesheet when creating pdf using apache fop

I want to convert html document to pdf using Apache FOP. I tried worked fine for a basic html file. but when the page has a right align paragraph this wont work

<p style= "font-size: 10px;margin: 5px 0px 20px; padding: 0px 20px 0px 0px; line-height: 130%;max-width: 258px;">
                <b> Accounts details</b><br>
                $Description <br>
                $address_line1 $address_line2<br>
                $address_city, $address_state $address_zip <br>
                $address_country <br>

I tried to create a simple xsl file but getting the bellow error

(Location of error unknown) First element must be the fo:root formatting object. Found (Namespace URI: "", Local Name: "html") instead. Please make sure you're producing a valid XSL-FO document.

Please find the xsl file I created.

  <?xml version="1.0" encoding="utf-8" standalone="no" ?>
<xsl:stylesheet xmlns="" xmlns:xsl="" version="1.0">
    <xsl:output method="xml" encoding="utf-8" indent="yes" doctype-system="" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
    <xsl:template match="/">
        <xsl:element name="html">
            <xsl:attribute name="xmlns"></xsl:attribute>
            <xsl:element name="head">
                <xsl:element name="meta">
                    <xsl:attribute name="equiv">content-type</xsl:attribute>
                    <xsl:attribute name="content">text/html;charset=utf-8</xsl:attribute>
                <xsl:element name="title">
            <xsl:element name="body">
                <p style= "font-size: 10px;margin: 5px 0px 20px; padding: 0px 20px 0px 0px; line-height: 130%;
                                  max-width: 258px;">
                    <b>Accounts Payable</b><br/>
                    $Description <br/>
                    $address_line1 $address_line2<br/>
                    $address_city, $address_state $address_zip <br/>
                    $address_country <br/>

Apache fop generated PDF renders hyperlinks by replacing accented characters with ‘?’

I have used Apache FOP 1.1 to programmatically generate PDF. The PDF is supposed to contain name of a document as hyperlink. When I click on the name, it should open the corresponding file. Here is the code:

    <fo:basic-link color="blue" show-destination="new">
        <xsl:attribute name="external-destination">
                <xsl:when test="@parentFolderPath">
                   <xsl:value-of select="@parentFolderPath" />/<xsl:value-of select="@FileName" />
                   <xsl:value-of select="@FileName" />
        </xsl:attribute><xsl:call-template name="writeWithoutOverlap"><xsl:with-param name="data" select="@FileName"/></xsl:call-template>                   

This works perfectly fine when I have a file having English characters in the name. However, when I have a file name like this: "étudiant où forêt naïve garçon.docx" the hyperlink formed in the PDF replaces the accented characters with '?'.

This is a screen shot of the PDF where you can see the malformed hyperlink.

I am using "Arial" font and encoding="UTF-8".

When the name of the file is getting printed correctly, why is the hyperlink giving a problem?