Lucee cfdocument pdf error

Hey Everyone,

I try to convert some simpel HTML to PDF through the cfdocument tag.
But it gives me the following error: Font ‘Courier-BoldOblique’ with ‘Cp1252’ is not recognized..
The weird thing is that installing another Lucee snapshot made the error go away. But after eating my lunch (and thus not doing any coding) the error came back. We do have other library installed to generate PDF’s and I think there may be some collision here. But how to fix this?

Thanks in advance!

OS: Windows Server
Java Version: 11.0.6
Tomcat Version: 9.0.31
Lucee Version: Lucee 5.3.6.40-SNAPSHOT

Please always include the top of stacktrace :slight_smile:

Which version of the pdf extension are you running?

This one liner fix for a pdf font problem has been waiting to be merged for 5 months @IamSigmund

pd4fonts.properties file generated by PDF extension is missing an important newline
https://luceeserver.atlassian.net/browse/LDEV-2595

Thanks for your quick reply. Currently it’s working again because I restarted Lucee. But when it comes back I will add the stacktrace!

should be still there in your exception.log file?

Hmm weird I don’t see it in the log file. Maybe if I call some other PDF functions the error wil come back

Ok when I called another function that converts a docx to pdf it suddenly shows the error:

lucee.runtime.exp.NativeException: Font 'Courier-BoldOblique' with 'Cp1252' is not recognized. at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:485) at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:43) at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:124) at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:110) at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:106) at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:102) at org.lucee.extension.pdf.xhtmlrenderer.FSPDFDocument.render(FSPDFDocument.java:64) at org.lucee.extension.pdf.tag.Document.renderInital(Document.java:717) at org.lucee.extension.pdf.tag.Document._doAfterBody(Document.java:621) at org.lucee.extension.pdf.tag.Document.doAfterBody(Document.java:573) at views.instellingen.pdf_builder_cfm$cf$11.call(/views/instellingen/pdf_builder.cfm:29) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:945) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:837) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:818) at framework.one_cfc$cf$1.udfCallb(/framework/one.cfc:1877) at framework.one_cfc$cf$1.udfCall(/framework/one.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:217) at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:779) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:785) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1710) at framework.one_cfc$cf$1.udfCall5(/framework/one.cfc:870) at framework.one_cfc$cf$1.udfCall(/framework/one.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:217) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:680) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:568) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1898) at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:436) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:215) at lucee.runtime.listener.ModernAppListener.onRequest(ModernAppListener.java:104) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2416) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2406) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2381) at lucee.runtime.engine.Request.exe(Request.java:43) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1127) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1073) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97) at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:415) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.lang.RuntimeException: Font 'Courier-BoldOblique' with 'Cp1252' is not recognized. ... 63 more Caused by: com.lowagie.text.DocumentException: Font 'Courier-BoldOblique' with 'Cp1252' is not recognized. at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source) at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source) at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source) at org.xhtmlrenderer.pdf.ITextFontResolver.createFont(ITextFontResolver.java:498) at org.xhtmlrenderer.pdf.ITextFontResolver.createFont(ITextFontResolver.java:494) at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:506) at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:474) ... 62 more

I use Docxtopdfconverter to make a pdf and pdfbox to get text out of a pdf.
EDIT: I’ve now found out that calling

temp_Converter = createObject("java","com.yeokhengmeng.docstopdfconverter.DocxToPDFConverter");

Is creating the error while calling cfdocument

I found a few other people with the same problem

Well I’m still looking but I’ve no idea how to fix this.
I thought that maybe removing the Itext from the docx converter may help, but it didn’t.
Al the jar files contain class files which cannot be edited.

have you tried dynamically loading those jars, rather than dumping them in /lib etc?

i.e. providing a context? https://docs.lucee.org/reference/functions/createobject.html#argument-context

createObject(“java”,“com.yeokhengmeng.docstopdfconverter.DocxToPDFConverter”, [‘all’, ‘the’, ‘jars’, ‘it needs’]);

Hey! Hmm yea that also sounds like a plan. Now all the dependencies are already inside the jar file but I could do it again and try loading it on that way. With another problem I also tried to make Javaloader work, but with no luck. I currently found a “solution” by enabling the older PDF engine in Lucee. Now it looks that I can use all the libraries without errors. Later on I will try the new engine. Thanks!

I believe that javaloader is meant to be no longer required in 5.3… but the docs never got updated

Does that mean jars (and not necessarily bundles) can now be dynamically loaded in isolation from different versions already loaded, and RE-loaded without an engine restart? These are the reasons I haven’t been able to drop JavaLoader.

paging @micstriit :slight_smile: