Repository: danfickle/openhtmltopdf

Issue #224: Exception in apache.pdfbox/fontbox - null font
Created: 2018-06-01T12:09:13Z
Hi,
Got this, have no idea why:
java.io.IOException: The TrueType font null does not contain a 'cmap' table
        at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapImpl(TrueTypeFont.java:548)
        at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapLookup(TrueTypeFont.java:528)
        at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapLookup(TrueTypeFont.java:514)
        at org.apache.fontbox.ttf.TTFSubsetter.<init>(TTFSubsetter.java:91)
        at org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder.subset(TrueTypeEmbedder.java:321)
        at org.apache.pdfbox.pdmodel.font.PDType0Font.subset(PDType0Font.java:239)
        at com.openhtmltopdf.pdfboxout.PdfBoxFontResolver.close(PdfBoxFontResolver.java:86)
        at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.cleanup(PdfBoxRenderer.java:848)
        at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.close(PdfBoxRenderer.java:870)
        at com.openhtmltopdf.pdfboxout.PdfRendererBuilder.run(PdfRendererBuilder.java:37)
        at web.MakePdf.processRequest(MakePdf.java:97)
        at web.MakePdf.doPost(MakePdf.java:116)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:159)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:97)
        at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:109)
        at web.ur.CheckAccess.doFilter(CheckAccess.java:49)
        at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:89)
        at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:156)
        at com.caucho.server.webapp.AccessLogFilterChain.doFilter(AccessLogFilterChain.java:95)
        at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:290)
        at com.caucho.server.hmux.HmuxRequest.handleInvocation(HmuxRequest.java:476)
        at com.caucho.server.hmux.HmuxRequest.handleRequestImpl(HmuxRequest.java:374)
        at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:341)
        at com.caucho.network.listen.TcpSocketLink.dispatchRequest(TcpSocketLink.java:1362)
        at com.caucho.network.listen.TcpSocketLink.handleRequest(TcpSocketLink.java:1318)
        at com.caucho.network.listen.TcpSocketLink.handleRequestsImpl(TcpSocketLink.java:1302)
        at com.caucho.network.listen.TcpSocketLink.handleRequests(TcpSocketLink.java:1210)
        at com.caucho.network.listen.TcpSocketLink.handleAcceptTaskImpl(TcpSocketLink.java:1006)
        at com.caucho.network.listen.ConnectionTask.runThread(ConnectionTask.java:117)
        at com.caucho.network.listen.ConnectionTask.run(ConnectionTask.java:93)
        at com.caucho.network.listen.SocketLinkThreadLauncher.handleTasks(SocketLinkThreadLauncher.java:169)
        at com.caucho.network.listen.TcpSocketAcceptThread.run(TcpSocketAcceptThread.java:61)
        at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173)
        at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118)

Probably this Exception#printStackTrace call should be removed, although I don't understand how can font be null:
public void close() {
		for (FontDescription fontDescription : _fontCache.values()) {
			/*
			 * If the font is not yet subset, we must subset it, otherwise we may leak a
			 * file handle because the PDType0Font may still have the font file open.
			 */
			if (fontDescription._font != null && fontDescription._font.willBeSubset()) {
				try {
					fontDescription._font.subset();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		_fontCache.clear();

		// Close all still open TrueTypeCollections
		for (TrueTypeCollection collection : _collectionsToClose) {
			try {
				collection.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		_collectionsToClose.clear();
	}

Duplicate issue #234: java.io.IOException: The TrueType font does not contain a 'cmap' table
Created: 2018-06-25T01:38:28Z
R14 version, generating pdf custom font error, but PDF font displayed correctly
java.io.IOException: The TrueType font does not contain a 'cmap' table
	at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmap(TrueTypeFont.java:477)
	at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmap(TrueTypeFont.java:460)
	at org.apache.fontbox.ttf.TTFSubsetter.<init>(TTFSubsetter.java:90)
	at org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder.subset(TrueTypeEmbedder.java:318)
	at org.apache.pdfbox.pdmodel.font.PDType0Font.subset(PDType0Font.java:162)
	at com.openhtmltopdf.pdfboxout.PdfBoxFontResolver.close(PdfBoxFontResolver.java:86)
	at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.cleanup(PdfBoxRenderer.java:850)
	at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.close(PdfBoxRenderer.java:872)
	at com.openhtmltopdf.pdfboxout.PdfRendererBuilder.run(PdfRendererBuilder.java:37)
	at com.promise.actual.deisgn.pdf.PdfTemplate.htmlToPdf(PdfTemplate.java:432)
	at com.promise.actual.deisgn.pdf.PdfTemplate.createSamplePdf(PdfTemplate.java:246)

	at com.promise.actual.deisgn.pdf.PdfTemplate.drawPdf(PdfTemplate.java:212)
	at com.promise.actual.deisgn.pdf.PdfTemplate.createPDF(PdfTemplate.java:127)
	at com.promise.actual.deisgn.pdf.PdfTemplate.<init>(PdfTemplate.java:78)
	at com.promise.redis.notification.ExpiredAction.createPdf(ExpiredAction.java:68)
	at com.promise.redis.notification.OrderSubscribe.onPMessage(OrderSubscribe.java:47)
	at redis.clients.jedis.JedisPubSub.process(JedisPubSub.java:145)
	at redis.clients.jedis.JedisPubSub.proceedWithPatterns(JedisPubSub.java:96)
	at redis.clients.jedis.Jedis.psubscribe(Jedis.java:2769)
	at com.promise.redis.notification.RedisInitSubscrib.afterPropertiesSet(RedisInitSubscrib.java:22)
	at com.promise.redis.notification.RedisInitSubscrib.run(RedisInitSubscrib.java:29)

Closing comment (2018-06-25T07:17:41Z): Duplicate of #224