How can I produce a PDF from a XML String using Pandoc Haskell library?

Two issues:

export :: (PandocMonad m, MonadIO m, MonadMask m) => String -> Template T.Text -> Pandoc -> m (Either BL.ByteString BL.ByteString)
export pdfengine tmpl = makePDF pdfengine [] writeLaTeX def {writerTemplate = Just tmpl}

The writer parameter of makePDF should be writeLaTeX

And, we are forced to update the parameter

def {writerTemplate = Just tmpl}

where tmpl has type Template Text.

Otherwise, pandoc would produce a fragment (instead a standalone document). And that’s why it can’t convert that LaTeX document to PDF.

One of the parameters of the type WriterOptions used to be writeStandalone :: Bool, but that was deprecated. When a Template is used, the writer always generates a standalone document.

3 Likes