languages,add images and flags

This commit is contained in:
Anthony Stirling 2023-05-13 09:42:56 +01:00
parent 6ee5daf884
commit ae22066bad
11 changed files with 180 additions and 29 deletions

View file

@ -221,7 +221,7 @@ fileToPDF.submit=\u062A\u062D\u0648\u064A\u0644 \u0625\u0644\u0649 PDF
#Add image
addImage.title=إضافة صورة
addImage.header=إضافة صورة إلى PDF (العمل قيد التقدم)
addImage.header=إضافة صورة إلى PDF
addImage.everyPage=كل صفحة؟
addImage.submit=إضافة صورة

View file

@ -108,7 +108,54 @@ home.PDFToXML.desc=Converteix PDF a format XML
home.ScannerImageSplit.title=Detecta/Divideix fotos escanejades
home.ScannerImageSplit.desc=Divideix múltiples fotos dins del PDF/foto
home.sign.title=Sign
home.sign.desc=Afegeix signatura al PDF mitjançant dibuix, text o imatge
home.flatten.title=Aplanar
home.flatten.desc=Elimineu tots els elements i formularis interactius d'un PDF
home.repair.title=Reparar
home.repair.desc=Intenta reparar un PDF danyat o trencat
home.removeBlanks.title=Elimina les pàgines en blanc
home.removeBlanks.desc=Detecta i elimina les pàgines en blanc d'un document
home.compare.title=Compara
home.compare.desc=Compara i mostra les diferències entre 2 documents PDF
downloadPdf=Descarregueu PDF
text=Text
font=Tipus de lletra
removeBlanks.title=Elimina els espais en blanc
removeBlanks.header=Elimina les pàgines en blanc
removeBlanks.threshold=Llindar:
removeBlanks.thresholdDesc=Llindar per determinar el blanc que ha de ser un píxel blanc
removeBlanks.whitePercent=Percentatge blanc (%):
removeBlanks.whitePercentDesc=Percentatge de pàgina que ha de ser blanca per eliminar-la
removeBlanks.submit=Elimina els espais en blanc
compare.title=Comparar
compare.header=Compara PDF
compare.document.1=Document 1
compare.document.2=Document 2
compare.submit=Comparar
sign.title=Sign
sign.header=Firma els PDF
sign.upload=Penja la imatge
sign.draw=Dibuixa la signatura
sign.text=Entrada de text
sign.clear=Esborrar
sign.add=Afegeix
repair.title=Reparar
repair.header=Repara els PDF
repair.submit=Reparar
flatten.title=Aplanar
flatten.header=Aplana els PDF
flatten.submit=Aplanar
ScannerImageSplit.selectText.1=Llindar d'angle:
ScannerImageSplit.selectText.2=Estableix l'angle absolut mínim necessari perquè la imatge es giri (per defecte: 10).

View file

@ -217,7 +217,7 @@ fileToPDF.submit=In PDF konvertieren
#Add image
addImage.title=Bild hinzufügen
addImage.header=Ein Bild einfügen (Work in progress)
addImage.header=Ein Bild einfügen
addImage.everyPage=Jede Seite?
addImage.submit=Bild hinzufügen

View file

@ -233,7 +233,7 @@ compress.submit=Compress
#Add image
addImage.title=Add Image
addImage.header=Add image to PDF (Work in progress)
addImage.header=Add image to PDF
addImage.everyPage=Every Page?
addImage.submit=Add image

View file

@ -231,7 +231,7 @@ compress.submit=Comprimir
#Add image
addImage.title=Añade Imagen
addImage.header=Añade image de PDF (Trabajo en progreso)
addImage.header=Añade image de PDF
addImage.everyPage=¿Todas las páginas?
addImage.submit=Añade imagen

View file

@ -220,7 +220,7 @@ fileToPDF.submit=Convertir en PDF
#Add image
addImage.title=Ajouter une image
addImage.header=Ajouter une image au PDF (Travail en cours)
addImage.header=Ajouter une image au PDF
addImage.everyPage=Chaque page?
addImage.submit=Ajouter une image

View file

@ -52,7 +52,7 @@ home.pdfOrganiser.title=整理
home.pdfOrganiser.desc=按任何顺序删除/重新排列页面。
home.addImage.title=在PDF中添加图片
home.addImage.desc=将图像添加到PDF的设定位置上(正在完成)
home.addImage.desc=将图像添加到PDF的设定位置上
home.watermark.title=添加水印
home.watermark.desc=在PDF中添加一个自定义的水印。

View file

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icons-es-ct" viewBox="0 0 640 480">
<path fill="#fcdd09" d="M0 0h640v480H0z"/>
<path stroke="#da121a" stroke-width="60" d="M0 90h810m0 120H0m0 120h810m0 120H0" transform="scale(.79012 .88889)"/>
</svg>

After

Width:  |  Height:  |  Size: 255 B

View file

@ -346,7 +346,7 @@ function compareVersions(version1, version2) {
<img src="images/flags/cn.svg" alt="icon" width="20" height="15"> 简体中文
</a>
<a class="dropdown-item lang_dropdown-item" href="" data-language-code="ca_CA">
<img src="images/flags/ca.svg" alt="icon" width="20" height="15"> Català
<img src="images/flags/es-ct.svg" alt="icon" width="20" height="15"> Català
</a>
</div>
</li>

View file

@ -1,10 +1,11 @@
<!DOCTYPE html>
<html th:lang="${#locale.toString()}" th:lang-direction="#{language.direction}" xmlns:th="http://www.thymeleaf.org">
<th:block th:insert="~{fragments/common :: head(title=#{addImage.title})}"></th:block>
<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=#{addImage.title})}"></th:block>
<script src="js/interact.min.js"></script>
</head>
<body>
<div id="page-container">
<div id="content-wrap">
@ -14,23 +15,121 @@
<div class="row justify-content-center">
<div class="col-md-6">
<h2 th:text="#{addImage.header}"></h2>
<form method="post" th:action="@{add-image}" enctype="multipart/form-data">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf')}"></div>
<div class="custom-file">
<input type="file" class="custom-file-input" id="fileInput2" name="fileInput2" accept="image/*" required>
<label class="custom-file-label" for="fileInput2" th:text="#{imgPrompt}"></label>
<!-- pdf selector -->
<div th:replace="~{fragments/common :: fileSelector(name='pdf-upload', multiple=false, accept='application/pdf')}"></div>
<script>
let originalFileName = '';
document.querySelector('input[name=pdf-upload]').addEventListener('change', async (event) => {
const file = event.target.files[0];
if (file) {
originalFileName = file.name.replace(/\.[^/.]+$/, "");
const pdfData = await file.arrayBuffer();
const pdfDoc = await pdfjsLib.getDocument({ data: pdfData }).promise;
await DraggableUtils.renderPage(pdfDoc, 0);
document.querySelectorAll(".show-on-file-selected").forEach(el => {
el.style.cssText = '';
})
}
});
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".show-on-file-selected").forEach(el => {
el.style.cssText = "display:none !important";
})
});
</script>
<div class="tab-group show-on-file-selected">
<div class="tab-container" th:title="#{addImage.upload}">
<div th:replace="~{fragments/common :: fileSelector(name='image-upload', multiple=true, accept='image/*', inputText=#{imgPrompt})}"></div>
<script>
const imageUpload = document.querySelector('input[name=image-upload]');
imageUpload.addEventListener('change', e => {
if(!e.target.files) {
return;
}
for (const imageFile of e.target.files) {
var reader = new FileReader();
reader.readAsDataURL(imageFile);
reader.onloadend = function (e) {
DraggableUtils.createDraggableCanvasFromUrl(e.target.result);
};
}
});
</script>
</div>
</div>
<!-- draggables box -->
<div id="box-drag-container" class="show-on-file-selected">
<canvas id="pdf-canvas"></canvas>
<script src="js/draggable-utils.js"></script>
<div class="draggable-buttons-box ignore-rtl">
<button class="btn btn-outline-secondary" onclick="DraggableUtils.deleteDraggableCanvas(DraggableUtils.getLastInteracted())">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6Z"/>
<path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1ZM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118ZM2.5 3h11V2h-11v1Z"/>
</svg>
</button>
<button class="btn btn-outline-secondary" onclick="document.documentElement.getAttribute('lang-direction')==='rtl' ? DraggableUtils.incrementPage() : DraggableUtils.decrementPage()" style="margin-left:auto">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/>
</svg>
</button>
<button class="btn btn-outline-secondary" onclick="document.documentElement.getAttribute('lang-direction')==='rtl' ? DraggableUtils.decrementPage() : DraggableUtils.incrementPage()">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
</svg>
</button>
</div>
<div class="form-group">
<label for="x">X</label> <input type="number" class="form-control" id="x" name="x" step="0.01" required>
</div>
<div class="form-group">
<label for="y">Y</label> <input type="number" class="form-control" id="y" name="y" step="0.01" required>
</div>
<div class="form-group">
<input type="checkbox" id="everyPage" name="everyPage" value="true"> <label for="everyPage" th:text="#{addImage.everyPage}"></label>
</div>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{addImage.submit}"></button>
</form>
<style>
#box-drag-container {
position: relative;
margin: 20px 0;
}
#pdf-canvas {
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.384);
width: 100%;
}
.draggable-buttons-box {
position: absolute;
top: 0;
padding: 10px;
width: 100%;
display: flex;
gap: 5px;
}
.draggable-buttons-box > button {
z-index: 10;
background-color: rgba(13, 110, 253, 0.1);
}
.draggable-canvas {
border: 1px solid red;
position: absolute;
touch-action: none;
user-select: none;
top: 0px;
left: 0;
}
</style>
</div>
<!-- download button -->
<div class="margin-auto-parent">
<button id="download-pdf" class="btn btn-primary mb-2 show-on-file-selected margin-center">Download PDF</button>
</div>
<script>
document.getElementById("download-pdf").addEventListener('click', async() => {
const modifiedPdf = await DraggableUtils.getOverlayedPdfDocument();
const modifiedPdfBytes = await modifiedPdf.save();
const blob = new Blob([modifiedPdfBytes], { type: 'application/pdf' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = originalFileName + '_addedImage.pdf';
link.click();
});
</script>
</div>
</div>
</div>
@ -38,5 +137,4 @@
<div th:insert="~{fragments/footer.html :: footer}"></div>
</div>
</body>
</html>

View file

@ -30,9 +30,11 @@
<!-- pdf selector -->
<div th:replace="~{fragments/common :: fileSelector(name='pdf-upload', multiple=false, accept='application/pdf')}"></div>
<script>
let originalFileName = '';
document.querySelector('input[name=pdf-upload]').addEventListener('change', async (event) => {
const file = event.target.files[0];
if (file) {
originalFileName = file.name.replace(/\.[^/.]+$/, "");
const pdfData = await file.arrayBuffer();
const pdfDoc = await pdfjsLib.getDocument({ data: pdfData }).promise;
await DraggableUtils.renderPage(pdfDoc, 0);
@ -275,7 +277,7 @@
const blob = new Blob([modifiedPdfBytes], { type: 'application/pdf' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'signed-document.pdf';
link.download = originalFileName + '_signed.pdf';
link.click();
});
</script>