mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-04-22 23:08:53 +02:00
Cleanups and making distinction between pro and enterprise (#3250)
# Description of Changes Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: a <a>
This commit is contained in:
@@ -68,17 +68,17 @@ public class CustomPDFDocumentFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point for loading a PDF document from a file. Automatically selects the most
|
||||
* appropriate loading strategy.
|
||||
*/
|
||||
* Main entry point for loading a PDF document from a file. Automatically selects the most
|
||||
* appropriate loading strategy.
|
||||
*/
|
||||
public PDDocument load(File file) throws IOException {
|
||||
return load(file, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point for loading a PDF document from a file with read-only option.
|
||||
* Automatically selects the most appropriate loading strategy.
|
||||
*/
|
||||
* Main entry point for loading a PDF document from a file with read-only option. Automatically
|
||||
* selects the most appropriate loading strategy.
|
||||
*/
|
||||
public PDDocument load(File file, boolean readOnly) throws IOException {
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
@@ -95,17 +95,17 @@ public class CustomPDFDocumentFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point for loading a PDF document from a Path. Automatically selects the most
|
||||
* appropriate loading strategy.
|
||||
*/
|
||||
* Main entry point for loading a PDF document from a Path. Automatically selects the most
|
||||
* appropriate loading strategy.
|
||||
*/
|
||||
public PDDocument load(Path path) throws IOException {
|
||||
return load(path, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point for loading a PDF document from a Path with read-only option.
|
||||
* Automatically selects the most appropriate loading strategy.
|
||||
*/
|
||||
* Main entry point for loading a PDF document from a Path with read-only option. Automatically
|
||||
* selects the most appropriate loading strategy.
|
||||
*/
|
||||
public PDDocument load(Path path, boolean readOnly) throws IOException {
|
||||
if (path == null) {
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
@@ -170,7 +170,8 @@ public class CustomPDFDocumentFactory {
|
||||
}
|
||||
|
||||
/** Load with password from InputStream and read-only option */
|
||||
public PDDocument load(InputStream input, String password, boolean readOnly) throws IOException {
|
||||
public PDDocument load(InputStream input, String password, boolean readOnly)
|
||||
throws IOException {
|
||||
if (input == null) {
|
||||
throw new IllegalArgumentException("InputStream cannot be null");
|
||||
}
|
||||
@@ -179,7 +180,8 @@ public class CustomPDFDocumentFactory {
|
||||
Path tempFile = createTempFile("pdf-stream-");
|
||||
|
||||
Files.copy(input, tempFile, StandardCopyOption.REPLACE_EXISTING);
|
||||
PDDocument doc = loadAdaptivelyWithPassword(tempFile.toFile(), Files.size(tempFile), password);
|
||||
PDDocument doc =
|
||||
loadAdaptivelyWithPassword(tempFile.toFile(), Files.size(tempFile), password);
|
||||
if (!readOnly) {
|
||||
postProcessDocument(doc);
|
||||
}
|
||||
@@ -203,7 +205,7 @@ public class CustomPDFDocumentFactory {
|
||||
|
||||
/** Load from a PDFFile object with read-only option */
|
||||
public PDDocument load(PDFFile pdfFile, boolean readOnly) throws IOException {
|
||||
return load(pdfFile.getFileInput(), readOnly);
|
||||
return load(pdfFile.getFileInput(), readOnly);
|
||||
}
|
||||
|
||||
/** Load from a MultipartFile */
|
||||
@@ -213,8 +215,7 @@ public class CustomPDFDocumentFactory {
|
||||
|
||||
/** Load from a MultipartFile with read-only option */
|
||||
public PDDocument load(MultipartFile pdfFile, boolean readOnly) throws IOException {
|
||||
return load(pdfFile.getInputStream(), readOnly);
|
||||
|
||||
return load(pdfFile.getInputStream(), readOnly);
|
||||
}
|
||||
|
||||
/** Load with password from MultipartFile */
|
||||
@@ -223,10 +224,11 @@ public class CustomPDFDocumentFactory {
|
||||
}
|
||||
|
||||
/** Load with password from MultipartFile with read-only option */
|
||||
public PDDocument load(MultipartFile fileInput, String password, boolean readOnly) throws IOException {
|
||||
return load(fileInput.getInputStream(), password, readOnly);
|
||||
public PDDocument load(MultipartFile fileInput, String password, boolean readOnly)
|
||||
throws IOException {
|
||||
return load(fileInput.getInputStream(), password, readOnly);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the appropriate caching strategy based on file size and available memory. This
|
||||
* common method is used by both password and non-password loading paths.
|
||||
@@ -471,5 +473,4 @@ public class CustomPDFDocumentFactory {
|
||||
return saveToBytes(document);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,18 +17,18 @@ public class PdfMetadataService {
|
||||
private final ApplicationProperties applicationProperties;
|
||||
private final String stirlingPDFLabel;
|
||||
private final UserServiceInterface userService;
|
||||
private final boolean runningEE;
|
||||
private final boolean runningProOrHigher;
|
||||
|
||||
@Autowired
|
||||
public PdfMetadataService(
|
||||
ApplicationProperties applicationProperties,
|
||||
@Qualifier("StirlingPDFLabel") String stirlingPDFLabel,
|
||||
@Qualifier("runningEE") boolean runningEE,
|
||||
@Qualifier("runningProOrHigher") boolean runningProOrHigher,
|
||||
@Autowired(required = false) UserServiceInterface userService) {
|
||||
this.applicationProperties = applicationProperties;
|
||||
this.stirlingPDFLabel = stirlingPDFLabel;
|
||||
this.userService = userService;
|
||||
this.runningEE = runningEE;
|
||||
this.runningProOrHigher = runningProOrHigher;
|
||||
}
|
||||
|
||||
public PdfMetadata extractMetadataFromPdf(PDDocument pdf) {
|
||||
@@ -69,7 +69,7 @@ public class PdfMetadataService {
|
||||
.getProFeatures()
|
||||
.getCustomMetadata()
|
||||
.isAutoUpdateMetadata()
|
||||
&& runningEE) {
|
||||
&& runningProOrHigher) {
|
||||
|
||||
creator =
|
||||
applicationProperties
|
||||
@@ -98,7 +98,7 @@ public class PdfMetadataService {
|
||||
.getProFeatures()
|
||||
.getCustomMetadata()
|
||||
.isAutoUpdateMetadata()
|
||||
&& runningEE) {
|
||||
&& runningProOrHigher) {
|
||||
author =
|
||||
applicationProperties
|
||||
.getPremium()
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
@@ -70,7 +69,7 @@ public class SignatureService {
|
||||
return Files.list(folder)
|
||||
.filter(path -> isImageFile(path))
|
||||
.map(path -> new SignatureFile(path.getFileName().toString(), category))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public byte[] getSignatureBytes(String username, String fileName) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user