Allow to convert html->pdf via weasyprint

This commit is contained in:
eikek
2022-11-05 00:48:32 +01:00
parent a5315f44ee
commit df75fbddcd
8 changed files with 146 additions and 10 deletions

View File

@ -551,6 +551,10 @@ Docpell Update Check
"""
}
# Which HTML->PDF converter command to use. One of: wkhtmlpdf,
# weasyprint.
html-converter = "wkhtmlpdf"
# To convert HTML files into PDF files, the external tool
# wkhtmltopdf is used.
wkhtmlpdf {
@ -568,7 +572,22 @@ Docpell Update Check
]
timeout = "2 minutes"
}
working-dir = ${java.io.tmpdir}"/docspell-convert"
working-dir = ${java.io.tmpdir}"/docspell-wkhtmltopdf"
}
# An alternative to wkhtmltopdf is weasyprint.
weasyprint {
command = {
program = "weasyprint"
args = [
"--optimize-size", "all",
"--encoding", "{{encoding}}",
"-",
"{{outfile}}"
]
timeout = "2 minutes"
}
working-dir = ${java.io.tmpdir}"/docspell-weasyprint"
}
# To convert image files to PDF files, tesseract is used. This

View File

@ -10,6 +10,7 @@ import cats.effect.Async
import docspell.config.Implicits._
import docspell.config.{ConfigFactory, FtsType, Validation}
import docspell.convert.ConvertConfig.HtmlConverter
import docspell.scheduler.CountingScheme
import docspell.store.Db
@ -38,6 +39,9 @@ object ConfigFile {
implicit val mailAddressReader: ConfigReader[MailAddress] =
ConfigReader[String].emap(reason(MailAddress.parse))
implicit val htmlConverterReader: ConfigReader[HtmlConverter] =
ConfigReader[String].emap(reason(HtmlConverter.fromString))
}
def validate: Validation[Config] =