Document extractor service (#15665)
* Document extractor service * Fixing vendor modules * Addressing PR Review comments * Some small simplifications * Fixing a linter complain * simplifying a bit the code using package variables Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
04ef5c682e
Коммит
8d5be2d657
30
vendor/code.sajari.com/docconv/pdf.go
сгенерированный
поставляемый
Обычный файл
30
vendor/code.sajari.com/docconv/pdf.go
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,30 @@
|
||||
// +build !ocr
|
||||
|
||||
package docconv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func ConvertPDF(r io.Reader) (string, map[string]string, error) {
|
||||
|
||||
f, err := NewLocalFile(r)
|
||||
if err != nil {
|
||||
return "", nil, fmt.Errorf("error creating local file: %v", err)
|
||||
}
|
||||
defer f.Done()
|
||||
|
||||
bodyResult, metaResult, convertErr := ConvertPDFText(f.Name())
|
||||
if convertErr != nil {
|
||||
return "", nil, convertErr
|
||||
}
|
||||
if bodyResult.err != nil {
|
||||
return "", nil, bodyResult.err
|
||||
}
|
||||
if metaResult.err != nil {
|
||||
return "", nil, metaResult.err
|
||||
}
|
||||
return bodyResult.body, metaResult.meta, nil
|
||||
|
||||
}
|
||||
Ссылка в новой задаче
Block a user