mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-03-30 00:17:49 +01:00
formats
This commit is contained in:
parent
ba4ad1aff9
commit
89e461e4f6
@ -29,7 +29,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@ -50,7 +49,7 @@ public class FakeScanControllerWIP {
|
|||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
@Hidden
|
@Hidden
|
||||||
//@PostMapping(consumes = "multipart/form-data", value = "/fakeScan")
|
// @PostMapping(consumes = "multipart/form-data", value = "/fakeScan")
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Repair a PDF file",
|
summary = "Repair a PDF file",
|
||||||
description =
|
description =
|
||||||
|
@ -201,7 +201,15 @@ public class StampController {
|
|||||||
x = overrideX;
|
x = overrideX;
|
||||||
y = overrideY;
|
y = overrideY;
|
||||||
} else {
|
} 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);
|
y = calculatePositionY(pageSize, position, fontSize, marginFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +255,9 @@ public class StampController {
|
|||||||
x = overrideX;
|
x = overrideX;
|
||||||
y = overrideY;
|
y = overrideY;
|
||||||
} else {
|
} 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);
|
y = calculatePositionY(pageSize, position, fontSize, marginFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,8 +269,16 @@ public class StampController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private float calculatePositionX(
|
private float calculatePositionX(
|
||||||
PDRectangle pageSize, int position, float contentWidth, PDFont font, float fontSize, String text, float marginFactor) throws IOException {
|
PDRectangle pageSize,
|
||||||
float actualWidth = (text != null) ? calculateTextWidth(text, font, fontSize) : contentWidth;
|
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) {
|
switch (position % 3) {
|
||||||
case 1: // Left
|
case 1: // Left
|
||||||
return pageSize.getLowerLeftX() + marginFactor * pageSize.getWidth();
|
return pageSize.getLowerLeftX() + marginFactor * pageSize.getWidth();
|
||||||
@ -277,8 +295,6 @@ public class StampController {
|
|||||||
return font.getStringWidth(text) / 1000 * fontSize;
|
return font.getStringWidth(text) / 1000 * fontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private float calculatePositionY(
|
private float calculatePositionY(
|
||||||
PDRectangle pageSize, int position, float height, float marginFactor) {
|
PDRectangle pageSize, int position, float height, float marginFactor) {
|
||||||
switch ((position - 1) / 3) {
|
switch ((position - 1) / 3) {
|
||||||
|
@ -66,7 +66,7 @@ public class ApiDocService {
|
|||||||
"BOOK",
|
"BOOK",
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"epub", "mobi", "azw3", "fb2", "txt",
|
"epub", "mobi", "azw3", "fb2", "txt",
|
||||||
"docx")); // As noted before, "Boolean" isn't a file type but a value
|
"docx"));
|
||||||
// type.
|
// type.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,14 +38,13 @@ public class OtherWebController {
|
|||||||
model.addAttribute("currentPage", "show-javascript");
|
model.addAttribute("currentPage", "show-javascript");
|
||||||
return "misc/show-javascript";
|
return "misc/show-javascript";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/stamp")
|
@GetMapping("/stamp")
|
||||||
@Hidden
|
@Hidden
|
||||||
public String stampForm(Model model) {
|
public String stampForm(Model model) {
|
||||||
model.addAttribute("currentPage", "stamp");
|
model.addAttribute("currentPage", "stamp");
|
||||||
return "misc/stamp";
|
return "misc/stamp";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/add-page-numbers")
|
@GetMapping("/add-page-numbers")
|
||||||
@Hidden
|
@Hidden
|
||||||
|
Loading…
Reference in New Issue
Block a user