mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-25 16:45:05 +00:00
Fix converted filename
Mark it by default with a string from the config file. Issue: 397
This commit is contained in:
parent
ef7cb4e779
commit
6db5c39d78
@ -6,6 +6,7 @@ import docspell.convert.flexmark.MarkdownConfig
|
||||
|
||||
case class ConvertConfig(
|
||||
chunkSize: Int,
|
||||
convertedFilenamePart: String,
|
||||
maxImageSize: Int,
|
||||
markdown: MarkdownConfig,
|
||||
wkhtmlpdf: WkHtmlPdfConfig,
|
||||
|
@ -23,6 +23,7 @@ object ConversionTest extends SimpleTestSuite with FileChecks {
|
||||
|
||||
val convertConfig = ConvertConfig(
|
||||
8192,
|
||||
"converted",
|
||||
3000 * 3000,
|
||||
MarkdownConfig("body { padding: 2em 5em; }"),
|
||||
WkHtmlPdfConfig(
|
||||
|
@ -328,6 +328,11 @@ docspell.joex {
|
||||
# as used with the rest server.
|
||||
chunk-size = 524288
|
||||
|
||||
# A string used to change the filename of the converted pdf file.
|
||||
# If empty, the original file name is used for the pdf file ( the
|
||||
# extension is always replaced with `pdf`).
|
||||
converted-filename-part = "converted"
|
||||
|
||||
# When reading images, this is the maximum size. Images that are
|
||||
# larger are not processed.
|
||||
max-image-size = ${docspell.joex.extraction.ocr.max-image-size}
|
||||
|
@ -135,7 +135,11 @@ object ConvertPdf {
|
||||
) = {
|
||||
val hint =
|
||||
MimeTypeHint.advertised(MimeType.pdf).withName(ra.name.getOrElse("file.pdf"))
|
||||
val newName = ra.name.map(n => s"$n.pdf")
|
||||
val newName =
|
||||
ra.name
|
||||
.map(FileName.apply)
|
||||
.map(_.withExtension("pdf").withPart(cfg.convertedFilenamePart, '.'))
|
||||
.map(_.fullName)
|
||||
ctx.store.bitpeace
|
||||
.saveNew(pdf, cfg.chunkSize, MimetypeHint(hint.filename, hint.advertised))
|
||||
.compile
|
||||
|
Loading…
x
Reference in New Issue
Block a user