1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-13 03:00:10 +01:00
This commit is contained in:
Anthony Stirling 2024-06-02 12:02:01 +01:00
parent eb526a5d0c
commit 31938b662c
2 changed files with 21 additions and 22 deletions

View File

@ -137,8 +137,7 @@ public class FakeScanControllerWIP {
// Normalize the kernel // Normalize the kernel
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
if(sum != 0) if (sum != 0) data[i] /= sum;
data[i] /= sum;
} }
Kernel kernel = new Kernel(size, size, data); Kernel kernel = new Kernel(size, size, data);

View File

@ -22,11 +22,11 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import io.github.pixee.security.Filenames; import io.github.pixee.security.Filenames;
import stirling.software.SPDF.controller.web.AccountWebController;
import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult;
public class PDFToFile { public class PDFToFile {
private static final Logger logger = LoggerFactory.getLogger(PDFToFile.class); private static final Logger logger = LoggerFactory.getLogger(PDFToFile.class);
public ResponseEntity<byte[]> processPdfToHtml(MultipartFile inputFile) public ResponseEntity<byte[]> processPdfToHtml(MultipartFile inputFile)
throws IOException, InterruptedException { throws IOException, InterruptedException {
@ -163,25 +163,25 @@ public class PDFToFile {
fileBytes = FileUtils.readFileToByteArray(outputFile); fileBytes = FileUtils.readFileToByteArray(outputFile);
} else { } else {
// Return output files in a ZIP archive // Return output files in a ZIP archive
fileName = pdfBaseName + "To" + outputFormat + ".zip"; fileName = pdfBaseName + "To" + outputFormat + ".zip";
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try (ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream)) { try (ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream)) {
for (File outputFile : outputFiles) { for (File outputFile : outputFiles) {
ZipEntry entry = new ZipEntry(outputFile.getName()); ZipEntry entry = new ZipEntry(outputFile.getName());
zipOutputStream.putNextEntry(entry); zipOutputStream.putNextEntry(entry);
try (FileInputStream fis = new FileInputStream(outputFile)) { try (FileInputStream fis = new FileInputStream(outputFile)) {
IOUtils.copy(fis, zipOutputStream); IOUtils.copy(fis, zipOutputStream);
} catch (IOException e) { } catch (IOException e) {
logger.error("Exception writing zip entry", e); logger.error("Exception writing zip entry", e);
} }
zipOutputStream.closeEntry();
}
} catch (IOException e) {
logger.error("Exception writing zip", e);
}
fileBytes = byteArrayOutputStream.toByteArray(); zipOutputStream.closeEntry();
}
} catch (IOException e) {
logger.error("Exception writing zip", e);
}
fileBytes = byteArrayOutputStream.toByteArray();
} }
} finally { } finally {