e4a76e96af
* CSS corrections * HTML corrections * JS corrections * JAVA corrections * remove tab * CSS corrections 2 * JS corrections 2 * back to the roots * max-linie 127 * add slash hr|br * return bootstrap-icons.css * return bootstrap-icons.min.css * return bootstrap.min.css * Update bootstrap-icons.css * Update bootstrap-icons.min.css * Update bootstrap-icons.min.css * Update bootstrap.min.css * CSS corrections * HTML corrections * JS corrections * JAVA corrections * remove tab * CSS corrections 2 * JS corrections 2 * back to the roots * max-linie 127 * add slash hr|br * return bootstrap-icons.css * Update bootstrap-icons.css * Bootstrap CSS * Update prism.css
65 lines
No EOL
2.5 KiB
HTML
65 lines
No EOL
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<html th:lang="${#locale.language}" th:lang-direction="#{language.direction}" xmlns:th="http://www.thymeleaf.org">
|
|
<head>
|
|
<th:block th:insert="~{fragments/common :: head(title=#{removeAnnotations.title}, header=#{removeAnnotations.header})}"></th:block>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="page-container">
|
|
<div id="content-wrap">
|
|
<th:block th:insert="~{fragments/navbar.html :: navbar}"></th:block>
|
|
<br /><br />
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-6">
|
|
<h2 th:text="#{removeAnnotations.header}"></h2>
|
|
<form id="pdfForm" class="mb-3">
|
|
<div class="custom-file">
|
|
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf', remoteCall='false')}"></div>
|
|
</div>
|
|
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{removeAnnotations.submit}"></button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<th:block th:insert="~{fragments/footer.html :: footer}"></th:block>
|
|
</div>
|
|
<script src="js/local-pdf-input-download.js"></script>
|
|
<script>
|
|
document.getElementById('pdfForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const { PDFDocument } = PDFLib;
|
|
|
|
const processFile = async (file) => {
|
|
const origFileUrl = URL.createObjectURL(file);
|
|
const formPdfBytes = await fetch(origFileUrl).then(res => res.arrayBuffer());
|
|
const pdfDoc = await PDFDocument.load(formPdfBytes, { ignoreEncryption: true });
|
|
|
|
const pages = pdfDoc.getPages();
|
|
|
|
for (let i = 0; i < pages.length; ++i) {
|
|
const page = pages[i];
|
|
const annotations = page.node.Annots();
|
|
if (!annotations) continue;
|
|
const ctx = annotations.context;
|
|
|
|
for (let j = 0; j < annotations.size(); ++j) {
|
|
const annotation = annotations.get(j);
|
|
ctx.delete(annotation);
|
|
}
|
|
}
|
|
|
|
const pdfBytes = await pdfDoc.save();
|
|
const pdfBlob = new Blob([pdfBytes], { type: 'application/pdf' });
|
|
const fileName = (file.name ? file.name.replace('.pdf', '') : 'pdf') + '_removed_annotations.pdf';
|
|
|
|
return { processedData: pdfBlob, fileName };
|
|
};
|
|
|
|
await downloadFilesWithCallback(processFile);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |