more fixes

This commit is contained in:
Anthony Stirling 2024-02-10 00:21:00 +00:00
parent 5a52e3d6dd
commit 6f72096953
4 changed files with 16 additions and 10 deletions

View File

@ -23,8 +23,8 @@ import stirling.software.SPDF.utils.WebResponseUtils;
public class ConvertHtmlToPDF { public class ConvertHtmlToPDF {
@Autowired @Autowired
@Qualifier("installBookAndHtmlFormats") @Qualifier("bookAndHtmlFormatsInstalled")
private boolean installBookAndHtmlFormats; private boolean bookAndHtmlFormatsInstalled;
@PostMapping(consumes = "multipart/form-data", value = "/html/pdf") @PostMapping(consumes = "multipart/form-data", value = "/html/pdf")
@Operation( @Operation(
@ -47,7 +47,10 @@ public class ConvertHtmlToPDF {
} }
byte[] pdfBytes = byte[] pdfBytes =
FileToPdf.convertHtmlToPdf( FileToPdf.convertHtmlToPdf(
request, fileInput.getBytes(), originalFilename, installBookAndHtmlFormats); request,
fileInput.getBytes(),
originalFilename,
bookAndHtmlFormatsInstalled);
String outputFilename = String outputFilename =
originalFilename.replaceFirst("[.][^.]+$", "") originalFilename.replaceFirst("[.][^.]+$", "")

View File

@ -33,8 +33,8 @@ import stirling.software.SPDF.utils.WebResponseUtils;
public class ConvertMarkdownToPdf { public class ConvertMarkdownToPdf {
@Autowired @Autowired
@Qualifier("htmlFormatsInstalled") @Qualifier("bookAndHtmlFormatsInstalled")
private boolean htmlFormatsInstalled; private boolean bookAndHtmlFormatsInstalled;
@PostMapping(consumes = "multipart/form-data", value = "/markdown/pdf") @PostMapping(consumes = "multipart/form-data", value = "/markdown/pdf")
@Operation( @Operation(
@ -69,7 +69,10 @@ public class ConvertMarkdownToPdf {
byte[] pdfBytes = byte[] pdfBytes =
FileToPdf.convertHtmlToPdf( FileToPdf.convertHtmlToPdf(
null, htmlContent.getBytes(), "converted.html", htmlFormatsInstalled); null,
htmlContent.getBytes(),
"converted.html",
bookAndHtmlFormatsInstalled);
String outputFilename = String outputFilename =
originalFilename.replaceFirst("[.][^.]+$", "") originalFilename.replaceFirst("[.][^.]+$", "")

View File

@ -29,8 +29,8 @@ import stirling.software.SPDF.utils.WebResponseUtils;
public class ConvertWebsiteToPDF { public class ConvertWebsiteToPDF {
@Autowired @Autowired
@Qualifier("installBookAndHtmlFormats") @Qualifier("bookAndHtmlFormatsInstalled")
private boolean installBookAndHtmlFormats; private boolean bookAndHtmlFormatsInstalled;
@PostMapping(consumes = "multipart/form-data", value = "/url/pdf") @PostMapping(consumes = "multipart/form-data", value = "/url/pdf")
@Operation( @Operation(
@ -53,7 +53,7 @@ public class ConvertWebsiteToPDF {
// Prepare the OCRmyPDF command // Prepare the OCRmyPDF command
List<String> command = new ArrayList<>(); List<String> command = new ArrayList<>();
if (!installBookAndHtmlFormats) { if (!bookAndHtmlFormatsInstalled) {
command.add("weasyprint"); command.add("weasyprint");
} else { } else {
command.add("wkhtmltopdf"); command.add("wkhtmltopdf");

View File

@ -14,7 +14,7 @@ system:
googlevisibility: false # 'true' to allow Google visibility (via robots.txt), 'false' to disallow googlevisibility: false # 'true' to allow Google visibility (via robots.txt), 'false' to disallow
enableAlphaFunctionality: false # Set to enable functionality which might need more testing before it fully goes live (This feature might make no changes) enableAlphaFunctionality: false # Set to enable functionality which might need more testing before it fully goes live (This feature might make no changes)
customApplications: customApplications:
installBookAndHtmlFormats: false # Installs Calibre for book format conversion (For non docker it must be manually downloaded but will need to be true to show in UI) bookAndHtmlFormatsInstalled: false # Installs Calibre for book format conversion (For non docker it must be manually downloaded but will need to be true to show in UI)
#ui: #ui:
# appName: exampleAppName # Application's visible name # appName: exampleAppName # Application's visible name