Apache FOP | custom fonts | relative url not working

I have a configuration file to download custom fonts for Apache FOP. I'm struggling to set up embed-url on the server so that the url font changes according to the server domain.

I tried the value of the embed-url property as:

Broken Embedded URLs:

  • embed-url = "context: /etc/designs/projectName/clientlibs/pdffonts/Batang.ttf"
  • embed-url = "File: /etc/designs/projectName/clientlibs/pdffonts/Batang.ttf"

Working Embed URL:

  • embed-url = "http: // local: 4503 / etc / constructs / projectname / clientlibs / pdffonts / batang.ttf"

Somehow I cannot find the correct syntax here. I am using FOP with AEM 6.0.

<?xml version="1.0"?>
<fop version="1.0">
    <renderers>
        <renderer mime="application/pdf">
            <fonts>
                <font kerning="yes"
                    embed-url="context:/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf" -- this doesn't
                    embedding-mode="subset">
                    <font-triplet name="SimSun" style="normal" weight="normal" />
                </font>
                <font kerning="yes"
                    embed-url="file:/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf" -- this doesn't
                    embedding-mode="subset">
                    <font-triplet name="Batang" style="normal" weight="normal" />
                </font>
                <font kerning="yes"
                    embed-url="http://localhost:4503/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf" -- this works
                    embedding-mode="subset">
                    <font-triplet name="Batang" style="normal" weight="normal" />
                </font>
            </fonts>
        </renderer>
    </renderers>
</fop>
+4
3

" " :

  • font-base ( ),
  • base
  • , , <base>.</base>, ,

, font-base base , .

<?xml version="1.0"?>
<fop version="1.0">

  <base>.</base>

  <font-base>/Users/lfurini/Library/Fonts</font-base>
  <!-- other possible examples:
  <font-base>.</font-base>
  <font-base>../fonts</font-base>
  --> 

  <!-- ... -->
</fop>

:

  • context: file:
  • embed-url /, , , " ",
  • ../ ,

    <!-- directly in the base folder -->
    <font kerning="yes" embed-url="font1.ttf">
      <font-triplet name="font1" style="normal" weight="normal"/>
    </font>
    
    <!-- in a "sister" folder -->
    <font kerning="yes" embed-url="../otherFonts/font2.ttf">
      <font-triplet name="font2" style="normal" weight="normal"/>
    </font>
    
    <!-- in a sub-folder -->
    <font kerning="yes" embed-url="specialFonts/font3.ttf">
      <font-triplet name="font3" style="normal" weight="normal"/>
    </font>
    
    <!-- absolute path -->
    <font kerning="yes" embed-url="/Users/lfurini/Library/Fonts/font4.ttf" embedding-mode="subset">
      <font-triplet name="font4" style="normal" weight="normal"/>
    </font>
    

( FOP 1.1, 2.0 2.1)

(: FOP, )

+3

, . patr .

fopFactory.setBaseURL(this.getServletContext() getInitParameter ( "my_path").);

-URL = "/newfont.ttf"

0

Source: https://habr.com/ru/post/1627252/


All Articles