* 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>
31 строка
553 B
Go
31 строка
553 B
Go
// +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
|
|
|
|
}
|