1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-05 07:20:12 +01:00
This commit is contained in:
Anthony Stirling 2024-01-28 17:39:07 +00:00
parent ba4ad1aff9
commit 89e461e4f6
4 changed files with 25 additions and 11 deletions

View File

@ -29,7 +29,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.RestController;
import org.springframework.web.multipart.MultipartFile;

View File

@ -201,7 +201,15 @@ public class StampController {
x = overrideX;
y = overrideY;
} else {
x = calculatePositionX(pageSize, position, fontSize, font, fontSize, watermarkText, marginFactor);
x =
calculatePositionX(
pageSize,
position,
fontSize,
font,
fontSize,
watermarkText,
marginFactor);
y = calculatePositionY(pageSize, position, fontSize, marginFactor);
}
@ -247,7 +255,9 @@ public class StampController {
x = overrideX;
y = overrideY;
} else {
x = calculatePositionX(pageSize, position, desiredPhysicalWidth, null, 0, null, marginFactor);
x =
calculatePositionX(
pageSize, position, desiredPhysicalWidth, null, 0, null, marginFactor);
y = calculatePositionY(pageSize, position, fontSize, marginFactor);
}
@ -259,8 +269,16 @@ public class StampController {
}
private float calculatePositionX(
PDRectangle pageSize, int position, float contentWidth, PDFont font, float fontSize, String text, float marginFactor) throws IOException {
float actualWidth = (text != null) ? calculateTextWidth(text, font, fontSize) : contentWidth;
PDRectangle pageSize,
int position,
float contentWidth,
PDFont font,
float fontSize,
String text,
float marginFactor)
throws IOException {
float actualWidth =
(text != null) ? calculateTextWidth(text, font, fontSize) : contentWidth;
switch (position % 3) {
case 1: // Left
return pageSize.getLowerLeftX() + marginFactor * pageSize.getWidth();
@ -277,8 +295,6 @@ public class StampController {
return font.getStringWidth(text) / 1000 * fontSize;
}
private float calculatePositionY(
PDRectangle pageSize, int position, float height, float marginFactor) {
switch ((position - 1) / 3) {

View File

@ -66,7 +66,7 @@ public class ApiDocService {
"BOOK",
Arrays.asList(
"epub", "mobi", "azw3", "fb2", "txt",
"docx")); // As noted before, "Boolean" isn't a file type but a value
"docx"));
// type.
}

View File

@ -46,7 +46,6 @@ public class OtherWebController {
return "misc/stamp";
}
@GetMapping("/add-page-numbers")
@Hidden
public String addPageNumbersForm(Model model) {