Skip to content

Commit

Permalink
Merge branch 'main' into sync_readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Frooodle authored Aug 15, 2024
2 parents 0398c09 + d32da95 commit 136052d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
Expand All @@ -27,6 +26,7 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

import stirling.software.SPDF.model.ApplicationProperties;
import stirling.software.SPDF.model.api.misc.ProcessPdfWithOcrRequest;
import stirling.software.SPDF.utils.ProcessExecutor;
import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult;
Expand All @@ -37,10 +37,10 @@
@Tag(name = "Misc", description = "Miscellaneous APIs")
public class OCRController {

private static final Logger logger = LoggerFactory.getLogger(OCRController.class);
@Autowired ApplicationProperties applicationProperties;

public List<String> getAvailableTesseractLanguages() {
String tessdataDir = "/usr/share/tessdata";
String tessdataDir = applicationProperties.getSystem().getTessdataDir();
File[] files = new File(tessdataDir).listFiles();
if (files == null) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -14,10 +15,14 @@
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.tags.Tag;

import stirling.software.SPDF.model.ApplicationProperties;

@Controller
@Tag(name = "Misc", description = "Miscellaneous APIs")
public class OtherWebController {

@Autowired ApplicationProperties applicationProperties;

@GetMapping("/compress-pdf")
@Hidden
public String compressPdfForm(Model model) {
Expand Down Expand Up @@ -97,7 +102,7 @@ public String printFileForm(Model model) {
}

public List<String> getAvailableTesseractLanguages() {
String tessdataDir = "/usr/share/tessdata";
String tessdataDir = applicationProperties.getSystem().getTessdataDir();
File[] files = new File(tessdataDir).listFiles();
if (files == null) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,15 @@ public static class System {
private boolean showUpdate;
private Boolean showUpdateOnlyAdmin;
private boolean customHTMLFiles;
private String tessdataDir;

public String getTessdataDir() {
return tessdataDir;
}

public void setTessdataDir(String tessdataDir) {
this.tessdataDir = tessdataDir;
}

public boolean isCustomHTMLFiles() {
return customHTMLFiles;
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/settings.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ system:
showUpdate: false # see when a new update is available
showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true'
customHTMLFiles: false # enable to have files placed in /customFiles/templates override the existing template html files
tessdataDir: /usr/share/tessdata # Path to the directory containing the Tessdata files. This setting is relevant for Windows systems. For Windows users, this path should be adjusted to point to the appropriate directory where the Tessdata files are stored.

ui:
appName: '' # Application's visible name
Expand All @@ -69,4 +70,4 @@ metrics:

# Automatically Generated Settings (Do Not Edit Directly)
AutomaticallyGenerated:
key: example
key: example

0 comments on commit 136052d

Please sign in to comment.