Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f866c8a61f | ||
|
|
472082cb03 | ||
|
|
b5a59ddb6a | ||
|
|
82da3c0027 | ||
|
|
908e75de39 |
10
README.md
10
README.md
@@ -25,17 +25,23 @@ I will support and fix/add things to this if there is a demand [Discord](https:/
|
||||
- Reorganize PDF pages into different orders.
|
||||
- Add images to PDFs at specified locations. (WIP)
|
||||
- Rotating PDFs in 90 degree increments.
|
||||
- Compressing PDFs to decrease their filesize.
|
||||
- Compressing PDFs to decrease their filesize. (Using OCRMyPDF)
|
||||
- Add and remove passwords
|
||||
- Set PDF Permissions
|
||||
- Add watermark(s)
|
||||
- Convert Any common file to PDF (using LibreOffice)
|
||||
- Extract images from PDF
|
||||
- OCR on PDF (Using OCRMyPDF)
|
||||
- Edit metadata
|
||||
- Dark mode support.
|
||||
- Custom download options
|
||||
- Parallel file processing and downloads
|
||||
|
||||
## Technologies used
|
||||
- Spring Boot + Thymeleaf
|
||||
- PDFBox
|
||||
- e-iceblue spire.pdf.free (for PDF compression untill i find a nicer way)
|
||||
- LibreOffice for advanced conversions
|
||||
- OcrMyPdf https://github.com/ocrmypdf/OCRmyPDF
|
||||
- HTML, CSS, JavaScript
|
||||
- Docker
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '3.0.3'
|
||||
id 'org.springframework.boot' version '3.0.4'
|
||||
id 'io.spring.dependency-management' version '1.1.0'
|
||||
}
|
||||
|
||||
group = 'stirling.software'
|
||||
version = '0.4.0'
|
||||
version = '0.4.2'
|
||||
sourceCompatibility = '17'
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -80,6 +80,8 @@ public class CompressController {
|
||||
// Prepare the OCRmyPDF command
|
||||
List<String> command = new ArrayList<>();
|
||||
command.add("ocrmypdf");
|
||||
command.add("--skip-text");
|
||||
command.add("--tesseract-timeout=0");
|
||||
command.add("--optimize");
|
||||
command.add(String.valueOf(optimizeLevel));
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import stirling.software.SPDF.utils.PdfUtils;
|
||||
import stirling.software.SPDF.utils.WatermarkRemover;
|
||||
import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
|
||||
|
||||
@Controller
|
||||
public class WatermarkController {
|
||||
@@ -45,7 +46,8 @@ public class WatermarkController {
|
||||
@PostMapping("/add-watermark")
|
||||
public ResponseEntity<byte[]> addWatermark(@RequestParam("fileInput") MultipartFile pdfFile, @RequestParam("watermarkText") String watermarkText,
|
||||
@RequestParam(defaultValue = "30", name = "fontSize") float fontSize, @RequestParam(defaultValue = "0", name = "rotation") float rotation,
|
||||
@RequestParam(defaultValue = "50", name = "widthSpacer") int widthSpacer, @RequestParam(defaultValue = "50", name = "heightSpacer") int heightSpacer)
|
||||
@RequestParam(defaultValue = "0.5", name = "opacity") float opacity,
|
||||
@RequestParam(defaultValue = "50", name = "widthSpacer") int widthSpacer, @RequestParam(defaultValue = "50", name = "heightSpacer") int heightSpacer)
|
||||
throws IOException {
|
||||
|
||||
// Load the input PDF
|
||||
@@ -53,9 +55,18 @@ public class WatermarkController {
|
||||
|
||||
// Create a page in the document
|
||||
for (PDPage page : document.getPages()) {
|
||||
|
||||
|
||||
|
||||
|
||||
// Get the page's content stream
|
||||
PDPageContentStream contentStream = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.APPEND, true);
|
||||
|
||||
// Set transparency
|
||||
PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
|
||||
graphicsState.setNonStrokingAlphaConstant(opacity);
|
||||
contentStream.setGraphicsStateParameters(graphicsState);
|
||||
|
||||
// Set font of watermark
|
||||
PDFont font = PDType1Font.HELVETICA_BOLD;
|
||||
contentStream.beginText();
|
||||
|
||||
@@ -127,8 +127,15 @@ addImage.submit=إضافة صورة
|
||||
|
||||
#compress
|
||||
compress.title=ضغط
|
||||
compress.header=ضغط ملف PDF
|
||||
compress.compressLevel=القيمة بين 1 و 100 (يتم تقليل 1 إلى أقصى حد)
|
||||
compress.header=\u0636\u063A\u0637 PDF
|
||||
compress.credit=\u062A\u0633\u062A\u062E\u062F\u0645 \u0647\u0630\u0647 \u0627\u0644\u062E\u062F\u0645\u0629 OCRmyPDF \u0644\u0636\u063A\u0637 / \u062A\u062D\u0633\u064A\u0646 PDF.
|
||||
compress.selectText.1 = \u0645\u0633\u062A\u0648\u0649 \u0627\u0644\u062A\u062D\u0633\u064A\u0646:
|
||||
compress.selectText.2=0 (\u0628\u062F\u0648\u0646 \u062A\u062D\u0633\u064A\u0646)
|
||||
compress.selectText.3=1 (\u0627\u0641\u062A\u0631\u0627\u0636\u064A\u060C \u062A\u062D\u0633\u064A\u0646 \u0628\u062F\u0648\u0646 \u0641\u0642\u062F\u0627\u0646)
|
||||
compress.selectText.4=2 (\u062A\u062D\u0633\u064A\u0646 \u0636\u064A\u0627\u0639)
|
||||
compress.selectText.5=3 (\u062A\u062D\u0633\u064A\u0646 \u0636\u064A\u0627\u0639 \u060C \u0623\u0643\u062B\u0631 \u0639\u062F\u0648\u0627\u0646\u064A\u0629)
|
||||
compress.selectText.6=\u062A\u0645\u0643\u064A\u0646 \u0639\u0631\u0636 \u0627\u0644\u0648\u064A\u0628 \u0627\u0644\u0633\u0631\u064A\u0639 (\u062E\u0637\u064A PDF)
|
||||
compress.selectText.7=\u062A\u0645\u0643\u064A\u0646 \u062A\u0631\u0645\u064A\u0632 JBIG2 \u0627\u0644\u0645\u0641\u0642\u0648\u062F
|
||||
compress.submit=ضغط
|
||||
|
||||
|
||||
@@ -218,6 +225,7 @@ watermark.selectText.3=حجم الخط:
|
||||
watermark.selectText.4=دوران (0-360):
|
||||
watermark.selectText.5=widthSpacer (مسافة بين كل علامة مائية أفقيًا):
|
||||
watermark.selectText.6=heightSpacer (مسافة بين كل علامة مائية عموديًا):
|
||||
watermark.selectText.7=\u0627\u0644\u062A\u0639\u062A\u064A\u0645 (0\u066A - 100\u066A):
|
||||
watermark.submit=إضافة علامة مائية
|
||||
|
||||
#remove-watermark
|
||||
|
||||
@@ -127,7 +127,14 @@ addImage.submit=Bild hinzufügen
|
||||
#compress
|
||||
compress.title=Komprimieren
|
||||
compress.header=PDF komprimieren
|
||||
compress.compressLevel=Wert zwischen 1 und 100 (1 ist am meisten komprimiert)
|
||||
compress.credit=Dieser Dienst verwendet OCRmyPDF für die PDF-Komprimierung/-Optimierung.
|
||||
compress.selectText.1=Optimierungsstufe:
|
||||
compress.selectText.2=0 (Keine Optimierung)
|
||||
compress.selectText.3=1 (Standard, verlustfreie Optimierung)
|
||||
compress.selectText.4=2 (Verlustbehaftete Optimierung)
|
||||
compress.selectText.5=3 (Verlustbehaftete Optimierung, aggressiver)
|
||||
compress.selectText.6=Schnelle Webansicht aktivieren (PDF linearisieren)
|
||||
compress.selectText.7=Verlustbehaftete JBIG2-Kodierung aktivieren
|
||||
compress.submit=Komprimieren
|
||||
|
||||
|
||||
@@ -217,6 +224,7 @@ watermark.selectText.3=Schriftgröße:
|
||||
watermark.selectText.4=Drehung (0-360):
|
||||
watermark.selectText.5=breiteSpacer (horizontaler Abstand zwischen den einzelnen Wasserzeichen):
|
||||
watermark.selectText.6=höheSpacer (vertikaler Abstand zwischen den einzelnen Wasserzeichen):
|
||||
watermark.selectText.7=Deckkraft (0% - 100 %):
|
||||
watermark.submit=Wasserzeichen hinzufügen
|
||||
|
||||
#remove-watermark
|
||||
|
||||
@@ -222,6 +222,7 @@ watermark.selectText.3=Font Size:
|
||||
watermark.selectText.4=Rotation (0-360):
|
||||
watermark.selectText.5=widthSpacer (Space between each watermark horizontally):
|
||||
watermark.selectText.6=heightSpacer (Space between each watermark vertically):
|
||||
watermark.selectText.7=Opacity (0% - 100%):
|
||||
watermark.submit=Add Watermark
|
||||
|
||||
#remove-watermark
|
||||
|
||||
@@ -124,7 +124,14 @@ addImage.submit=Add image
|
||||
#compress
|
||||
compress.title=Compress
|
||||
compress.header=Compress PDF
|
||||
compress.compressLevel=Value between 1 and 100 (1 being most reduced)
|
||||
compress.credit=This service uses OCRmyPDF for PDF Compress/Optimisation.
|
||||
compress.selectText.1=Optimization level:
|
||||
compress.selectText.2=0 (No optimization)
|
||||
compress.selectText.3=1 (Default, lossless optimization)
|
||||
compress.selectText.4=2 (Lossy optimization)
|
||||
compress.selectText.5=3 (Lossy optimization, more aggressive)
|
||||
compress.selectText.6=Enable fast web view (linearize PDF)
|
||||
compress.selectText.7=Enable lossy JBIG2 encoding
|
||||
compress.submit=Compress
|
||||
|
||||
|
||||
@@ -215,6 +222,7 @@ watermark.selectText.3=Font Size:
|
||||
watermark.selectText.4=Rotation (0-360):
|
||||
watermark.selectText.5=widthSpacer (Space between each watermark horizontally):
|
||||
watermark.selectText.6=heightSpacer (Space between each watermark vertically):
|
||||
watermark.selectText.7=Opacity (0% - 100%):
|
||||
watermark.submit=Add Watermark
|
||||
|
||||
#remove-watermark
|
||||
|
||||
@@ -133,7 +133,14 @@ addImage.submit=Ajouter une image
|
||||
#compress
|
||||
compress.title=Compresser
|
||||
compress.header=Compresser le PDF
|
||||
compress.compressLevel=Valeur entre 1 et 100 (1 étant le plus réduit)
|
||||
compress.credit=Ce service utilise OCRmyPDF pour la compression/optimisation PDF.
|
||||
compress.selectText.1=Niveau d\u2019optimisation :
|
||||
compress.selectText.2=0 (pas d\u2019optimisation)
|
||||
compress.selectText.3=1 (par défaut, optimisation sans perte)
|
||||
compress.selectText.4=2 (optimisation avec perte)
|
||||
compress.selectText.5=3 (optimisation avec perte, plus agressive)
|
||||
compress.selectText.6=Activer l\u2019affichage Web rapide (linéariser PDF)
|
||||
compress.selectText.7=Activer l\u2019encodage JBIG2 avec perte
|
||||
compress.submit=Compresser
|
||||
|
||||
|
||||
@@ -223,6 +230,7 @@ watermark.selectText.3=Taille de la police
|
||||
watermark.selectText.4=Rotation (0-360)Â:
|
||||
watermark.selectText.5=widthSpacer (Espace entre chaque filigrane horizontalement)Â:
|
||||
watermark.selectText.6=heightSpacer (Espace entre chaque filigrane verticalement)Â:
|
||||
watermark.selectText.7=Opacité (0 % - 100 %):
|
||||
watermark.submit=Ajouter un filigrane
|
||||
|
||||
#remove-watermark
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<input type="checkbox" name="jbig2Lossy" id="jbig2Lossy">
|
||||
<label for="jbig2Lossy" th:text="#{compress.selectText.7}"></label>
|
||||
</div>
|
||||
<button type="submit" th:text="#{compress.submit}"></button>
|
||||
<button type="submit" class="btn btn-primary" th:text="#{compress.submit}"></button>
|
||||
</form>
|
||||
<p class="mt-3" th:text="#{compress.credit}"></p>
|
||||
|
||||
|
||||
@@ -26,6 +26,45 @@
|
||||
<label for="fontSize" th:text="#{watermark.selectText.3}"></label>
|
||||
<input type="text" id="fontSize" name="fontSize" class="form-control" value="30" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="opacity" th:text="#{watermark.selectText.7}"></label>
|
||||
<input type="text" id="opacity" name="opacityText" class="form-control" value="50" onblur="updateopacityValue()" />
|
||||
<input type="hidden" id="opacityReal" name="opacity" value="0.5">
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
const opacityInput = document.getElementById('opacity');
|
||||
const opacityRealInput = document.getElementById('opacityReal');
|
||||
|
||||
const updateopacityValue = () => {
|
||||
let percentageValue = parseFloat(opacityInput.value.replace('%', ''));
|
||||
if (isNaN(percentageValue)) {
|
||||
percentageValue = 0;
|
||||
}
|
||||
percentageValue = Math.min(Math.max(percentageValue, 0), 100);
|
||||
opacityInput.value = `${percentageValue}`;
|
||||
opacityRealInput.value = (percentageValue / 100).toFixed(2);
|
||||
};
|
||||
|
||||
const appendPercentageSymbol = () => {
|
||||
if (!opacityInput.value.endsWith('%')) {
|
||||
opacityInput.value += '%';
|
||||
}
|
||||
};
|
||||
|
||||
opacityInput.addEventListener('focus', () => {
|
||||
opacityInput.value = opacityInput.value.replace('%', '');
|
||||
});
|
||||
opacityInput.addEventListener('blur', () => {
|
||||
updateopacityValue();
|
||||
appendPercentageSymbol();
|
||||
});
|
||||
|
||||
// Set initial values
|
||||
updateopacityValue();
|
||||
appendPercentageSymbol();
|
||||
</script>
|
||||
<div class="form-group">
|
||||
<label for="rotation" th:text="#{watermark.selectText.4}"></label>
|
||||
<input type="text" id="rotation" name="rotation" class="form-control" value="45" />
|
||||
|
||||
Reference in New Issue
Block a user