HTML to PDF / DOCX / RTF Java converter library Forums PD4ML v3 Archived Forums (Read Only) HTML/CSS rendering issues Embed TTFs – getting does not seem to be TTF error message

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27130

    I am trying to embed Archer fonts using Java API. The html version of my page works well with the fonts, but when I try to render that url using PD4ML, it gives an error in my console:

    file:/windows/fonts/Archer-Book_1.otf does not seem to be TTF

    I tried renaming to .ttf, and it still says Archer-Book_1.ttf does not seem to be TTF

    Code to get PD4ML instance:
    private static PD4ML getPd4mlInstance(PdfGeneratorSettings settings,<br /> HttpSession httpSession) {<br /> PD4ML pd4ml = new PD4ML();<br /> String httpSessionId = httpSession.getId();<br /> pd4ml.setCookie(SESSION_KEY,<br /> httpSessionId + PATH);<br /> pd4ml.setPageSize(getPageSizeAndOrientation(pd4ml,<br /> settings));<br /> pd4ml.setHtmlWidth(settings.getHtmlPageWidth());<br /> pd4ml.setPageInsets(settings.getPageInsets());<br /> try{<br /> pd4ml.useTTF("/windows/fonts", true);<br /> } catch (FileNotFoundException e){<br /> LOG.error("not able to find fonts", e);<br /> }<br /> pd4ml.enableDebugInfo();<br /> setFooter(pd4ml,<br /> settings);<br /> <br /> return pd4ml;<br /> }

    Rendering call:

    <br /> public void generatePdfBasedOnUrl(PdfGeneratorSettings settings,<br /> URL url) throws InvalidParameterException, IOException {<br /> getPd4mlInstance(settings,<br /> httpSession).render(url,<br /> settings.getOutputStream());<br /> }<br />
    JSP/HTML:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><br /> <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%><br /> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%><br /> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%><br /> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%><br /> <%@ taglib prefix="pd4ml" uri="http://pd4ml.com/tlds/pd4ml/2.6"%><br /> <br /> <html><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><br /> <style type="text/css"><br /> .clearfix:after {<br /> visibility: hidden;<br /> display: block;<br /> font-size: 0;<br /> content: " ";<br /> clear: both;<br /> height: 0;<br /> }<br /> <br /> body{<br /> width: 1350px;<br /> font-family: 'Archer Book';<br /> }<br /> <br /> #page1, #page2{<br /> border: 1px solid #000;<br /> padding: 1px;<br /> margin-top: 3px;<br /> height: 820px;<br /> width: 1344px;<br /> }<br /> <br /> #page1LeftSide, #page2LeftSide{<br /> /* border: 1px solid #000; */<br /> height: 818px;<br /> width: 650px;<br /> float: right;<br /> margin-right: 22px;<br /> left: -12px;<br /> position: relative;<br /> }<br /> #page1RightSide, #page2RightSide{<br /> /* border: 1px solid #000; */<br /> height: 818px;<br /> width: 650px;<br /> float: right;<br /> margin-left: 18px;<br /> }<br /> </style><br /> </head><br /> <body><br /> <font face="Archer Book">Hello Archer Book</font><br/><br /> </body><br /> </html>

    I have an older version (v381 I think?).

    Has anyone seen this, and how did they fix it?

    #30003

    I am repeating my email comment here:

    loading java:archerfonts/Archer-Book.otf [1ms]<br /> reject TTF lookup for: 'archer book'<br /> can not read 'archer book' from java:archerfonts/Archer-Book.otf: java:archerfonts/Archer-Book.otf is .OTF font file with currently unsupported PostScript outlines ('CFF' glyph table instead of 'loca').<br />

    Under .OTF extension there can be two different font formats: TTF and Type1 (PostScript).

    Archer-Book.otf is obviously Type1. Java provides only limited support for Type1 fonts and in most of the cases it simply gives up by an attempt to instantiate java.awt.Font object from such .OTF file.

    As the only robust solution I would recommend to look for a similar TTF (or OTF of TTF format) font and to use it instead.

    #30004

    Thanks again for your help! I was able to use FontForge and convert my OTFs to TTFs and the old version of PD4ML was able to render correctly (at least the small subset of text I have in my proof of concept)

    #30005

    Thank you for the update! I was not sure FontForge is capable to convert one font type to another. I am glad it is.

    #30006

    Hi there,

    I also encounter the (‘CFF’ glyph table instead of ‘loca’) message when using an otf font file (and version 3.10.0 of pd4ml). However I am able to instantiate a Font object and display / render some text without problems (in my rather simple test cases though).

    -> do you happen to have / know if there is further information available on why this happens here? Maybe something related to the underlying pdf-creation-layer/lib?

    Best regards and have a nice day

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.