Add stamp, fix html, change accepts

This commit is contained in:
Anthony Stirling
2024-01-28 17:36:17 +00:00
parent 75cf3ed0c1
commit be1904749b
18 changed files with 816 additions and 14 deletions

View File

@@ -12,7 +12,7 @@ import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import stirling.software.SPDF.model.api.GeneralFile;
import stirling.software.SPDF.model.api.converters.HTMLToPdfRequest;
import stirling.software.SPDF.utils.FileToPdf;
import stirling.software.SPDF.utils.WebResponseUtils;
@@ -30,7 +30,8 @@ public class ConvertHtmlToPDF {
summary = "Convert an HTML or ZIP (containing HTML and CSS) to PDF",
description =
"This endpoint takes an HTML or ZIP file input and converts it to a PDF format.")
public ResponseEntity<byte[]> HtmlToPdf(@ModelAttribute GeneralFile request) throws Exception {
public ResponseEntity<byte[]> HtmlToPdf(@ModelAttribute HTMLToPdfRequest request)
throws Exception {
MultipartFile fileInput = request.getFileInput();
if (fileInput == null) {
@@ -45,7 +46,7 @@ public class ConvertHtmlToPDF {
}
byte[] pdfBytes =
FileToPdf.convertHtmlToPdf(
fileInput.getBytes(), originalFilename, htmlFormatsInstalled);
request, fileInput.getBytes(), originalFilename, htmlFormatsInstalled);
String outputFilename =
originalFilename.replaceFirst("[.][^.]+$", "")

View File

@@ -68,7 +68,7 @@ public class ConvertMarkdownToPdf {
byte[] pdfBytes =
FileToPdf.convertHtmlToPdf(
htmlContent.getBytes(), "converted.html", htmlFormatsInstalled);
null, htmlContent.getBytes(), "converted.html", htmlFormatsInstalled);
String outputFilename =
originalFilename.replaceFirst("[.][^.]+$", "")