fixes
This commit is contained in:
@@ -44,14 +44,14 @@ public class CustomPDDocumentFactory {
|
|||||||
return createNewBytesBasedOnOldDocument(document);
|
return createNewBytesBasedOnOldDocument(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] createNewBytesBasedOnOldDocument(PDDocument oldDocument) throws IOException {
|
public byte[] createNewBytesBasedOnOldDocument(PDDocument oldDocument) throws IOException {
|
||||||
PDDocument document = new PDDocument();
|
|
||||||
pdfMetadataService.setMetadataToPdf(
|
pdfMetadataService.setMetadataToPdf(
|
||||||
document, pdfMetadataService.extractMetadataFromPdf(oldDocument), true);
|
oldDocument, pdfMetadataService.extractMetadataFromPdf(oldDocument), true);
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
document.save(baos);
|
oldDocument.save(baos);
|
||||||
document.close();
|
oldDocument.close();
|
||||||
return baos.toByteArray();
|
return baos.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class CustomHtmlSanitizer {
|
|||||||
.and(new HtmlPolicyBuilder().disallowElements("noscript").toFactory());
|
.and(new HtmlPolicyBuilder().disallowElements("noscript").toFactory());
|
||||||
|
|
||||||
public static String sanitize(String html) {
|
public static String sanitize(String html) {
|
||||||
return POLICY.sanitize(html);
|
String htmlAfter = POLICY.sanitize(html);
|
||||||
|
return htmlAfter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ public class FileToPdf {
|
|||||||
List<String> command = new ArrayList<>();
|
List<String> command = new ArrayList<>();
|
||||||
if (!htmlFormatsInstalled) {
|
if (!htmlFormatsInstalled) {
|
||||||
command.add("weasyprint");
|
command.add("weasyprint");
|
||||||
command.add("-e utf-8");
|
command.add("-e");
|
||||||
|
command.add("utf-8");
|
||||||
|
command.add("-v");
|
||||||
command.add(tempInputFile.toString());
|
command.add(tempInputFile.toString());
|
||||||
command.add(tempOutputFile.toString());
|
command.add(tempOutputFile.toString());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user