Skip to content

Commit

Permalink
commit (#1128)
Browse files Browse the repository at this point in the history
* commit

* formatting
  • Loading branch information
Frooodle authored Apr 26, 2024
1 parent 70349d6 commit 30444fc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Stirling PDF allows easy customization of the app.
Includes things like
- Custom application name
- Custom slogans, icons, images, and even custom HTML (via file overrides)
- Custom slogans, icons, images css etc (via file overrides) (Does not currently support html)
There are two options for this, either using the generated settings file ``settings.yml``
This file is located in the ``/configs`` directory and follows standard YAML formatting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.springframework.web.multipart.MultipartFile;

import io.github.pixee.security.Filenames;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

Expand All @@ -51,7 +52,9 @@ public class FakeScanControllerWIP {

private static final Logger logger = LoggerFactory.getLogger(FakeScanControllerWIP.class);

// TODO finish
@PostMapping(consumes = "multipart/form-data", value = "/fake-scan")
@Hidden
@Operation(
summary = "Repair a PDF file",
description =
Expand Down Expand Up @@ -94,14 +97,13 @@ public ResponseEntity<byte[]> fakeScan(@ModelAttribute PDFFile request) throws I
public BufferedImage processImage(BufferedImage image) {
// Rotation

addDustAndHairs(image, 50);
// image = rotate(image, 1);
image = softenEdges(image, 50);
image = rotate(image, 1);

// image = softenEdges(image, 5);
image = applyGaussianBlur(image, 0.5);
addGaussianNoise(image, 0.8);
addGaussianNoise(image, 0.5);
image = linearStretch(image);

addDustAndHairs(image, 3);
return image;
}

Expand Down Expand Up @@ -156,32 +158,51 @@ public BufferedImage softenEdges(BufferedImage image, int featherRadius) {

g2.drawImage(image, 0, 0, null);
g2.setComposite(AlphaComposite.DstIn);

// Top edge
g2.setPaint(
new GradientPaint(
0, 0, new Color(0, 0, 0, 1f), 0, featherRadius, new Color(0, 0, 0, 0f)));
g2.fillRect(0, 0, width, featherRadius); // top edge
0,
0,
new Color(0, 0, 0, 1f),
0,
featherRadius * 2,
new Color(0, 0, 0, 0f)));
g2.fillRect(0, 0, width, featherRadius);

// Bottom edge
g2.setPaint(
new GradientPaint(
0,
height - featherRadius,
height - featherRadius * 2,
new Color(0, 0, 0, 0f),
0,
height,
new Color(0, 0, 0, 1f)));
g2.fillRect(0, height - featherRadius, width, featherRadius); // bottom edge
g2.fillRect(0, height - featherRadius, width, featherRadius);

// Left edge
g2.setPaint(
new GradientPaint(
0, 0, new Color(0, 0, 0, 1f), featherRadius, 0, new Color(0, 0, 0, 0f)));
g2.fillRect(0, 0, featherRadius, height); // left edge
0,
0,
new Color(0, 0, 0, 1f),
featherRadius * 2,
0,
new Color(0, 0, 0, 0f)));
g2.fillRect(0, 0, featherRadius, height);

// Right edge
g2.setPaint(
new GradientPaint(
width - featherRadius,
width - featherRadius * 2,
0,
new Color(0, 0, 0, 0f),
width,
0,
new Color(0, 0, 0, 1f)));
g2.fillRect(width - featherRadius, 0, featherRadius, height); // right edge
g2.fillRect(width - featherRadius, 0, featherRadius, height);

g2.dispose();

return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
import org.springframework.http.HttpStatus;
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;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

import stirling.software.SPDF.model.api.misc.PrintFileRequest;
Expand All @@ -35,12 +33,13 @@
@Tag(name = "Misc", description = "Miscellaneous APIs")
public class PrintFileController {

//TODO
//@PostMapping(value = "/print-file", consumes = "multipart/form-data")
//@Operation(
// TODO
// @PostMapping(value = "/print-file", consumes = "multipart/form-data")
// @Operation(
// summary = "Prints PDF/Image file to a set printer",
// description =
// "Input of PDF or Image along with a printer name/URL/IP to match against to send it to (Fire and forget) Input:Any Output:N/A Type:SISO")
// "Input of PDF or Image along with a printer name/URL/IP to match against to
// send it to (Fire and forget) Input:Any Output:N/A Type:SISO")
public ResponseEntity<String> printFile(@ModelAttribute PrintFileRequest request)
throws IOException {
MultipartFile file = request.getFileInput();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/stirling/software/SPDF/utils/PdfUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,6 @@ public static void addImageToDocument(
boolean imageIsLandscape = image.getWidth() > image.getHeight();
PDRectangle pageSize = PDRectangle.A4;

System.out.println(fitOption);

if (autoRotate && imageIsLandscape) {
pageSize = new PDRectangle(pageSize.getHeight(), pageSize.getWidth());
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/templates/fragments/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav me-auto flex-nowrap">
<li class="nav-item">
<li class="nav-item" th:if="${@endpointConfiguration.isEndpointEnabled('multi-tool')}">
<a class="nav-link" href="#" th:href="@{multi-tool}" th:classappend="${currentPage}=='multi-tool' ? 'active' : ''" th:title="#{home.multiTool.desc}">
<img class="icon" src="images/tools.svg" alt="icon">
<span class="icon-text" th:text="#{home.multiTool.title}"></span>
</a>
</li>
<li class="nav-item nav-item-separator"></li>
<li class="nav-item">
<li th:if="${@endpointConfiguration.isEndpointEnabled('multi-tool')}" class="nav-item nav-item-separator"></li>
<li th:if="${@endpointConfiguration.isEndpointEnabled('pipeline')}" class="nav-item">
<a class="nav-link" href="#" th:href="@{pipeline}" th:classappend="${currentPage}=='pipeline' ? 'active' : ''" th:title="#{home.pipeline.desc}">
<img class="icon" src="images/pipeline.svg" alt="icon">
<span class="icon-text" th:text="#{home.pipeline.title}"></span>
</a>
</li>
<li class="nav-item nav-item-separator"></li>
<li th:if="${@endpointConfiguration.isEndpointEnabled('pipeline')}" class="nav-item nav-item-separator"></li>
<li class="nav-item dropdown" th:classappend="${currentPage}=='remove-pages' OR ${currentPage}=='merge-pdfs' OR ${currentPage}=='split-pdfs' OR ${currentPage}=='crop' OR ${currentPage}=='adjust-contrast' OR ${currentPage}=='pdf-organizer' OR ${currentPage}=='rotate-pdf' OR ${currentPage}=='multi-page-layout' OR ${currentPage}=='scale-pages' OR ${currentPage}=='auto-split-pdf' OR ${currentPage}=='extract-page' OR ${currentPage}=='pdf-to-single-page' ? 'active' : ''">
<a class="nav-link dropdown-toggle" id="navbarDropdown-1" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img class="icon" src="images/file-earmark-pdf.svg" alt="icon">
Expand Down

0 comments on commit 30444fc

Please sign in to comment.