Hello everybody! I use that code:
val inputStream = new URL(docxUrl).openStream()
val wordPackage = WordprocessingMLPackage.load(inputStream)
val foSettings = Docx4J.createFOSettings()
foSettings.setWmlPackage(wordPackage)
val os = new FileOutputStream(System.getProperty("user.dir") + "/OUT_FontContent.pdf")
Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL)
But unfortunately I have that error (starts with warnings, but than ERROR appears):
2021-09-29 18:16:42 WARN org.docx4j.utils.ResourceUtils Couldn't get resource: docx4j.properties
api_1 | 2021-09-29 18:16:42 WARN org.docx4j.Docx4jProperties Couldn't find/read docx4j.properties; docx4j.properties not found via classloader.
api_1 | 2021-09-29 18:16:42 INFO org.docx4j.jaxb.Context java.vendor=N/A
api_1 | 2021-09-29 18:16:42 INFO org.docx4j.jaxb.Context java.version=11.0.8
api_1 | 2021-09-29 18:16:42 INFO org.docx4j.jaxb.Context java.vm.name=OpenJDK 64-Bit Server VM
api_1 | 2021-09-29 18:16:44 INFO org.docx4j.jaxb.Context JAXB Reference Implementation is in use.
api_1 | 2021-09-29 18:16:44 WARN org.docx4j.XmlUtils default SAXParserFactory property : null
api_1 | Please consider using Xerces.
api_1 | 2021-09-29 18:16:44 INFO org.docx4j.XmlUtils actual: com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
api_1 | 2021-09-29 18:16:44 WARN org.docx4j.XmlUtils default DocumentBuilderFactory property: null
api_1 | Please consider using Xerces.
api_1 | 2021-09-29 18:16:44 INFO org.docx4j.XmlUtils actual: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
api_1 | 2021-09-29 18:16:44 INFO o.d.o.contenttype.ContentTypeManager Detected WordProcessingML package
api_1 | 2021-09-29 18:16:44 INFO o.d.o.contenttype.ContentTypeManager Detected WordProcessingML package
api_1 | 2021-09-29 18:16:44 INFO org.docx4j.openpackaging.io3.Load3 Instantiated package of type org.docx4j.openpackaging.packages.WordprocessingMLPackage
api_1 | 2021-09-29 18:16:44 INFO org.docx4j.utils.XPathFactoryUtil xpath implementation: org.apache.xpath.jaxp.XPathFactoryImpl
api_1 | 2021-09-29 18:16:44 INFO o.d.o.contenttype.ContentTypeManager Using DocPropsCustomPart ...
api_1 | 2021-09-29 18:16:44 INFO org.docx4j.openpackaging.io3.Load3 package read; elapsed time: 1538 ms
api_1 | 2021-09-29 18:16:44 INFO o.d.model.structure.PageDimensions No cols in this section; defaulting.
api_1 | 2021-09-29 18:16:44 INFO o.d.jaxb.NamespacePrefixMapperUtils Using ri.NamespacePrefixMapper, which is suitable for the JAXB RI
api_1 | 2021-09-29 18:16:44 WARN org.docx4j.fonts.IdentityPlusMapper WARNING! SubstituterWindowsPlatformImpl works best on Windows. To get good results on other platforms, you'll probably need to have installed Windows fonts.
api_1 | 2021-09-29 18:16:44 INFO o.d.o.p.W.FontTablePart Writing temp embedded fonts 1632939404443
api_1 | 2021-09-29 18:16:44 WARN org.docx4j.fonts.IdentityPlusMapper - - No physical font for: Calibri
api_1 | 2021-09-29 18:16:44 WARN org.docx4j.fonts.IdentityPlusMapper - - No physical font for: Lato Black
api_1 | 2021-09-29 18:16:44 INFO o.d.o.parts.DocPropsCorePart unmarshalling org.docx4j.openpackaging.parts.DocPropsCorePart
api_1 | 2021-09-29 18:16:44 INFO o.d.o.parts.DocPropsExtendedPart unmarshalling org.docx4j.openpackaging.parts.DocPropsExtendedPart
api_1 | 2021-09-29 18:16:44 INFO o.d.o.parts.DocPropsCustomPart unmarshalling org.docx4j.openpackaging.parts.DocPropsCustomPart
api_1 | 2021-09-29 18:16:44 INFO o.d.o.parts.DocPropsCustomPart
api_1 |
api_1 | org.docx4j.openpackaging.parts.DocPropsCustomPart unmarshalled
api_1 |
api_1 |
api_1 | 2021-09-29 18:16:44 WARN org.docx4j.fonts.RunFontSelector Font 'Calibri' is not mapped to a physical font.
api_1 | 2021-09-29 18:16:44 INFO o.d.o.p.W.FontTablePart Writing temp embedded fonts 1632939404463
api_1 | 2021-09-29 18:16:44 INFO o.d.c.o.c.preprocess.FieldsCombiner starting
api_1 | 2021-09-29 18:16:44 INFO o.d.c.o.c.p.CoverPageSectPrMover No need to move sectPr
api_1 | 2021-09-29 18:16:44 INFO o.d.model.structure.PageDimensions No cols in this section; defaulting.
api_1 | 2021-09-29 18:16:44 WARN org.docx4j.fonts.RunFontSelector Font 'Calibri' is not mapped to a physical font.
api_1 | 2021-09-29 18:16:44 WARN org.docx4j.fonts.RunFontSelector Calibri is not mapped!
api_1 | Uncaught error from thread [application-akka.actor.default-dispatcher-9]: Bad type on operand stack
api_1 | Exception Details:
api_1 | Location:
api_1 | org/docx4j/org/apache/xalan/processor/ProcessorOutputElem.startElement(Lorg/docx4j/org/apache/xalan/processor/StylesheetHandler;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/xml/sax/Attributes;)V @142: invokevirtual
api_1 | Reason:
api_1 | Type 'org/docx4j/org/apache/xalan/templates/OutputProperties' (current frame, stack[1]) is not assignable to 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement'
api_1 | Current Frame:
api_1 | bci: @142
api_1 | flags: { }
api_1 | locals: { 'org/docx4j/org/apache/xalan/processor/ProcessorOutputElem', 'org/docx4j/org/apache/xalan/processor/StylesheetHandler', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'org/xml/sax/Attributes', 'java/lang/String', 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement' }
api_1 | stack: { 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement', 'org/docx4j/org/apache/xalan/templates/OutputProperties' }
api_1 | Bytecode:
api_1 | 0000000: 2abb 0015 59b7 0016 b500 022a b400 022b
api_1 | 0000010: b600 17b6 0018 2ab4 0002 2bb6 0019 b600
api_1 | 0000020: 1a2a b400 022b b600 1bb6 001c 2a2b 1904
api_1 | 0000030: 1905 2ab6 001d 2ab4 0002 b600 1e12 20b6
api_1 | 0000040: 0021 c000 223a 0601 1906 a500 2d19 062b
api_1 | 0000050: b600 23b8 0024 3a07 2ab4 0002 b600 1e12
api_1 | 0000060: 2019 07b6 0025 57a7 0010 3a07 2b19 07b6
api_1 | 0000070: 0027 1907 b600 282b b600 292a b400 02b6
api_1 | 0000080: 002a 2bb6 002b 3a07 1907 2ab4 0002 b600
api_1 | 0000090: 2c57 2a01 b500 02b1
api_1 | Exception Handler Table:
api_1 | bci [77, 103] => handler: 106
api_1 | Stackmap Table:
api_1 | full_frame(@106,{Object[#45],Object[#104],Object[#34],Object[#34],Object[#34],Object[#105],Object[#34]},{Object[#38]})
api_1 | same_frame(@119)
api_1 | , shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application]
api_1 | java.lang.VerifyError: Bad type on operand stack
api_1 | Exception Details:
api_1 | Location:
api_1 | org/docx4j/org/apache/xalan/processor/ProcessorOutputElem.startElement(Lorg/docx4j/org/apache/xalan/processor/StylesheetHandler;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/xml/sax/Attributes;)V @142: invokevirtual
api_1 | Reason:
api_1 | Type 'org/docx4j/org/apache/xalan/templates/OutputProperties' (current frame, stack[1]) is not assignable to 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement'
api_1 | Current Frame:
api_1 | bci: @142
api_1 | flags: { }
api_1 | locals: { 'org/docx4j/org/apache/xalan/processor/ProcessorOutputElem', 'org/docx4j/org/apache/xalan/processor/StylesheetHandler', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'org/xml/sax/Attributes', 'java/lang/String', 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement' }
api_1 | stack: { 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement', 'org/docx4j/org/apache/xalan/templates/OutputProperties' }
api_1 | Bytecode:
api_1 | 0000000: 2abb 0015 59b7 0016 b500 022a b400 022b
api_1 | 0000010: b600 17b6 0018 2ab4 0002 2bb6 0019 b600
api_1 | 0000020: 1a2a b400 022b b600 1bb6 001c 2a2b 1904
api_1 | 0000030: 1905 2ab6 001d 2ab4 0002 b600 1e12 20b6
api_1 | 0000040: 0021 c000 223a 0601 1906 a500 2d19 062b
api_1 | 0000050: b600 23b8 0024 3a07 2ab4 0002 b600 1e12
api_1 | 0000060: 2019 07b6 0025 57a7 0010 3a07 2b19 07b6
api_1 | 0000070: 0027 1907 b600 282b b600 292a b400 02b6
api_1 | 0000080: 002a 2bb6 002b 3a07 1907 2ab4 0002 b600
api_1 | 0000090: 2c57 2a01 b500 02b1
api_1 | Exception Handler Table:
api_1 | bci [77, 103] => handler: 106
api_1 | Stackmap Table:
api_1 | full_frame(@106,{Object[#45],Object[#104],Object[#34],Object[#34],Object[#34],Object[#105],Object[#34]},{Object[#38]})
api_1 | same_frame(@119)
api_1 |
api_1 | at org.docx4j.org.apache.xalan.processor.XSLTSchema.build(XSLTSchema.java:674)
api_1 | at org.docx4j.org.apache.xalan.processor.XSLTSchema.<init>(XSLTSchema.java:72)
api_1 | at org.docx4j.org.apache.xalan.processor.StylesheetHandler.<init>(StylesheetHandler.java:1287)
api_1 | at org.docx4j.org.apache.xalan.processor.TransformerFactoryImpl.newTemplatesHandler(TransformerFactoryImpl.java:371)
api_1 | at org.docx4j.org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:862)
api_1 | at org.docx4j.XmlUtils.getTransformerTemplate(XmlUtils.java:1262)
api_1 | at org.docx4j.convert.out.fo.renderers.AbstractFORenderer.<clinit>(AbstractFORenderer.java:49)
api_1 | at org.docx4j.convert.out.fo.FOConversionContext.initializeFoRenderer(FOConversionContext.java:207)
api_1 | at org.docx4j.convert.out.fo.FOConversionContext.<init>(FOConversionContext.java:95)
api_1 | at org.docx4j.convert.out.fo.AbstractFOExporter.createContext(AbstractFOExporter.java:101)
api_1 | at org.docx4j.convert.out.fo.AbstractFOExporter.createContext(AbstractFOExporter.java:47)
api_1 | at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:72)
api_1 | at org.docx4j.Docx4J.toFO(Docx4J.java:712)
api_1 | at ru.ispras.kb.controllers.DocxExporter.createDocx(DocxExporter.scala:157)
api_1 | at ru.ispras.kb.controllers.ObjectExporter.$anonfun$getObjectsAndSend$2(ObjectExporter.scala:87)
api_1 | at scala.util.Success.$anonfun$map$1(Try.scala:255)
api_1 | at scala.util.Success.map(Try.scala:213)
api_1 | at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
api_1 | at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
api_1 | at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
api_1 | at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
api_1 | at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56)
api_1 | at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:93)
api_1 | at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
api_1 | at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
api_1 | at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:93)
api_1 | at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:48)
api_1 | at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
api_1 | at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
api_1 | at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
api_1 | at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
api_1 | at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
api_1 | at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
api_1 | 2021-09-29 18:16:44 ERROR akka.actor.ActorSystemImpl akka.actor.ActorSystemImpl(application) Uncaught error from thread [application-akka.actor.default-dispatcher-9]: Bad type on operand stack
api_1 | Exception Details:
api_1 | Location:
api_1 | org/docx4j/org/apache/xalan/processor/ProcessorOutputElem.startElement(Lorg/docx4j/org/apache/xalan/processor/StylesheetHandler;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/xml/sax/Attributes;)V @142: invokevirtual
api_1 | Reason:
api_1 | Type 'org/docx4j/org/apache/xalan/templates/OutputProperties' (current frame, stack[1]) is not assignable to 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement'
api_1 | Current Frame:
api_1 | bci: @142
api_1 | flags: { }
api_1 | locals: { 'org/docx4j/org/apache/xalan/processor/ProcessorOutputElem', 'org/docx4j/org/apache/xalan/processor/StylesheetHandler', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'org/xml/sax/Attributes', 'java/lang/String', 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement' }
api_1 | stack: { 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement', 'org/docx4j/org/apache/xalan/templates/OutputProperties' }
api_1 | Bytecode:
api_1 | 0000000: 2abb 0015 59b7 0016 b500 022a b400 022b
api_1 | 0000010: b600 17b6 0018 2ab4 0002 2bb6 0019 b600
api_1 | 0000020: 1a2a b400 022b b600 1bb6 001c 2a2b 1904
api_1 | 0000030: 1905 2ab6 001d 2ab4 0002 b600 1e12 20b6
api_1 | 0000040: 0021 c000 223a 0601 1906 a500 2d19 062b
api_1 | 0000050: b600 23b8 0024 3a07 2ab4 0002 b600 1e12
api_1 | 0000060: 2019 07b6 0025 57a7 0010 3a07 2b19 07b6
api_1 | 0000070: 0027 1907 b600 282b b600 292a b400 02b6
api_1 | 0000080: 002a 2bb6 002b 3a07 1907 2ab4 0002 b600
api_1 | 0000090: 2c57 2a01 b500 02b1
api_1 | Exception Handler Table:
api_1 | bci [77, 103] => handler: 106
api_1 | Stackmap Table:
api_1 | full_frame(@106,{Object[#45],Object[#104],Object[#34],Object[#34],Object[#34],Object[#105],Object[#34]},{Object[#38]})
api_1 | same_frame(@119)
api_1 | , shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application]
api_1 | java.lang.VerifyError: Bad type on operand stack
api_1 | Exception Details:
api_1 | Location:
api_1 | org/docx4j/org/apache/xalan/processor/ProcessorOutputElem.startElement(Lorg/docx4j/org/apache/xalan/processor/StylesheetHandler;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/xml/sax/Attributes;)V @142: invokevirtual
api_1 | Reason:
api_1 | Type 'org/docx4j/org/apache/xalan/templates/OutputProperties' (current frame, stack[1]) is not assignable to 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement'
api_1 | Current Frame:
api_1 | bci: @142
api_1 | flags: { }
api_1 | locals: { 'org/docx4j/org/apache/xalan/processor/ProcessorOutputElem', 'org/docx4j/org/apache/xalan/processor/StylesheetHandler', 'java/lang/String', 'java/lang/String', 'java/lang/String', 'org/xml/sax/Attributes', 'java/lang/String', 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement' }
api_1 | stack: { 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement', 'org/docx4j/org/apache/xalan/templates/OutputProperties' }
api_1 | Bytecode:
api_1 | 0000000: 2abb 0015 59b7 0016 b500 022a b400 022b
api_1 | 0000010: b600 17b6 0018 2ab4 0002 2bb6 0019 b600
api_1 | 0000020: 1a2a b400 022b b600 1bb6 001c 2a2b 1904
api_1 | 0000030: 1905 2ab6 001d 2ab4 0002 b600 1e12 20b6
api_1 | 0000040: 0021 c000 223a 0601 1906 a500 2d19 062b
api_1 | 0000050: b600 23b8 0024 3a07 2ab4 0002 b600 1e12
api_1 | 0000060: 2019 07b6 0025 57a7 0010 3a07 2b19 07b6
api_1 | 0000070: 0027 1907 b600 282b b600 292a b400 02b6
api_1 | 0000080: 002a 2bb6 002b 3a07 1907 2ab4 0002 b600
api_1 | 0000090: 2c57 2a01 b500 02b1
api_1 | Exception Handler Table:
api_1 | bci [77, 103] => handler: 106
api_1 | Stackmap Table:
api_1 | full_frame(@106,{Object[#45],Object[#104],Object[#34],Object[#34],Object[#34],Object[#105],Object[#34]},{Object[#38]})
api_1 | same_frame(@119)
api_1 |
api_1 | at org.docx4j.org.apache.xalan.processor.XSLTSchema.build(XSLTSchema.java:674)
api_1 | at org.docx4j.org.apache.xalan.processor.XSLTSchema.<init>(XSLTSchema.java:72)
api_1 | at org.docx4j.org.apache.xalan.processor.StylesheetHandler.<init>(StylesheetHandler.java:1287)
api_1 | at org.docx4j.org.apache.xalan.processor.TransformerFactoryImpl.newTemplatesHandler(TransformerFactoryImpl.java:371)
api_1 | at org.docx4j.org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:862)
api_1 | at org.docx4j.XmlUtils.getTransformerTemplate(XmlUtils.java:1262)
api_1 | at org.docx4j.convert.out.fo.renderers.AbstractFORenderer.<clinit>(AbstractFORenderer.java:49)
api_1 | at org.docx4j.convert.out.fo.FOConversionContext.initializeFoRenderer(FOConversionContext.java:207)
api_1 | at org.docx4j.convert.out.fo.FOConversionContext.<init>(FOConversionContext.java:95)
api_1 | at org.docx4j.convert.out.fo.AbstractFOExporter.createContext(AbstractFOExporter.java:101)
api_1 | at org.docx4j.convert.out.fo.AbstractFOExporter.createContext(AbstractFOExporter.java:47)
api_1 | at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:72)
api_1 | at org.docx4j.Docx4J.toFO(Docx4J.java:712)
api_1 | at ru.ispras.kb.controllers.DocxExporter.createDocx(DocxExporter.scala:157)
api_1 | at ru.ispras.kb.controllers.ObjectExporter.$anonfun$getObjectsAndSend$2(ObjectExporter.scala:87)
api_1 | at scala.util.Success.$anonfun$map$1(Try.scala:255)
api_1 | at scala.util.Success.map(Try.scala:213)
api_1 | at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
api_1 | at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
api_1 | at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
api_1 | at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
api_1 | at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56)
api_1 | at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:93)
api_1 | at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
api_1 | at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
api_1 | at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:93)
api_1 | at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:48)
api_1 | at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
api_1 | at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
api_1 | at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
api_1 | at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
api_1 | at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
api_1 | at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Have you any suggestion? Is is my serious bottleneck now
I attach the document which I want to convert.