I use Lucee 5.3.3.62 and I need to generate pdf exactly as in ColdFusion 11, which I believe use iText.
The new Lucee engine seems to be different (fonts different, images not rendered, sizes), so I tried to set this.pdf.type = “classic”.
But still there are many differences and some pdf generation is simply failing (produce a file with wrong format, or gives errors on some image manipulation)
Anyone tried this? any guidelines?
I’ll try to come up with more specific errors.
I see…but I managed to make a virtual host work on the same machine.
Now this other virtualhost produces empty pdf…only thing I can see is this stackTrace.
And I checked the WEB-INF/lucee/fonts, should be ok
"ERROR","http-nio-8888-exec-37","01/30/2020","17:57:24","",";class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap');lucee.runtime.exp.NativeException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')
at java.desktop/sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1086)
at java.desktop/sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:971)
at java.desktop/sun.font.CompositeFont.doDeferredInitialisation(CompositeFont.java:287)
at java.desktop/sun.font.CompositeFont.getSlotFont(CompositeFont.java:376)
at java.desktop/sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:80)
at java.desktop/sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:95)
at java.desktop/sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:360)
at java.desktop/sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:351)
at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:303)
at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:251)
at java.desktop/sun.awt.SunToolkit.getFontMetrics(SunToolkit.java:582)
at java.desktop/sun.awt.HeadlessToolkit.getFontMetrics(HeadlessToolkit.java:330)
at org.zefer.font.c.super(Unknown Source)
at org.zefer.font.c.<init>(Unknown Source)
at org.zefer.cache.ResourceCache.getFontMetrics(Unknown Source)
at org.zefer.html.doc.q.Ó00000(Unknown Source)
at org.zefer.html.doc.q.return(Unknown Source)
at org.zefer.html.doc.w.<init>(Unknown Source)
at org.zefer.html.doc.PD4MLHtmlParser.buildDocument(Unknown Source)
at org.zefer.pd4ml.PD4ML.o00000(Unknown Source)
at org.zefer.pd4ml.PD4ML.render(Unknown Source)
at org.zefer.pd4ml.PD4ML.render(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.lucee.extension.pdf.pd4ml.PDFByReflection.invoke(PDFByReflection.java:209)
at org.lucee.extension.pdf.pd4ml.PDFByReflection.render(PDFByReflection.java:180)
at org.lucee.extension.pdf.pd4ml.PD4MLPDFDocument.content(PD4MLPDFDocument.java:137)
at org.lucee.extension.pdf.pd4ml.PD4MLPDFDocument.render(PD4MLPDFDocument.java:110)
at org.lucee.extension.pdf.tag.Document.render(Document.java:637)
at org.lucee.extension.pdf.tag.Document._doEndTag(Document.java:601)
at org.lucee.extension.pdf.tag.Document.doEndTag(Document.java:545)
at pdf.pdf_image_cfm$cf$3.call(/pdf/pdf_image.cfm:2)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:942)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:834)
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:216)
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:42)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2409)
at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2399)
at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2374)
at lucee.runtime.engine.Request.exe(Request.java:43)
at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1109)
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1055)
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:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
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.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassCastException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')
... 68 more
the question is also, it is possible to use iText like in CF (and maybe even paying the licence if necessary?).
I though that “classic” would do the trick.
This is really blocking
ok, I probably got rid of the class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont error, and I added the comment.
Images are still a problem though
The funny thing is that I have 2 virtual hosts on the same Lucee installation mapped to 2 Lucee Applications and one is working “more or less” fine, the other doesn’t and I can’t tell the difference
I managed to render the image with localUrl=“no” and the image url.
Previously I didn’t realize that the url was not resolved on the server.
So it doesn’t seem to be really a PDF problem, rather the file is not found with localURL=“yes” on some hosts. With harcoded path, no path, or getTempPath()… no success.
The files are on the same EFS as the cfm page. Lucee is running on an EC2.
I don’t see however any weird in the logs. Maybe I don’t have logging enabled for pdf…
We haven’t been able to make our applications produce PDF documents reliably with the new PDF engine. eg. <div style="position:absolute;top:100;left:200">some text</div> places text in the top left corner of the page. We’re still using PDF extension version 1.0.0.68 and Java 8 in our applications to keep PDFs working.