Skip to content

Commit

Permalink
Text color selection for watermark (#2415)
Browse files Browse the repository at this point in the history
* added custom color selection for Watermark

* using the same translation as AddStampRequest.customColor for the new watermark.customColor

* fixed the space issue between words
  • Loading branch information
saikumarjetti authored Dec 7, 2024
1 parent cb6e1cd commit b47df3d
Show file tree
Hide file tree
Showing 40 changed files with 99 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public ResponseEntity<byte[]> addWatermark(@ModelAttribute AddWatermarkRequest r
float opacity = request.getOpacity();
int widthSpacer = request.getWidthSpacer();
int heightSpacer = request.getHeightSpacer();
String customColor = request.getCustomColor();
boolean convertPdfToImage = request.isConvertPDFToImage();

// Load the input PDF
Expand Down Expand Up @@ -97,7 +98,8 @@ public ResponseEntity<byte[]> addWatermark(@ModelAttribute AddWatermarkRequest r
widthSpacer,
heightSpacer,
fontSize,
alphabet);
alphabet,
customColor);
} else if ("image".equalsIgnoreCase(watermarkType)) {
addImageWatermark(
contentStream,
Expand Down Expand Up @@ -136,7 +138,8 @@ private void addTextWatermark(
int widthSpacer,
int heightSpacer,
float fontSize,
String alphabet)
String alphabet,
String colorString)
throws IOException {
String resourceDir = "";
PDFont font = new PDType1Font(Standard14Fonts.FontName.HELVETICA);
Expand Down Expand Up @@ -173,7 +176,18 @@ private void addTextWatermark(
}

contentStream.setFont(font, fontSize);
contentStream.setNonStrokingColor(Color.LIGHT_GRAY);

Color redactColor;
try {
if (!colorString.startsWith("#")) {
colorString = "#" + colorString;
}
redactColor = Color.decode(colorString);
} catch (NumberFormatException e) {

redactColor = Color.LIGHT_GRAY;
}
contentStream.setNonStrokingColor(redactColor);

String[] textLines = watermarkText.split("\\\\n");
float maxLineWidth = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class AddWatermarkRequest extends PDFFile {
@Schema(description = "The height spacer between watermark elements", example = "50")
private int heightSpacer;

@Schema(description = "The color for watermark", defaultValue = "#d3d3d3")
private String customColor = "#d3d3d3";

@Schema(description = "Convert the redacted PDF to an image", defaultValue = "false")
private boolean convertPDFToImage;
}
1 change: 1 addition & 0 deletions src/main/resources/messages_ar_AR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=تشفير
#watermark
watermark.title=إضافة علامة مائية
watermark.header=إضافة علامة مائية
watermark.customColor=لون نص مخصص
watermark.selectText.1=حدد PDF لإضافة العلامة المائية إليه:
watermark.selectText.2=نص العلامة المائية:
watermark.selectText.3=حجم الخط:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_az_AZ.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Şifrlə
#watermark
watermark.title=Watermark Əlavə Et
watermark.header=Watermark Əlavə Et
watermark.customColor=Fərdi Mətn Rəngi
watermark.selectText.1=Watermark əlavə olunacaq PDF-i seç
watermark.selectText.2=Watermark Mətni:
watermark.selectText.3=Şrift Ölçüsü:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_bg_BG.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Шифроване
#watermark
watermark.title=Добавяне на воден знак
watermark.header=Добавяне на воден знак
watermark.customColor=Персонализиран цвят на текста
watermark.selectText.1=Изберете PDF, към който да добавите воден знак:
watermark.selectText.2=Текст на воден знак:
watermark.selectText.3=Размер на шрифта:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ca_CA.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Encripta
#watermark
watermark.title=Afegir Marca d'Aigua
watermark.header=Afegir Marca d'Aigua
watermark.customColor=Color de Text Personalitzat
watermark.selectText.1=Selecciona el PDF per afegir la Marca d'Aigua:
watermark.selectText.2=Text de la Marca d'Aigua
watermark.selectText.3=Mida de la Font:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_cs_CZ.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Šifrovat
#watermark
watermark.title=Přidat vodoznak
watermark.header=Přidat vodoznak
watermark.customColor=Vlastní barva textu
watermark.selectText.1=Vyberte PDF, ke kterému chcete přidat vodoznak:
watermark.selectText.2=Text vodoznaku:
watermark.selectText.3=Velikost písma:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_da_DK.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Kryptér
#watermark
watermark.title=Tilføj Vandmærke
watermark.header=Tilføj Vandmærke
watermark.customColor=Brugerdefineret Tekstfarve
watermark.selectText.1=Vælg PDF til at tilføje vandmærke:
watermark.selectText.2=Vandmærketekst:
watermark.selectText.3=Skriftstørrelse:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Verschlüsseln
#watermark
watermark.title=Wasserzeichen hinzufügen
watermark.header=Wasserzeichen hinzufügen
watermark.customColor=Benutzerdefinierte Textfarbe
watermark.selectText.1=PDF auswählen, dem ein Wasserzeichen hinzugefügt werden soll:
watermark.selectText.2=Wasserzeichen Text:
watermark.selectText.3=Schriftgröße:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_el_GR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Κρυπτογράφηση
#watermark
watermark.title=Προσθήκη Υδατογραφήματος
watermark.header=Προσθήκη Υδατογραφήματος
watermark.customColor=Προσαρμοσμένο χρώμα κειμένου
watermark.selectText.1=Επιλέξτε PDF για την προσθήκη του υδατογραφήματος:
watermark.selectText.2=Κείμενο Υδατογραφήματος:
watermark.selectText.3=Μέγεθος Κειμένου:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en_GB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Encrypt
#watermark
watermark.title=Add Watermark
watermark.header=Add Watermark
watermark.customColor=Custom Text Colour
watermark.selectText.1=Select PDF to add watermark to:
watermark.selectText.2=Watermark Text:
watermark.selectText.3=Font Size:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Encrypt
#watermark
watermark.title=Add Watermark
watermark.header=Add Watermark
watermark.customColor=Custom Text Color
watermark.selectText.1=Select PDF to add watermark to:
watermark.selectText.2=Watermark Text:
watermark.selectText.3=Font Size:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_es_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Encriptar
#watermark
watermark.title=Añadir marca de agua
watermark.header=Añadir marca de agua
watermark.customColor=Personalizar color de texto
watermark.selectText.1=Seleccionar PDF para añadir marca de agua:
watermark.selectText.2=Texto de la marca de agua:
watermark.selectText.3=Tamaño de la Fuente:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_eu_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Enkriptatu
#watermark
watermark.title=Gehitu ur-marka
watermark.header=Gehitu ur-marka
watermark.customColor=Custom Text Color
watermark.selectText.1=Hautatu PDFa ur-marka gehitzeko:
watermark.selectText.2=Ur-markaren testua:
watermark.selectText.3=Letra-tipoaren tamaina:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Chiffrer
#watermark
watermark.title=Ajouter un filigrane
watermark.header=Ajouter un filigrane
watermark.customColor=Couleur de texte personnalisée
watermark.selectText.1=PDF auquel ajouter un filigrane
watermark.selectText.2=Texte du filigrane
watermark.selectText.3=Taille de police
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ga_IE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Criptigh
#watermark
watermark.title=Cuir Uisce leis
watermark.header=Cuir Uisce leis
watermark.customColor=Dath Téacs Saincheaptha
watermark.selectText.1=Roghnaigh PDF chun comhartha uisce a chur leis:
watermark.selectText.2=Téacs Comhartha Uisce:
watermark.selectText.3=Méid cló:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_hi_IN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=एन्क्रिप्ट करें
#watermark
watermark.title=वॉटरमार्क जोड़ें
watermark.header=वॉटरमार्क जोड़ें
watermark.customColor=संवैधित टेक्स्ट रंग
watermark.selectText.1=वॉटरमार्क जोड़ने के लिए पीडीएफ चुनें:
watermark.selectText.2=वॉटरमार्क टेक्स्ट:
watermark.selectText.3=फ़ॉन्ट साइज़:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_hr_HR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Šifriraj
#watermark
watermark.title=Dodaj vodeni žig
watermark.header=Dodaj vodeni žig
watermark.customColor=Prilagođena boja teksta
watermark.selectText.1=Izaberite PDF za dodavanje vodenog žiga:
watermark.selectText.2=Tekst vodenog žiga:
watermark.selectText.3=Veličina fonta:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_hu_HU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Titkosítás
#watermark
watermark.title=Vízjel hozzáadása
watermark.header=Vízjel hozzáadása
watermark.customColor=Egyéni szövegszín
watermark.selectText.1=Válassza ki a PDF-t, amelyhez vízjelet kíván hozzáadni:
watermark.selectText.2=Vízjel szövege:
watermark.selectText.3=Betűméret:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_id_ID.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Enkripsi
#watermark
watermark.title=Tambahkan Watermark
watermark.header=Tambahkan Watermark
watermark.customColor=Warna Teks Kustom
watermark.selectText.1=Pilih PDF untuk menambahkan watermark:
watermark.selectText.2=Text Watermark:
watermark.selectText.3=Ukuran Huruf:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_it_IT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Crittografa
#watermark
watermark.title=Aggiungi Filigrana
watermark.header=Aggiungi filigrana
watermark.customColor=Colore testo personalizzato
watermark.selectText.1=Seleziona PDF a cui aggiungere la filigrana:
watermark.selectText.2=Testo:
watermark.selectText.3=Dimensione carattere:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ja_JP.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=暗号化
#watermark
watermark.title=透かしの追加
watermark.header=透かしの追加
watermark.customColor=文字色のカスタム
watermark.selectText.1=透かしを追加するPDFを選択:
watermark.selectText.2=透かしのテキスト:
watermark.selectText.3=文字サイズ:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ko_KR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=암호화
#watermark
watermark.title=워터마크 추가
watermark.header=워터마크 추가
watermark.customColor=사용자 정의 텍스트 색상
watermark.selectText.1=워터마크를 추가할 PDF 선택:
watermark.selectText.2=워터마크 텍스트:
watermark.selectText.3=폰트 크기:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_nl_NL.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Versleutelen
#watermark
watermark.title=Watermerk toevoegen
watermark.header=Watermerk toevoegen
watermark.customColor=Aangepaste tekstkleur
watermark.selectText.1=Selecteer PDF om watermerk toe te voegen:
watermark.selectText.2=Watermerk tekst:
watermark.selectText.3=Tekengrootte:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_no_NB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Krypter
#watermark
watermark.title=Legg til vannmerke
watermark.header=Legg til vannmerke
watermark.customColor=Tilpasset Tekstfarge
watermark.selectText.1=Velg PDF-fil å legge til vannmerke på:
watermark.selectText.2=Vannmerketekst:
watermark.selectText.3=Skriftstørrelse:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_pl_PL.properties
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Zablokuj
#watermark
watermark.title=Dodaj znak wodny
watermark.header=Dodaj znak wodny
watermark.customColor=Własny kolor tekstu
watermark.selectText.1=Wybierz dokument PDF, do którego chcesz dodać znak wodny:
watermark.selectText.2=Treść znaku wodnego:
watermark.selectText.3=Rozmiar czcionki:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Criptografar
#watermark
watermark.title=Adicionar marca d'água
watermark.header=Adicionar marca d'água
watermark.customColor=Cor de texto personalizada
watermark.selectText.1=Selecione PDF para adicionar a marca d'água:
watermark.selectText.2=Texto da marca d'água:
watermark.selectText.3=Tamanho da fonte:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_pt_PT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Proteger
#watermark
watermark.title=Adicionar Marca d'Água
watermark.header=Adicionar Marca d'Água
watermark.customColor=Personalizar a cor do texto
watermark.selectText.1=Seleccione o PDF para Adicionar a Marca d'Água
watermark.selectText.2=Texto da Marca d'Água
watermark.selectText.3=Tamanho da Fonte
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ro_RO.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Criptează
#watermark
watermark.title=Adaugă Filigran
watermark.header=Adaugă Filigran
watermark.customColor=Culoare Text Personalizată
watermark.selectText.1=Selectează PDF-ul la care să adaugi filigranul:
watermark.selectText.2=Textul Filigranului:
watermark.selectText.3=Mărimea fontului:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ru_RU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Шифровать
#watermark
watermark.title=Добавить водяной знак
watermark.header=Добавить водяной знак
watermark.customColor=Настроенный цвет текста
watermark.selectText.1=Выберите PDF, чтобы добавить водяной знак:
watermark.selectText.2=Текст водяного знака:
watermark.selectText.3=Размер шрифта:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_sk_SK.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Zašifrovať
#watermark
watermark.title=Pridať vodotlač
watermark.header=Pridať vodotlač
watermark.customColor=Vlastná farba textu
watermark.selectText.1=Vyberte PDF, do ktorého chcete pridať vodotlač:
watermark.selectText.2=Text vodotlače:
watermark.selectText.3=Veľkosť písma:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_sr_LATN_RS.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Enkriptuj
#watermark
watermark.title=Dodaj vodeni žig
watermark.header=Dodaj vodeni žig
watermark.customColor=Custom Text Color
watermark.selectText.1=Izaberite PDF za dodavanje vodenog žiga:
watermark.selectText.2=Tekst vodenog žiga:
watermark.selectText.3=Veličina fonta:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_sv_SE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Kryptera
#watermark
watermark.title=Lägg till vattenstämpel
watermark.header=Lägg till vattenstämpel
watermark.customColor=Anpassad textfärg
watermark.selectText.1=Välj PDF för att lägga till vattenstämpel till:
watermark.selectText.2=Vattenmärkestext:
watermark.selectText.3=Teckenstorlek:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_th_TH.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=เข้ารหัส
#watermark
watermark.title=เพิ่มลายน้ำ
watermark.header=เพิ่มลายน้ำ
watermark.customColor=สีข้อความที่กำหนดเอง
watermark.selectText.1=เลือก PDF เพื่อเพิ่มลายน้ำ:
watermark.selectText.2=ข้อความลายน้ำ:
watermark.selectText.3=ขนาดฟอนต์:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_tr_TR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Şifrele
#watermark
watermark.title=Filigran Ekle
watermark.header=Filigran Ekle
watermark.customColor=Özel Metin Rengi
watermark.selectText.1=Filigran eklemek için PDF seçin:
watermark.selectText.2=Filigran Metni:
watermark.selectText.3=Yazı Boyutu:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_uk_UA.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Шифрувати
#watermark
watermark.title=Додати водяний знак
watermark.header=Додати водяний знак
watermark.customColor=Користувацький колір тексту
watermark.selectText.1=Виберіть PDF, щоб додати водяний знак:
watermark.selectText.2=Текст водяного знаку:
watermark.selectText.3=Розмір шрифту:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_vi_VN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=Mã hóa
#watermark
watermark.title=Thêm hình mờ
watermark.header=Thêm hình mờ
watermark.customColor=Màu văn bản tùy chỉnh
watermark.selectText.1=Chọn PDF để thêm hình mờ:
watermark.selectText.2=Văn bản hình mờ:
watermark.selectText.3=Cỡ chữ:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=加密
#watermark
watermark.title=添加水印
watermark.header=添加水印
watermark.customColor=自定义文本颜色
watermark.selectText.1=选择要添加水印的PDF:
watermark.selectText.2=水印文本:
watermark.selectText.3=字体大小:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_zh_TW.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ addPassword.submit=加密
#watermark
watermark.title=新增浮水印
watermark.header=新增浮水印
watermark.customColor=自訂文字顏色
watermark.selectText.1=選擇要新增浮水印的 PDF:
watermark.selectText.2=浮水印文字:
watermark.selectText.3=字型大小:
Expand Down
Loading

0 comments on commit b47df3d

Please sign in to comment.