Corrected api structure, updated deps, clean up

This commit is contained in:
Dario Ghunney Ware 2025-06-20 15:31:36 +01:00
parent f16ddeb583
commit 7c8f9804d3
49 changed files with 67 additions and 306 deletions

View File

@ -27,5 +27,6 @@ dependencies {
api 'jakarta.servlet:jakarta.servlet-api:6.1.0'
api 'org.snakeyaml:snakeyaml-engine:2.9'
api "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.9"
api 'com.sun.mail:jakarta.mail:2.0.1'
api 'jakarta.mail:jakarta.mail-api:2.1.3'
runtimeOnly 'org.eclipse.angus:angus-mail:2.0.3'
}

View File

@ -9,22 +9,25 @@ import org.apache.pdfbox.pdmodel.PageMode;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class PDFAttachmentUtils {
public class AttachmentUtils {
/**
* Sets the PDF catalog viewer preferences to display attachments in the viewer.
*
* @param document The <code>PDDocument</code> to modify.
* @param pageMode The <code>PageMode</code> to set for the PDF viewer. <code>PageMode</code>
* values: <code>UseNone</code>, <code>UseOutlines</code>, <code>UseThumbs</code>, <code>
* FullScreen</code>, <code>UseOC</code>, <code>UseAttachments</code>.
*/
public static void setCatalogViewerPreferences(PDDocument document, PageMode pageMode) {
try {
PDDocumentCatalog catalog = document.getDocumentCatalog();
if (catalog != null) {
// Get the catalog's COS dictionary to work with low-level PDF objects
COSDictionary catalogDict = catalog.getCOSObject();
// Set PageMode to UseAttachments - this is the standard PDF specification approach
// PageMode values: UseNone, UseOutlines, UseThumbs, FullScreen, UseOC,
// UseAttachments
catalog.setPageMode(pageMode);
catalogDict.setName(COSName.PAGE_MODE, pageMode.stringValue());
// Also set viewer preferences for better attachment viewing experience
COSDictionary viewerPrefs =
(COSDictionary) catalogDict.getDictionaryObject(COSName.VIEWER_PREFERENCES);
if (viewerPrefs == null) {
@ -32,19 +35,15 @@ public class PDFAttachmentUtils {
catalogDict.setItem(COSName.VIEWER_PREFERENCES, viewerPrefs);
}
// Set NonFullScreenPageMode to UseAttachments as fallback for viewers that support
// it
viewerPrefs.setName(
COSName.getPDFName("NonFullScreenPageMode"), pageMode.stringValue());
// Additional viewer preferences that may help with attachment display
viewerPrefs.setBoolean(COSName.getPDFName("DisplayDocTitle"), true);
log.info(
"Set PDF PageMode to UseAttachments to automatically show attachments pane");
}
} catch (Exception e) {
// Log error but don't fail the entire operation for viewer preferences
log.error("Failed to set catalog viewer preferences for attachments", e);
}
}

View File

@ -1,6 +1,6 @@
package stirling.software.common.util;
import static stirling.software.common.util.PDFAttachmentUtils.setCatalogViewerPreferences;
import static stirling.software.common.util.AttachmentUtils.setCatalogViewerPreferences;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

View File

@ -84,9 +84,9 @@ public class EndpointConfiguration {
}
public void disableGroup(String group) {
Set<String> disabledEndpoints = endpointGroups.get(group);
if (disabledEndpoints != null) {
for (String endpoint : disabledEndpoints) {
Set<String> endpoints = endpointGroups.get(group);
if (endpoints != null) {
for (String endpoint : endpoints) {
disableEndpoint(endpoint);
}
}

View File

@ -5,9 +5,9 @@ import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@ -18,6 +18,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.model.api.misc.AddAttachmentRequest;
import stirling.software.SPDF.service.AttachmentServiceInterface;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.WebResponseUtils;
@ -33,24 +34,23 @@ public class AttachmentController {
private final AttachmentServiceInterface pdfAttachmentService;
@SuppressWarnings("DataFlowIssue")
@PostMapping(consumes = "multipart/form-data", value = "/add-attachments")
@Operation(
summary = "Add attachments to PDF",
description =
"This endpoint adds embedded files (attachments) to a PDF and sets the PageMode to UseAttachments to make them visible. Input:PDF + Files Output:PDF Type:MISO")
public ResponseEntity<byte[]> addAttachments(
@RequestParam("fileInput") MultipartFile pdfFile,
@RequestParam("attachments") List<MultipartFile> attachments)
"This endpoint adds attachments to a PDF. Input:PDF, Output:PDF Type:MISO")
public ResponseEntity<byte[]> addAttachments(@ModelAttribute AddAttachmentRequest request)
throws IOException {
MultipartFile fileInput = request.getFileInput();
List<MultipartFile> attachments = request.getAttachments();
PDDocument document =
pdfAttachmentService.addAttachment(
pdfDocumentFactory.load(pdfFile, false), attachments);
pdfDocumentFactory.load(fileInput, false), attachments);
return WebResponseUtils.pdfDocToWebResponse(
document,
Filenames.toSimpleFileName(pdfFile.getOriginalFilename())
Filenames.toSimpleFileName(fileInput.getOriginalFilename())
.replaceFirst("[.][^.]+$", "")
+ "_with_attachments.pdf");
}

View File

@ -0,0 +1,23 @@
package stirling.software.SPDF.model.api.misc;
import java.util.List;
import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class AddAttachmentRequest extends PDFFile {
@Schema(
description = "The image file to be overlaid onto the PDF.",
requiredMode = Schema.RequiredMode.REQUIRED,
format = "binary")
private List<MultipartFile> attachments;
}

View File

@ -1,6 +1,6 @@
package stirling.software.SPDF.service;
import static stirling.software.common.util.PDFAttachmentUtils.setCatalogViewerPreferences;
import static stirling.software.common.util.AttachmentUtils.setCatalogViewerPreferences;
import java.io.IOException;
import java.util.GregorianCalendar;

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=كل صفحة؟
addImage.upload=إضافة صورة
addImage.submit=إضافة صورة
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=دمج
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=قم بسحب المفات وإفلاتها هنا
fileChooser.extractPDF=جاري الاستخراج...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1594,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Buraxılışlar

View File

@ -1594,7 +1594,6 @@ fileChooser.dragAndDropPDF=Влачете и пуснете PDF файл
fileChooser.dragAndDropImage=Влачете и пуснете изображение
fileChooser.hoveredDragAndDrop=Влачете и пуснете файл(ове) тук
fileChooser.extractPDF=Извличане...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Версии

View File

@ -1594,7 +1594,6 @@ fileChooser.dragAndDropPDF=PDF ཡིག་ཆ་འཐེན་ནས་འཇ
fileChooser.dragAndDropImage=པར་རིས་ཡིག་ཆ་འཐེན་ནས་འཇོག་པ།
fileChooser.hoveredDragAndDrop=ཡིག་ཆ་འདིར་འཐེན་ནས་འཇོག་པ།
fileChooser.extractPDF=འདོན་རིས་འགྱུར་བའི་སྒྲིག་བཏང་བ།
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=པར་གཞི།

View File

@ -1594,7 +1594,7 @@ fileChooser.dragAndDropPDF=Arrossega i deixa anar un fitxer PDF
fileChooser.dragAndDropImage=Arrossega i deixa anar un fitxer d'imatge
fileChooser.hoveredDragAndDrop=Arrossega i deixa anar fitxer(s) aquí
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Llançaments
releases.title=Notes de Llançament

View File

@ -1594,7 +1594,7 @@ fileChooser.dragAndDropPDF=Přetáhnout PDF soubor
fileChooser.dragAndDropImage=Přetáhnout obrázek
fileChooser.hoveredDragAndDrop=Přetáhněte soubor(y) sem
fileChooser.extractPDF=Extrahování...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Vydání
releases.title=Poznámky k vydání

View File

@ -1594,7 +1594,7 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases
releases.title=Release Notes

View File

@ -1594,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF-Datei
fileChooser.dragAndDropImage=Drag & Drop Bilddatei
fileChooser.hoveredDragAndDrop=Datei(en) hierhin Ziehen & Fallenlassen
fileChooser.extractPDF=Extrahiere...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Veröffentlichungen

View File

@ -1594,7 +1594,7 @@ fileChooser.dragAndDropPDF=Σύρετε & αφήστε αρχείο PDF
fileChooser.dragAndDropImage=Σύρετε & αφήστε αρχείο εικόνας
fileChooser.hoveredDragAndDrop=Σύρετε & αφήστε αρχείο(α) εδώ
fileChooser.extractPDF=Εξαγωγή...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Εκδόσεις
releases.title=Σημειώσεις έκδοσης

View File

@ -525,10 +525,6 @@ home.addImage.title=Add image
home.addImage.desc=Adds a image onto a set location on the PDF
addImage.tags=img,jpg,picture,photo
home.attachments.title=Add Attachments
home.attachments.desc=Add or remove embedded files (attachments) to/from a PDF
attachments.tags=embed,attach,file,attachment,attachments
home.watermark.title=Add Watermark
home.watermark.desc=Add a custom watermark to your PDF document.
watermark.tags=Text,repeating,label,own,copyright,trademark,img,jpg,picture,photo
@ -537,6 +533,7 @@ home.permissions.title=Change Permissions
home.permissions.desc=Change the permissions of your PDF document
permissions.tags=read,write,edit,print
home.removePages.title=Remove
home.removePages.desc=Delete unwanted pages from your PDF document.
removePages.tags=Remove pages,delete pages
@ -1209,14 +1206,6 @@ addImage.upload=Add image
addImage.submit=Add image
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Merge
merge.header=Merge multiple PDFs (2+)
@ -1605,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1205,12 +1205,6 @@ addImage.everyPage=¿Todas las páginas?
addImage.upload=Añadir imagen
addImage.submit=Enviar imagen
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Unir
@ -1600,7 +1594,6 @@ fileChooser.dragAndDropPDF=Arrastrar & Soltar archivo PDF
fileChooser.dragAndDropImage=Arrastrar & Soltar archivo de Imagen
fileChooser.hoveredDragAndDrop=Arrastrar & Soltar archivos(s) aquí
fileChooser.extractPDF=Extrayendo...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Versiones

View File

@ -1594,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=هر صفحه؟
addImage.upload=افزودن تصویر
addImage.submit=افزودن تصویر
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=ادغام
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=فایل(های) خود را اینجا بکشید و رها کنید
fileChooser.extractPDF=در حال استخراج...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=نسخه‌ها

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=Toutes les pages ?
addImage.upload=Télécharger une image
addImage.submit=Ajouter une image
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Fusionner
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Glisser & Déposer le(s) fichier(s) ici
fileChooser.extractPDF=Extraction en cours...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Versions

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=Gach Leathanach?
addImage.upload=Cuir íomhá leis
addImage.submit=Cuir íomhá leis
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Cumaisc
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Tarraing & Scaoil comhad PDF
fileChooser.dragAndDropImage=Tarraing & Scaoil comhad Íomhá
fileChooser.hoveredDragAndDrop=Tarraing agus scaoil comhad(í) anseo
fileChooser.extractPDF=Ag Aistriú...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Eisiúintí

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=हर पृष्ठ?
addImage.upload=छवि जोड़ें
addImage.submit=छवि जोड़ें
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=मर्ज करें
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=PDF फ़ाइल खींचें और छो
fileChooser.dragAndDropImage=छवि फ़ाइल खींचें और छोड़ें
fileChooser.hoveredDragAndDrop=फ़ाइल(ें) यहाँ खींचें और छोड़ें
fileChooser.extractPDF=निकालना...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=रिलीज़

View File

@ -1206,14 +1206,6 @@ addImage.upload=Dodaj sliku
addImage.submit=Dodaj sliku
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Spajanje
merge.header=Spajanje više PDF-ova (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=Minden oldalra?
addImage.upload=Kép hozzáadása
addImage.submit=Kép hozzáadása
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Egyesítés
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Húzza ide a PDF fájlt
fileChooser.dragAndDropImage=Húzza ide a képfájlt
fileChooser.hoveredDragAndDrop=Húzza ide a fájl(oka)t
fileChooser.extractPDF=Kinyerés...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Kiadási jegyzék

View File

@ -1206,14 +1206,6 @@ addImage.upload=Tambahkan Gambar
addImage.submit=Tambahkan Gambar
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Gabungkan
merge.header=Gabungkan beberapa PDFs (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=Ogni pagina?
addImage.upload=Aggiungi immagine
addImage.submit=Aggiungi immagine
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Unisci
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Trascina & rilascia il file PDF
fileChooser.dragAndDropImage=Trascina & rilascia il file immagine
fileChooser.hoveredDragAndDrop=Trascina & rilascia i file qui
fileChooser.extractPDF=Estraendo...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Rilasci

View File

@ -1205,12 +1205,6 @@ addImage.everyPage=全ページ?
addImage.upload=画像の追加
addImage.submit=画像の追加
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=結合
@ -1600,7 +1594,6 @@ fileChooser.dragAndDropPDF=PDFファイルをドラッグドロップ
fileChooser.dragAndDropImage=画像ファイルをドラッグ&ドロップ
fileChooser.hoveredDragAndDrop=ファイルをここにドラッグ&ドロップ
fileChooser.extractPDF=抽出中...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=リリース

View File

@ -1206,14 +1206,6 @@ addImage.upload=이미지 추가
addImage.submit=이미지 추가
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=병합
merge.header=여러 PDF 병합 (2개 이상)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=PDF 파일을 드래그 앤 드롭
fileChooser.dragAndDropImage=이미지 파일을 드래그 앤 드롭
fileChooser.hoveredDragAndDrop=여기에 파일을 드래그 앤 드롭하세요
fileChooser.extractPDF=추출 중...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=릴리스

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=എല്ലാ പേജിലും?
addImage.upload=ചിത്രം ചേർക്കുക
addImage.submit=ചിത്രം ചേർക്കുക
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=ലയിപ്പിക്കുക
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=PDF ഫയൽ വലിച്ചിടുക
fileChooser.dragAndDropImage=ചിത്ര ഫയൽ വലിച്ചിടുക
fileChooser.hoveredDragAndDrop=ഫയൽ(കൾ) ഇവിടെ വലിച്ചിടുക
fileChooser.extractPDF=വേർതിരിച്ചെടുക്കുന്നു...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=റിലീസുകൾ

View File

@ -1206,14 +1206,6 @@ addImage.upload=Afbeelding toevoegen
addImage.submit=Afbeelding toevoegen
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Samenvoegen
merge.header=Meerdere PDF's samenvoegen (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=På hver side?
addImage.upload=Legg til bilde
addImage.submit=Legg til bilde
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Slå sammen
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Versjoner

View File

@ -1206,14 +1206,6 @@ addImage.upload=Dodaj obraz
addImage.submit=Dodaj obraz
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Połącz
merge.header=Połącz wiele dokumentów PDF (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Przeciągnij i upuść plik PDF
fileChooser.dragAndDropImage=Przeciągnij i upuść plik obrazu
fileChooser.hoveredDragAndDrop=Przeciągnij i upuść plik(i) tutaj
fileChooser.extractPDF=Trwa wyodrębnianie...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Wydania

View File

@ -1206,14 +1206,6 @@ addImage.upload=Carregar imagem
addImage.submit=Adicionar imagem
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Mesclar
merge.header=Mesclar
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Arraste & Solte PDF(s)
fileChooser.dragAndDropImage=Arraste & Solte Imagem(ns)
fileChooser.hoveredDragAndDrop=Arraste & Solte arquivo(s) aqui
fileChooser.extractPDF=Extraindo...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Versões

View File

@ -1206,14 +1206,6 @@ addImage.upload=Adicionar imagem
addImage.submit=Adicionar imagem
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Juntar
merge.header=Juntar múltiplos PDFs (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Arrastar e Largar ficheiro PDF
fileChooser.dragAndDropImage=Arrastar e Largar ficheiro de Imagem
fileChooser.hoveredDragAndDrop=Arrastar e Largar ficheiro(s) aqui
fileChooser.extractPDF=Extraindo...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Lançamentos

View File

@ -1206,14 +1206,6 @@ addImage.upload=Adăugare imagine
addImage.submit=Adăugare imagine
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Unire
merge.header=Unirea mai multor PDF-uri (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=Каждая страница?
addImage.upload=Добавить изображение
addImage.submit=Добавить изображение
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Объединить
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Перетащите PDF-файл
fileChooser.dragAndDropImage=Перетащите файл изображения
fileChooser.hoveredDragAndDrop=Перетащите файл(ы) сюда
fileChooser.extractPDF=Извлечение...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Релизы

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=Každá stránka?
addImage.upload=Pridať obrázok
addImage.submit=Pridať obrázok
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Zlúčiť
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1206,14 +1206,6 @@ addImage.upload=Dodaj sliko
addImage.submit=Dodaj sliko
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Združi
merge.header=Združi več PDF-jev (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Povleci in spusti datoteko PDF
fileChooser.dragAndDropImage=Povleci in spusti slikovno datoteko
fileChooser.hoveredDragAndDrop=Povleci in spusti datoteko(e) sem
fileChooser.extractPDF=Izvlečenje...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Izdaje

View File

@ -1206,14 +1206,6 @@ addImage.upload=Dodaj sliku
addImage.submit=Dodaj sliku
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Spajanje
merge.header=Spajanje više PDF fajlova (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=Varje sida?
addImage.upload=Lägg till bild
addImage.submit=Lägg till bild
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Sammanfoga
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Dra & Släpp PDF fil
fileChooser.dragAndDropImage=Dra & Släpp bildfil
fileChooser.hoveredDragAndDrop=Dra & Släpp fil(er) här
fileChooser.extractPDF=Extraherar...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Utgåvor

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=ทุกหน้า?
addImage.upload=เพิ่มรูปภาพ
addImage.submit=เพิ่มรูปภาพ
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=รวม
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1205,13 +1205,6 @@ addImage.everyPage=Her Sayfa mı?
addImage.upload=Resim ekle
addImage.submit=Resim ekle
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Birleştir
@ -1601,7 +1594,6 @@ fileChooser.dragAndDropPDF=PDF dosyasını Sürükle & Bırak
fileChooser.dragAndDropImage=Görsel dosyasını Sürükle & Bırak
fileChooser.hoveredDragAndDrop=Dosya(lar)ı buraya sürükleyip bırakın
fileChooser.extractPDF=PDF Çıkarılıyor...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Sürümler

View File

@ -1206,14 +1206,6 @@ addImage.upload=Додати зображення
addImage.submit=Додати зображення
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Об'єднати
merge.header=Об'єднання кількох PDF-файлів (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Перетащите PDF-файл
fileChooser.dragAndDropImage=Перетащите файл зображення
fileChooser.hoveredDragAndDrop=Перетащите файл(и) сюда
fileChooser.extractPDF=Видобування...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Релізи

View File

@ -1206,14 +1206,6 @@ addImage.upload=Thêm hình ảnh
addImage.submit=Thêm hình ảnh
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=Trộn
merge.header=Trộn nhiều PDF (2+)
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=Drag & Drop PDF file
fileChooser.dragAndDropImage=Drag & Drop Image file
fileChooser.hoveredDragAndDrop=Drag & Drop file(s) here
fileChooser.extractPDF=Extracting...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=Releases

View File

@ -1206,14 +1206,6 @@ addImage.upload=添加图片
addImage.submit=添加图片
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=合并
merge.header=合并多个 PDF2个以上
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=拖放PDF文件
fileChooser.dragAndDropImage=拖放图片文件
fileChooser.hoveredDragAndDrop=拖放文件到此处
fileChooser.extractPDF=处理中...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=版本

View File

@ -1206,14 +1206,6 @@ addImage.upload=新增圖片
addImage.submit=新增圖片
#attachments
attachments.title=Add Attachments
attachments.header=Add attachments
attachments.description=Allows you to add attachments to the PDF
attachments.descriptionPlaceholder=Enter a description for the attachments...
attachments.addButton=Add Attachments
#merge
merge.title=合併
merge.header=合併多個 PDF
@ -1602,7 +1594,6 @@ fileChooser.dragAndDropPDF=拖放 PDF 檔案
fileChooser.dragAndDropImage=拖放圖片檔案
fileChooser.hoveredDragAndDrop=將檔案拖放至此
fileChooser.extractPDF=處理中...
fileChooser.addAttachments=drag & drop attachments here
#release notes
releases.footer=版本資訊

View File

@ -105,9 +105,6 @@
<div
th:replace="~{fragments/navbarEntry :: navbarEntry('img-to-pdf', 'picture_as_pdf', 'home.imageToPdf.title', 'home.imageToPdf.desc', 'imageToPdf.tags', 'convertto')}">
</div>
<div
th:replace="~{fragments/navbarEntry :: navbarEntry('eml-to-pdf', 'email', 'home.EMLToPDF.title', 'home.EMLToPDF.desc', 'EMLToPDF.tags', 'convertto')}">
</div>
<div
th:replace="~{fragments/navbarEntry :: navbarEntry('file-to-pdf', 'draft', 'home.fileToPDF.title', 'home.fileToPDF.desc', 'fileToPDF.tags', 'convertto')}">
</div>

View File

@ -21,6 +21,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import stirling.software.SPDF.model.api.misc.AddAttachmentRequest;
import stirling.software.SPDF.service.AttachmentServiceInterface;
import stirling.software.common.service.CustomPDFDocumentFactory;
import stirling.software.common.util.WebResponseUtils;
@ -40,6 +41,7 @@ class AttachmentControllerTest {
private MockMultipartFile pdfFile;
private MockMultipartFile attachment1;
private MockMultipartFile attachment2;
private AddAttachmentRequest request;
private PDDocument mockDocument;
private PDDocument modifiedMockDocument;
@ -48,7 +50,7 @@ class AttachmentControllerTest {
pdfFile = new MockMultipartFile("fileInput", "test.pdf", "application/pdf", "PDF content".getBytes());
attachment1 = new MockMultipartFile("attachment1", "file1.txt", "text/plain", "File 1 content".getBytes());
attachment2 = new MockMultipartFile("attachment2", "file2.jpg", "image/jpeg", "Image content".getBytes());
request = new AddAttachmentRequest();
mockDocument = mock(PDDocument.class);
modifiedMockDocument = mock(PDDocument.class);
}
@ -56,6 +58,8 @@ class AttachmentControllerTest {
@Test
void addAttachments_Success() throws IOException {
List<MultipartFile> attachments = List.of(attachment1, attachment2);
request.setAttachments(attachments);
request.setFileInput(pdfFile);
ResponseEntity<byte[]> expectedResponse = ResponseEntity.ok("modified PDF content".getBytes());
when(pdfDocumentFactory.load(pdfFile, false)).thenReturn(mockDocument);
@ -65,7 +69,7 @@ class AttachmentControllerTest {
mockedWebResponseUtils.when(() -> WebResponseUtils.pdfDocToWebResponse(eq(modifiedMockDocument), eq("test_with_attachments.pdf")))
.thenReturn(expectedResponse);
ResponseEntity<byte[]> response = attachmentController.addAttachments(pdfFile, attachments);
ResponseEntity<byte[]> response = attachmentController.addAttachments(request);
assertNotNull(response);
assertEquals(HttpStatus.OK, response.getStatusCode());
@ -78,6 +82,8 @@ class AttachmentControllerTest {
@Test
void addAttachments_SingleAttachment() throws IOException {
List<MultipartFile> attachments = List.of(attachment1);
request.setAttachments(attachments);
request.setFileInput(pdfFile);
ResponseEntity<byte[]> expectedResponse = ResponseEntity.ok("modified PDF content".getBytes());
when(pdfDocumentFactory.load(pdfFile, false)).thenReturn(mockDocument);
@ -87,7 +93,7 @@ class AttachmentControllerTest {
mockedWebResponseUtils.when(() -> WebResponseUtils.pdfDocToWebResponse(eq(modifiedMockDocument), eq("test_with_attachments.pdf")))
.thenReturn(expectedResponse);
ResponseEntity<byte[]> response = attachmentController.addAttachments(pdfFile, attachments);
ResponseEntity<byte[]> response = attachmentController.addAttachments(request);
assertNotNull(response);
assertEquals(HttpStatus.OK, response.getStatusCode());
@ -100,11 +106,13 @@ class AttachmentControllerTest {
@Test
void addAttachments_IOExceptionFromPDFLoad() throws IOException {
List<MultipartFile> attachments = List.of(attachment1);
request.setAttachments(attachments);
request.setFileInput(pdfFile);
IOException ioException = new IOException("Failed to load PDF");
when(pdfDocumentFactory.load(pdfFile, false)).thenThrow(ioException);
assertThrows(IOException.class, () -> attachmentController.addAttachments(pdfFile, attachments));
assertThrows(IOException.class, () -> attachmentController.addAttachments(request));
verify(pdfDocumentFactory).load(pdfFile, false);
verifyNoInteractions(pdfAttachmentService);
}
@ -112,12 +120,14 @@ class AttachmentControllerTest {
@Test
void addAttachments_IOExceptionFromAttachmentService() throws IOException {
List<MultipartFile> attachments = List.of(attachment1);
request.setAttachments(attachments);
request.setFileInput(pdfFile);
IOException ioException = new IOException("Failed to add attachment");
when(pdfDocumentFactory.load(pdfFile, false)).thenReturn(mockDocument);
when(pdfAttachmentService.addAttachment(mockDocument, attachments)).thenThrow(ioException);
assertThrows(IOException.class, () -> attachmentController.addAttachments(pdfFile, attachments));
assertThrows(IOException.class, () -> attachmentController.addAttachments(request));
verify(pdfAttachmentService).addAttachment(mockDocument, attachments);
}
}