-
Hi, I've been using 0.14.0 for PDF generation and recently tried to upgrade to 0.17.1 (can't go higher because stuck with CE2). I'm not sure if I'm doing something wrong or if there is an issue with the library. I'm using java 11, not sure if that could cause issues. I've tried with laika versions 0.16.1 and 0.17.0 as well but I get the same error. Here is a small example using ZIO. import zio.interop.catz._
import laika.io.implicits._
val blocker = Blocker.liftExecutionContext(
ExecutionContext.fromExecutor(Executors.newCachedThreadPool()),
)
val parser: MarkupParser = MarkupParser.of(Markdown).build
val renderer: Resource[Task, BinaryTreeRenderer[Task]] =
Renderer.of(PDF).io(blocker).sequential[Task].build
parser.parse("hello") match {
case Left(error) => Task.fail(new IllegalArgumentException(s"Could not parse markdown $error"))
case Right(doc) =>
(for {
file <- Managed.makeEffect[File](File.createTempFile("KYC", ".pdf"))(_.delete())
_ <- Managed.effect(println("Created file"))
_ <- renderer.toManagedZIO.tapM(
_.from(DocumentTreeRoot(DocumentTree(doc.path, Seq(doc)))).toFile(file).render,
)
_ <- Managed.effect(println("Rendered pdf"))
} yield file).use(file => Task.succeed(println(file.getAbsolutePath)))
}
// Output
Created file
[Fatal Error] :3:48: The prefix "fo" for element "fo:block" is not bound.
org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 48; The prefix "fo" for element "fo:block" is not bound.
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 48; The prefix "fo" for element "fo:block" is not bound.
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502)
at laika.render.pdf.PDFRenderer.$anonfun$render$16(PDFRenderer.scala:76)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
For parsing you are using a pure parser without theme support, for rendering you are using the effectful renderers. This way the default FO template does not get applied (older versions had a fallback and therefore still worked in that case). but theme support (introduced in 0.16 and containing all default templates) is not part of the pure base parsers/renderers). You can fix this either by using a transformer instead of a separate parser and renderer or by using an IO-based parser, too ( |
Beta Was this translation helpful? Give feedback.
-
@Edvin-san I converted the issue to a discussion, pinging you here as I'm not sure you get a notification for that. |
Beta Was this translation helpful? Give feedback.
For parsing you are using a pure parser without theme support, for rendering you are using the effectful renderers. This way the default FO template does not get applied (older versions had a fallback and therefore still worked in that case). but theme support (introduced in 0.16 and containing all default templates) is not part of the pure base parsers/renderers).
You can fix this either by using a transformer instead of a separate parser and renderer or by using an IO-based parser, too (
MarkupParser.of(Markdown).io(blocker).sequential[Task]
).