Documentation ¶
Index ¶
- Variables
- func CheckDependencies() (available, missing []string)
- func CountDirectory(directory string) int
- func GetCachedDirectoryFiles(directoryname string) ([]fs.DirEntry, error)
- func GetCachedDocPreview(name string) string
- func GetDirectories() ([]fs.DirEntry, error)
- func GetDirectoryFiles(directory string) ([]fs.DirEntry, error)
- func GetDocPreview(name string) string
- func GetInboundFiles() ([]fs.DirEntry, error)
- func GetOcrInboundFunc(progress chan float32, currentFile chan string) (runner func(), err error)
- func GetTimestampFilePrefix() string
- func MoveFileToDirectory(name, newName, directoryName string) (string, error)
- func OcrPdf(name string) error
- func OpenDocExternal(path string) error
- func PrintCheckDeps()
- func RemoveTimeStampFilePrefix(name string) string
- func UpdateDirectoryFilesCache(directoryname string)
- func UpdateFilePreviewCache(filename string)
- func WarmDirectoryFilesCache(directories []fs.DirEntry)
- func WarmInboundFilePreviewCache(files []fs.DirEntry)
Constants ¶
This section is empty.
Variables ¶
var ( Inbound = "." Dest = "~/Documents" TimestampPrefixMatch, _ = regexp.Compile(`^\d\d\d\d\d\d\d\d-\d\d\d\d\d\d\.\d\d\d_(.*)$`) )
var (
DEPENDENCIES = map[string]string{
"pdftotext": "display textual preview of pdf",
"xdg-open": "open pdf in your default viewer",
"ocrmypdf": "run ocr on pdf",
"img2pdf": "convert image to pdf",
"ag": "list your documents very fast",
"fzf": "fuzzy search through your documents",
"rga": "ripgrep-all - use in combination with fzf to fuzzy search your documents",
}
)
var (
OCRMYPDF_ERRCODES = map[int]string{
0: "Everything worked as expected.",
1: "Invalid arguments, exited with an error.",
2: "The input file does not seem to be a valid PDF.",
3: "An external program required by OCRmyPDF is missing.",
4: "An output file was created, but it does not seem to be a valid PDF. The file will be available.",
5: "The user running OCRmyPDF does not have sufficient permissions to read the input file and write the output file.",
6: "The file already appears to contain text so it may not need OCR. See output message.",
7: "An error occurred in an external program (child process) and OCRmyPDF cannot continue.",
8: "The input PDF is encrypted. OCRmyPDF does not read encrypted PDFs. Use another program such as qpdf to remove encryption.",
9: "A custom configuration file was forwarded to Tesseract using --tesseract-config, and Tesseract rejected this file.",
10: "A valid PDF was created, PDF/A conversion failed. The file will be available.",
15: "Some other error occurred.",
130: "The program was interrupted by pressing Ctrl+C.",
}
)
Functions ¶
func CheckDependencies ¶
func CheckDependencies() (available, missing []string)
MissingExternDependencies returns a slice with the names of executables which are missing on the system to use all the functionality
func CountDirectory ¶
CountDirectory returns the number of files in a directory
func GetCachedDirectoryFiles ¶
GetCachedDirectoryFiles returns the list of files for the given directory name from the cache
func GetCachedDocPreview ¶
GetCachedDocPreview returns the text preview for the given file name from the cache
func GetDirectories ¶
GetDirectories returns a slice of the existing directories
func GetDirectoryFiles ¶
GetDirectoryFiles returns a slice of files in the directory
func GetDocPreview ¶
GetDocPreview returns the text layer of a pdf as simple string by running the external commant pdftotext on it
func GetInboundFiles ¶
GetInboundFiles returns a slice of all inbound files
func GetOcrInboundFunc ¶
GetOcrInboundFunc returns a function that can be run async to iterate all inbound files and add a text layer to scans progress can be watched by the channels that are passed here
func GetTimestampFilePrefix ¶
func GetTimestampFilePrefix() string
GetTimestampFilePrefix returns as timestamp prefix Quite long, not sure about that yet, but it avoids duplicates / overwrites
func MoveFileToDirectory ¶
MoveFileToDirectory moves the given file with the given new name to the given directory. This also triggers a cache update for this directory.
func OpenDocExternal ¶
OpenDocExternal tries to open the document in the systems default application for given type
func PrintCheckDeps ¶
func PrintCheckDeps()
PrintCheckDeps runs a check for all external dependecies and prints out the result
func RemoveTimeStampFilePrefix ¶
RemoveTimeStampFilePrefix would remove the timestamp from the files name if the file is prefixed with a timestamp that matches this programs default
func UpdateDirectoryFilesCache ¶
func UpdateDirectoryFilesCache(directoryname string)
UpdateDirectoryFilesCache upates the list of files for the given directory name in the cache
func UpdateFilePreviewCache ¶
func UpdateFilePreviewCache(filename string)
UpdateFilePreviewCache upates the text preview for the given file name in the cache
func WarmDirectoryFilesCache ¶
WarmDirectoryFilesCache loads the list of files per directory and puts it into the cache the first element will be loaded sync to have it available as soon as the it is displayed by some ui the rest will be loaded async in goroutines
func WarmInboundFilePreviewCache ¶
WarmInboundFilePreviewCache loads text previews for all inbound files into the cache the first preview will be loaded sync to have it available as soon as the it is displayed by some ui the rest will be loaded async in goroutines
Types ¶
This section is empty.