mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-20 13:47:46 +02:00
Delete src/main directory
This commit is contained in:
parent
1937a83531
commit
69c25cc5df
@ -1,13 +0,0 @@
|
|||||||
package stirling.software.SPDF;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public class SPdfApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(SPdfApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import com.spire.pdf.PdfCompressionLevel;
|
|
||||||
import com.spire.pdf.PdfDocument;
|
|
||||||
import com.spire.pdf.PdfPageBase;
|
|
||||||
import com.spire.pdf.exporting.PdfImageInfo;
|
|
||||||
import com.spire.pdf.graphics.PdfBitmap;
|
|
||||||
|
|
||||||
import stirling.software.SPDF.utils.PdfUtils;
|
|
||||||
//import com.spire.pdf.*;
|
|
||||||
@Controller
|
|
||||||
public class CompressController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompressController.class);
|
|
||||||
|
|
||||||
@GetMapping("/compress-pdf")
|
|
||||||
public String compressPdfForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "compress-pdf");
|
|
||||||
return "compress-pdf";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/compress-pdf")
|
|
||||||
public ResponseEntity<byte[]> compressPDF(@RequestParam("fileInput") MultipartFile pdfFile,
|
|
||||||
@RequestParam("imageCompressionLevel") String imageCompressionLevel) throws IOException {
|
|
||||||
|
|
||||||
|
|
||||||
//Load a sample PDF document
|
|
||||||
PdfDocument document = new PdfDocument();
|
|
||||||
document.loadFromBytes(pdfFile.getBytes());
|
|
||||||
|
|
||||||
//Compress PDF
|
|
||||||
document.getFileInfo().setIncrementalUpdate(false);
|
|
||||||
document.setCompressionLevel(PdfCompressionLevel.Best);
|
|
||||||
|
|
||||||
//compress PDF Images
|
|
||||||
for (int i = 0; i < document.getPages().getCount(); i++) {
|
|
||||||
|
|
||||||
PdfPageBase page = document.getPages().get(i);
|
|
||||||
PdfImageInfo[] images = page.getImagesInfo();
|
|
||||||
if (images != null && images.length > 0)
|
|
||||||
for (int j = 0; j < images.length; j++) {
|
|
||||||
PdfImageInfo image = images[j];
|
|
||||||
PdfBitmap bp = new PdfBitmap(image.getImage());
|
|
||||||
//bp.setPngDirectToJpeg(true);
|
|
||||||
bp.setQuality(Integer.valueOf(imageCompressionLevel));
|
|
||||||
|
|
||||||
page.replaceImage(j, bp);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the rearranged PDF to a ByteArrayOutputStream
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
document.saveToStream(outputStream);
|
|
||||||
|
|
||||||
// Close the original document
|
|
||||||
document.close();
|
|
||||||
|
|
||||||
// Prepare the response headers
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
||||||
headers.setContentDispositionFormData("attachment", "compressed.pdf");
|
|
||||||
headers.setContentLength(outputStream.size());
|
|
||||||
|
|
||||||
// Return the response with the PDF data and headers
|
|
||||||
return new ResponseEntity<>(outputStream.toByteArray(), headers, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import stirling.software.SPDF.utils.PdfUtils;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class ConvertPDFController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ConvertPDFController.class);
|
|
||||||
|
|
||||||
@GetMapping("/convert-pdf")
|
|
||||||
public String convertToPdfForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "convert-pdf");
|
|
||||||
return "convert-pdf";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/convert-to-pdf")
|
|
||||||
public ResponseEntity<byte[]> convertToPdf(@RequestParam("fileInput") MultipartFile file) throws IOException {
|
|
||||||
// Convert the file to PDF and get the resulting bytes
|
|
||||||
byte[] bytes = PdfUtils.convertToPdf(file.getInputStream());
|
|
||||||
logger.info("File {} successfully converted to pdf", file.getOriginalFilename());
|
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
||||||
String filename = "converted.pdf";
|
|
||||||
headers.setContentDispositionFormData(filename, filename);
|
|
||||||
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
|
|
||||||
ResponseEntity<byte[]> response = new ResponseEntity<>(bytes, headers, HttpStatus.OK);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/convert-from-pdf")
|
|
||||||
public ResponseEntity<byte[]> convertToImage(@RequestParam("fileInput") MultipartFile file,
|
|
||||||
@RequestParam("imageFormat") String imageFormat) throws IOException {
|
|
||||||
byte[] pdfBytes = file.getBytes();
|
|
||||||
//returns bytes for image
|
|
||||||
byte[] result = PdfUtils.convertFromPdf(pdfBytes, imageFormat.toLowerCase());
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.parseMediaType(getMediaType(imageFormat)));
|
|
||||||
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
|
|
||||||
ResponseEntity<byte[]> response = new ResponseEntity<>(result, headers, HttpStatus.OK);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getMediaType(String imageFormat) {
|
|
||||||
if(imageFormat.equalsIgnoreCase("PNG"))
|
|
||||||
return "image/png";
|
|
||||||
else if(imageFormat.equalsIgnoreCase("JPEG") || imageFormat.equalsIgnoreCase("JPG"))
|
|
||||||
return "image/jpeg";
|
|
||||||
else if(imageFormat.equalsIgnoreCase("GIF"))
|
|
||||||
return "image/gif";
|
|
||||||
else
|
|
||||||
return "application/octet-stream";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import stirling.software.SPDF.utils.PdfUtils;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class OverlayImageController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(OverlayImageController.class);
|
|
||||||
|
|
||||||
@GetMapping("/add-image")
|
|
||||||
public String overlayImage(Model model) {
|
|
||||||
model.addAttribute("currentPage", "add-image");
|
|
||||||
return "add-image";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/add-image")
|
|
||||||
public ResponseEntity<byte[]> overlayImage(@RequestParam("fileInput") MultipartFile pdfFile,
|
|
||||||
@RequestParam("fileInput2") MultipartFile imageFile, @RequestParam("x") float x,
|
|
||||||
@RequestParam("y") float y) {
|
|
||||||
try {
|
|
||||||
byte[] pdfBytes = pdfFile.getBytes();
|
|
||||||
byte[] imageBytes = imageFile.getBytes();
|
|
||||||
byte[] result = PdfUtils.overlayImage(pdfBytes, imageBytes, x, y);
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
||||||
headers.setContentDispositionFormData("attachment", "overlayed.pdf");
|
|
||||||
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
|
|
||||||
return new ResponseEntity<>(result, headers, HttpStatus.OK);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("Failed to add image to PDF", e);
|
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPageTree;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.core.io.InputStreamResource;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class PdfController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PdfController.class);
|
|
||||||
|
|
||||||
@GetMapping("/")
|
|
||||||
public String root(Model model) {
|
|
||||||
return "redirect:/home";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/merge-pdfs")
|
|
||||||
public String hello(Model model) {
|
|
||||||
model.addAttribute("currentPage", "merge-pdfs");
|
|
||||||
return "merge-pdfs";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/home")
|
|
||||||
public String home(Model model) {
|
|
||||||
model.addAttribute("currentPage", "home");
|
|
||||||
return "home";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/merge-pdfs")
|
|
||||||
public ResponseEntity<InputStreamResource> mergePdfs(@RequestParam("fileInput") MultipartFile[] files)
|
|
||||||
throws IOException {
|
|
||||||
// Read the input PDF files into PDDocument objects
|
|
||||||
List<PDDocument> documents = new ArrayList<>();
|
|
||||||
|
|
||||||
// Loop through the files array and read each file into a PDDocument
|
|
||||||
for (MultipartFile file : files) {
|
|
||||||
documents.add(PDDocument.load(file.getInputStream()));
|
|
||||||
}
|
|
||||||
|
|
||||||
PDDocument mergedDoc = mergeDocuments(documents);
|
|
||||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
||||||
mergedDoc.save(byteArrayOutputStream);
|
|
||||||
mergedDoc.close();
|
|
||||||
|
|
||||||
// Create an InputStreamResource from the merged PDF
|
|
||||||
InputStreamResource resource = new InputStreamResource(
|
|
||||||
new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
|
|
||||||
|
|
||||||
// Return the merged PDF as a response
|
|
||||||
return ResponseEntity.ok().contentType(MediaType.APPLICATION_PDF).body(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PDDocument mergeDocuments(List<PDDocument> documents) throws IOException {
|
|
||||||
// Create a new empty document
|
|
||||||
PDDocument mergedDoc = new PDDocument();
|
|
||||||
|
|
||||||
// Iterate over the list of documents and add their pages to the merged document
|
|
||||||
for (PDDocument doc : documents) {
|
|
||||||
// Get all pages from the current document
|
|
||||||
PDPageTree pages = doc.getPages();
|
|
||||||
// Iterate over the pages and add them to the merged document
|
|
||||||
for (PDPage page : pages) {
|
|
||||||
mergedDoc.addPage(page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the merged document
|
|
||||||
return mergedDoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class RearrangePagesPDFController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RearrangePagesPDFController.class);
|
|
||||||
|
|
||||||
@GetMapping("/pdf-organizer")
|
|
||||||
public String pageOrganizer(Model model) {
|
|
||||||
model.addAttribute("currentPage", "pdf-organizer");
|
|
||||||
return "pdf-organizer";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/rearrange-pages")
|
|
||||||
public ResponseEntity<byte[]> rearrangePages(@RequestParam("fileInput") MultipartFile pdfFile,
|
|
||||||
@RequestParam("pageOrder") String pageOrder) {
|
|
||||||
try {
|
|
||||||
// Load the input PDF
|
|
||||||
PDDocument document = PDDocument.load(pdfFile.getInputStream());
|
|
||||||
|
|
||||||
// Split the page order string into an array of page numbers or range of numbers
|
|
||||||
String[] pageOrderArr = pageOrder.split(",");
|
|
||||||
List<Integer> newPageOrder = new ArrayList<Integer>();
|
|
||||||
//int[] newPageOrder = new int[pageOrderArr.length];
|
|
||||||
int totalPages = document.getNumberOfPages();
|
|
||||||
|
|
||||||
// loop through the page order array
|
|
||||||
for (String element : pageOrderArr) {
|
|
||||||
// check if the element contains a range of pages
|
|
||||||
if (element.contains("-")) {
|
|
||||||
// split the range into start and end page
|
|
||||||
String[] range = element.split("-");
|
|
||||||
int start = Integer.parseInt(range[0]);
|
|
||||||
int end = Integer.parseInt(range[1]);
|
|
||||||
// check if the end page is greater than total pages
|
|
||||||
if (end > totalPages) {
|
|
||||||
end = totalPages;
|
|
||||||
}
|
|
||||||
// loop through the range of pages
|
|
||||||
for (int j = start; j <= end; j++) {
|
|
||||||
// print the current index
|
|
||||||
newPageOrder.add( j - 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// if the element is a single page
|
|
||||||
newPageOrder.add( Integer.parseInt(element) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new list to hold the pages in the new order
|
|
||||||
List<PDPage> newPages = new ArrayList<>();
|
|
||||||
for (int i = 0; i < newPageOrder.size(); i++) {
|
|
||||||
newPages.add(document.getPage(newPageOrder.get(i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove all the pages from the original document
|
|
||||||
for (int i = document.getNumberOfPages() - 1; i >= 0; i--) {
|
|
||||||
document.removePage(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the pages in the new order
|
|
||||||
for (PDPage page : newPages) {
|
|
||||||
document.addPage(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the rearranged PDF to a ByteArrayOutputStream
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
document.save(outputStream);
|
|
||||||
|
|
||||||
// Close the original document
|
|
||||||
document.close();
|
|
||||||
|
|
||||||
// Prepare the response headers
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
||||||
headers.setContentDispositionFormData("attachment", "rearranged.pdf");
|
|
||||||
headers.setContentLength(outputStream.size());
|
|
||||||
|
|
||||||
// Return the response with the PDF data and headers
|
|
||||||
return new ResponseEntity<>(outputStream.toByteArray(), headers, HttpStatus.OK);
|
|
||||||
} catch (IOException e) {
|
|
||||||
|
|
||||||
logger.error("Failed rearranging documents", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPageTree;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import stirling.software.SPDF.utils.PdfUtils;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class RotationController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RotationController.class);
|
|
||||||
|
|
||||||
@GetMapping("/rotate-pdf")
|
|
||||||
public String rotatePdfForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "rotate-pdf");
|
|
||||||
return "rotate-pdf";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/rotate-pdf")
|
|
||||||
public ResponseEntity<byte[]> rotatePDF(@RequestParam("fileInput") MultipartFile pdfFile,
|
|
||||||
@RequestParam("angle") String angle) throws IOException {
|
|
||||||
|
|
||||||
// Load the PDF document
|
|
||||||
PDDocument document = PDDocument.load(pdfFile.getBytes());
|
|
||||||
|
|
||||||
// Get the list of pages in the document
|
|
||||||
PDPageTree pages = document.getPages();
|
|
||||||
|
|
||||||
// Rotate all pages by the specified angle
|
|
||||||
Iterator<PDPage> iterPage = pages.iterator();
|
|
||||||
|
|
||||||
while (iterPage.hasNext()) {
|
|
||||||
PDPage page = iterPage.next();
|
|
||||||
page.setRotation(Integer.valueOf(angle));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the rearranged PDF to a ByteArrayOutputStream
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
document.save(outputStream);
|
|
||||||
|
|
||||||
// Close the document
|
|
||||||
document.close();
|
|
||||||
|
|
||||||
// Prepare the response headers
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
||||||
headers.setContentDispositionFormData("attachment", "output.pdf");
|
|
||||||
headers.setContentLength(outputStream.size());
|
|
||||||
|
|
||||||
// Return the response with the PDF data and headers
|
|
||||||
return new ResponseEntity<>(outputStream.toByteArray(), headers, HttpStatus.OK);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.nio.file.FileSystem;
|
|
||||||
import java.nio.file.FileSystems;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.core.io.ByteArrayResource;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class SplitPDFController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SplitPDFController.class);
|
|
||||||
|
|
||||||
@GetMapping("/split-pdfs")
|
|
||||||
public String splitPdfForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "split-pdfs");
|
|
||||||
return "split-pdfs";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/split-pages")
|
|
||||||
public ResponseEntity<Resource> splitPdf(@RequestParam("fileInput") MultipartFile file,
|
|
||||||
@RequestParam("pages") String pages) throws IOException {
|
|
||||||
// parse user input
|
|
||||||
|
|
||||||
// open the pdf document
|
|
||||||
InputStream inputStream = file.getInputStream();
|
|
||||||
PDDocument document = PDDocument.load(inputStream);
|
|
||||||
|
|
||||||
List<Integer> pageNumbers = new ArrayList<>();
|
|
||||||
pages = pages.replaceAll("\\s+", ""); // remove whitespaces
|
|
||||||
if (pages.toLowerCase().equals("all")) {
|
|
||||||
for (int i = 0; i < document.getNumberOfPages(); i++) {
|
|
||||||
pageNumbers.add(i);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
List<String> pageNumbersStr = new ArrayList<>(Arrays.asList(pages.split(",")));
|
|
||||||
if (!pageNumbersStr.contains(String.valueOf(document.getNumberOfPages()))) {
|
|
||||||
String lastpage = String.valueOf(document.getNumberOfPages());
|
|
||||||
pageNumbersStr.add(lastpage);
|
|
||||||
}
|
|
||||||
for (String page : pageNumbersStr) {
|
|
||||||
if (page.contains("-")) {
|
|
||||||
String[] range = page.split("-");
|
|
||||||
int start = Integer.parseInt(range[0]);
|
|
||||||
int end = Integer.parseInt(range[1]);
|
|
||||||
for (int i = start; i <= end; i++) {
|
|
||||||
pageNumbers.add(i);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pageNumbers.add(Integer.parseInt(page));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("Splitting PDF into pages: {}",
|
|
||||||
pageNumbers.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
||||||
|
|
||||||
// split the document
|
|
||||||
List<ByteArrayOutputStream> splitDocumentsBoas = new ArrayList<>();
|
|
||||||
int currentPage = 0;
|
|
||||||
for (int pageNumber : pageNumbers) {
|
|
||||||
try (PDDocument splitDocument = new PDDocument()) {
|
|
||||||
for (int i = currentPage; i < pageNumber; i++) {
|
|
||||||
PDPage page = document.getPage(i);
|
|
||||||
splitDocument.addPage(page);
|
|
||||||
logger.debug("Adding page {} to split document", i);
|
|
||||||
}
|
|
||||||
currentPage = pageNumber;
|
|
||||||
logger.debug("Setting current page to {}", currentPage);
|
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
splitDocument.save(baos);
|
|
||||||
|
|
||||||
splitDocumentsBoas.add(baos);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Failed splitting documents and saving them", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// closing the original document
|
|
||||||
document.close();
|
|
||||||
|
|
||||||
// create the zip file
|
|
||||||
Path zipFile = Paths.get("split_documents.zip");
|
|
||||||
URI uri = URI.create("jar:file:" + zipFile.toUri().getPath());
|
|
||||||
Map<String, String> env = new HashMap<>();
|
|
||||||
env.put("create", "true");
|
|
||||||
FileSystem zipfs = FileSystems.newFileSystem(uri, env);
|
|
||||||
|
|
||||||
// loop through the split documents and write them to the zip file
|
|
||||||
for (int i = 0; i < splitDocumentsBoas.size(); i++) {
|
|
||||||
String fileName = "split_document_" + (i + 1) + ".pdf";
|
|
||||||
ByteArrayOutputStream baos = splitDocumentsBoas.get(i);
|
|
||||||
byte[] pdf = baos.toByteArray();
|
|
||||||
Path pathInZipfile = zipfs.getPath(fileName);
|
|
||||||
try (OutputStream os = Files.newOutputStream(pathInZipfile)) {
|
|
||||||
os.write(pdf);
|
|
||||||
logger.info("Wrote split document {} to zip file", fileName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Failed writing to zip", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zipfs.close();
|
|
||||||
logger.info("Successfully created zip file with split documents: {}", zipFile.toString());
|
|
||||||
byte[] data = Files.readAllBytes(zipFile);
|
|
||||||
ByteArrayResource resource = new ByteArrayResource(data);
|
|
||||||
new File("split_documents.zip").delete();
|
|
||||||
// return the Resource in the response
|
|
||||||
return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=split_documents.zip")
|
|
||||||
.contentType(MediaType.APPLICATION_OCTET_STREAM).contentLength(resource.contentLength()).body(resource);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
package stirling.software.SPDF.utils;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import javax.imageio.IIOImage;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.imageio.ImageWriter;
|
|
||||||
import javax.imageio.stream.ImageOutputStream;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
|
||||||
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
|
||||||
import org.apache.pdfbox.rendering.ImageType;
|
|
||||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class PdfUtils {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PdfUtils.class);
|
|
||||||
|
|
||||||
public static byte[] convertToPdf(InputStream imageStream) throws IOException {
|
|
||||||
|
|
||||||
// Create a File object for the image
|
|
||||||
File imageFile = new File("image.jpg");
|
|
||||||
|
|
||||||
try (FileOutputStream fos = new FileOutputStream(imageFile); InputStream input = imageStream) {
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int len;
|
|
||||||
// Read from the input stream and write to the file
|
|
||||||
while ((len = input.read(buffer)) != -1) {
|
|
||||||
fos.write(buffer, 0, len);
|
|
||||||
}
|
|
||||||
logger.info("Image successfully written to file: {}", imageFile.getAbsolutePath());
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("Error writing image to file: {}", imageFile.getAbsolutePath(), e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (PDDocument doc = new PDDocument()) {
|
|
||||||
// Create a new PDF page
|
|
||||||
PDPage page = new PDPage();
|
|
||||||
doc.addPage(page);
|
|
||||||
|
|
||||||
// Create an image object from the image file
|
|
||||||
PDImageXObject image = PDImageXObject.createFromFileByContent(imageFile, doc);
|
|
||||||
|
|
||||||
try (PDPageContentStream contentStream = new PDPageContentStream(doc, page)) {
|
|
||||||
// Draw the image onto the page
|
|
||||||
contentStream.drawImage(image, 0, 0);
|
|
||||||
logger.info("Image successfully added to PDF");
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("Error adding image to PDF", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a ByteArrayOutputStream to save the PDF to
|
|
||||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
||||||
doc.save(byteArrayOutputStream);
|
|
||||||
logger.info("PDF successfully saved to byte array");
|
|
||||||
return byteArrayOutputStream.toByteArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] convertFromPdf(byte[] inputStream, String imageType) throws IOException {
|
|
||||||
try (PDDocument document = PDDocument.load(new ByteArrayInputStream(inputStream))) {
|
|
||||||
// Create a PDFRenderer to convert the PDF to an image
|
|
||||||
PDFRenderer pdfRenderer = new PDFRenderer(document);
|
|
||||||
BufferedImage bim = pdfRenderer.renderImageWithDPI(0, 300, ImageType.RGB);
|
|
||||||
|
|
||||||
// Get an ImageWriter for the specified image type
|
|
||||||
Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(imageType);
|
|
||||||
ImageWriter writer = writers.next();
|
|
||||||
|
|
||||||
// Create a ByteArrayOutputStream to save the image to
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
try (ImageOutputStream ios = ImageIO.createImageOutputStream(baos)) {
|
|
||||||
writer.setOutput(ios);
|
|
||||||
// Write the image to the output stream
|
|
||||||
writer.write(new IIOImage(bim, null, null));
|
|
||||||
// Log that the image was successfully written to the byte array
|
|
||||||
logger.info("Image successfully written to byte array");
|
|
||||||
}
|
|
||||||
return baos.toByteArray();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Log an error message if there is an issue converting the PDF to an image
|
|
||||||
logger.error("Error converting PDF to image", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] overlayImage(byte[] pdfBytes, byte[] imageBytes, float x, float y) throws IOException {
|
|
||||||
|
|
||||||
try (PDDocument document = PDDocument.load(new ByteArrayInputStream(pdfBytes))) {
|
|
||||||
// Get the first page of the PDF
|
|
||||||
PDPage page = document.getPage(0);
|
|
||||||
try (PDPageContentStream contentStream = new PDPageContentStream(document, page,
|
|
||||||
PDPageContentStream.AppendMode.APPEND, true)) {
|
|
||||||
// Create an image object from the image bytes
|
|
||||||
PDImageXObject image = PDImageXObject.createFromByteArray(document, imageBytes, "");
|
|
||||||
// Draw the image onto the page at the specified x and y coordinates
|
|
||||||
contentStream.drawImage(image, x, y);
|
|
||||||
logger.info("Image successfully overlayed onto PDF");
|
|
||||||
}
|
|
||||||
// Create a ByteArrayOutputStream to save the PDF to
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
document.save(baos);
|
|
||||||
logger.info("PDF successfully saved to byte array");
|
|
||||||
return baos.toByteArray();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Log an error message if there is an issue overlaying the image onto the PDF
|
|
||||||
logger.error("Error overlaying image onto PDF", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
spring.http.multipart.max-file-size=1GB
|
|
||||||
spring.http.multipart.max-request-size=1GB
|
|
||||||
|
|
||||||
multipart.enabled=true
|
|
||||||
multipart.max-file-size=1000MB
|
|
||||||
multipart.max-request-size=1000MB
|
|
||||||
|
|
||||||
spring.servlet.multipart.max-file-size=1000MB
|
|
||||||
spring.servlet.multipart.max-request-size=1000MB
|
|
||||||
|
|
||||||
server.forward-headers-strategy=NATIVE
|
|
@ -1,8 +0,0 @@
|
|||||||
log4j.rootLogger=ERROR,stdout
|
|
||||||
log4j.logger.com.endeca=INFO
|
|
||||||
# Logger for crawl metrics
|
|
||||||
log4j.logger.com.endeca.itl.web.metrics=INFO
|
|
||||||
|
|
||||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
|
||||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
|
||||||
log4j.appender.stdout.layout.ConversionPattern=%p\t%d{ISO8601}\t%r\t%c\t[%t]\t%m%n
|
|
@ -1,23 +0,0 @@
|
|||||||
/* Dark Mode Styles */
|
|
||||||
body {
|
|
||||||
background-color: #333;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark-card {
|
|
||||||
background-color: #333 !important;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.jumbotron {
|
|
||||||
background-color: #222; /* or any other dark color */
|
|
||||||
color: #fff; /* or any other light color */
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-group {
|
|
||||||
background-color: #222 !important;
|
|
||||||
color: fff !important;
|
|
||||||
}
|
|
||||||
.list-group-item {
|
|
||||||
background-color: #222 !important;
|
|
||||||
color: fff !important;
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB |
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 100 100"><rect width="100" height="100" rx="50" fill="#000000"></rect><path fill="#ffffff" d="M22.76 53.83L18.32 53.83L18.32 63.29Q18.06 63.38 17.62 63.49Q17.18 63.60 16.65 63.60L16.65 63.60Q14.71 63.60 14.71 61.97L14.71 61.97L14.71 38.56Q14.71 37.86 15.06 37.48Q15.42 37.11 16.16 36.89L16.16 36.89Q17.44 36.49 19.27 36.32Q21.09 36.14 22.81 36.14L22.81 36.14Q28.40 36.14 30.97 38.49Q33.54 40.85 33.54 44.85L33.54 44.85Q33.54 48.94 30.90 51.39Q28.26 53.83 22.76 53.83L22.76 53.83ZM18.28 50.84L22.54 50.84Q26.06 50.84 28.00 49.38Q29.94 47.93 29.94 44.90L29.94 44.90Q29.94 41.90 28.07 40.52Q26.20 39.13 22.72 39.13L22.72 39.13Q21.53 39.13 20.37 39.24Q19.20 39.35 18.28 39.53L18.28 39.53L18.28 50.84ZM58.40 49.69L58.40 49.69Q58.40 46.88 57.55 44.87Q56.69 42.87 55.21 41.60Q53.74 40.32 51.78 39.73Q49.82 39.13 47.58 39.13L47.58 39.13Q46.17 39.13 45.14 39.22Q44.10 39.31 43.22 39.48L43.22 39.48L43.22 60.43Q44.28 60.69 45.49 60.78Q46.70 60.87 47.98 60.87L47.98 60.87Q53.17 60.87 55.79 58.05Q58.40 55.24 58.40 49.69ZM62.06 49.69L62.06 49.69Q62.06 53.30 61.07 55.96Q60.08 58.62 58.25 60.38Q56.42 62.14 53.83 63.00Q51.23 63.86 48.02 63.86L48.02 63.86Q46.61 63.86 44.85 63.75Q43.09 63.64 41.51 63.16L41.51 63.16Q39.66 62.58 39.66 61.13L39.66 61.13L39.66 38.52Q39.66 37.81 40.01 37.44Q40.36 37.06 41.11 36.84L41.11 36.84Q42.48 36.40 44.19 36.27Q45.91 36.14 47.62 36.14L47.62 36.14Q50.84 36.14 53.50 37.00Q56.16 37.86 58.05 39.55Q59.94 41.24 61 43.77Q62.06 46.30 62.06 49.69ZM70.28 36.62L84.89 36.62Q85.02 36.84 85.16 37.22Q85.29 37.59 85.29 38.03L85.29 38.03Q85.29 38.78 84.94 39.22Q84.58 39.66 83.92 39.66L83.92 39.66L71.96 39.66L71.96 48.81L83.35 48.81Q83.48 49.03 83.62 49.41Q83.75 49.78 83.75 50.22L83.75 50.22Q83.75 50.97 83.40 51.41Q83.04 51.85 82.38 51.85L82.38 51.85L71.96 51.85L71.96 63.33Q71.74 63.42 71.27 63.51Q70.81 63.60 70.33 63.60L70.33 63.60Q68.35 63.60 68.35 62.01L68.35 62.01L68.35 38.56Q68.35 37.68 68.88 37.15Q69.40 36.62 70.28 36.62L70.28 36.62Z"></path></svg>
|
|
Before Width: | Height: | Size: 2.0 KiB |
@ -1,5 +0,0 @@
|
|||||||
#footer {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<th:block th:insert="~{common :: head}"></th:block>
|
|
||||||
<title>S-PDF Add-Image</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div th:insert="~{navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>Add image to PDF</h2>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form method="post" th:action="@{add-image}"
|
|
||||||
enctype="multipart/form-data">
|
|
||||||
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label" for="fileInput">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput2"
|
|
||||||
name="fileInput2" required> <label
|
|
||||||
class="custom-file-label" for="fileInput2">Choose Image</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="x">X</label> <input type="number" class="form-control"
|
|
||||||
id="x" name="x" step="0.01" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="y">Y</label> <input type="number" class="form-control"
|
|
||||||
id="y" name="y" step="0.01" required>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{footer.html :: footer}"></div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,95 +0,0 @@
|
|||||||
<head th:fragment="head">
|
|
||||||
<link rel="shortcut icon" href="favicon.svg">
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
|
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
|
|
||||||
<link rel="stylesheet" th:href="@{dark-mode.css}" id="dark-mode-styles">
|
|
||||||
<script>
|
|
||||||
function toggleDarkMode() {
|
|
||||||
var checkbox = document.getElementById("toggle-dark-mode");
|
|
||||||
var darkModeStyles = document.getElementById("dark-mode-styles");
|
|
||||||
if (checkbox.checked) {
|
|
||||||
localStorage.setItem("dark-mode", "on");
|
|
||||||
darkModeStyles.disabled = false;
|
|
||||||
} else {
|
|
||||||
localStorage.setItem("dark-mode", "off");
|
|
||||||
darkModeStyles.disabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$(document).ready(function () {
|
|
||||||
var darkModeStyles = document.getElementById("dark-mode-styles");
|
|
||||||
var checkbox = document.getElementById("toggle-dark-mode");
|
|
||||||
if (localStorage.getItem("dark-mode") == "on") {
|
|
||||||
darkModeStyles.disabled = false;
|
|
||||||
checkbox.checked = true;
|
|
||||||
}
|
|
||||||
if (localStorage.getItem("dark-mode") == "off") {
|
|
||||||
darkModeStyles.disabled = true;
|
|
||||||
checkbox.checked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" href="general.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<th:block th:fragment="filelist">
|
|
||||||
<div id="fileList"></div>
|
|
||||||
<div id="fileList2"></div>
|
|
||||||
<script>
|
|
||||||
var input = document.getElementById("fileInput");
|
|
||||||
var output = document.getElementById("fileList");
|
|
||||||
|
|
||||||
input.addEventListener("change", function () {
|
|
||||||
var files = input.files;
|
|
||||||
var fileNames = "";
|
|
||||||
|
|
||||||
for (var i = 0; i < files.length; i++) {
|
|
||||||
fileNames += (i + 1) + ". " + files[i].name + "<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
output.innerHTML = fileNames;
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
var input2 = document.getElementById("fileInput2");
|
|
||||||
var output2 = document.getElementById("fileList2");
|
|
||||||
if (input2 != null && !input2) {
|
|
||||||
input2.addEventListener("change", function () {
|
|
||||||
var files = input2.files;
|
|
||||||
var fileNames = "";
|
|
||||||
|
|
||||||
for (var i = 0; i < files.length; i++) {
|
|
||||||
fileNames += (i + 1) + ". " + files[i].name + "<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
output2.innerHTML = fileNames;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
if (dropContainer) {
|
|
||||||
dropContainer.ondragover = dropContainer.ondragenter = function (evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
};
|
|
||||||
|
|
||||||
dropContainer.ondrop = function (evt) {
|
|
||||||
if(fileInput) {
|
|
||||||
fileInput.files = evt.dataTransfer.files;
|
|
||||||
|
|
||||||
const dT = new DataTransfer();
|
|
||||||
dT.items.add(evt.dataTransfer.files[0]);
|
|
||||||
dT.items.add(evt.dataTransfer.files[3]);
|
|
||||||
fileInput.files = dT.files;
|
|
||||||
|
|
||||||
evt.preventDefault();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</th:block>
|
|
@ -1,43 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<th:block th:insert="~{common :: head}"></th:block>
|
|
||||||
<title>S-PDF Add-Image</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div th:insert="~{navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>Compress PDF</h2>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form action="#" th:action="@{compress-pdf}" th:object="${rotateForm}"
|
|
||||||
method="post" enctype="multipart/form-data">
|
|
||||||
<p>Warning: This process can take up to a minute depending on file-size</p>
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label" for="fileInput">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="imageCompressionLevel">Value between 1 and 100 (1 being most reduced)</label> <input type="number" class="form-control"
|
|
||||||
id="imageCompressionLevel" name="imageCompressionLevel" step="1" value="1" min="1" max="100" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">Compress</button>
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{footer.html :: footer}"></div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,61 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
<head>
|
|
||||||
<th:block th:insert="~{common :: head}"></th:block>
|
|
||||||
<title>S-PDF ConvertToPDF</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div th:insert="~{navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>Image to PDF</h2>
|
|
||||||
|
|
||||||
<form method="post" enctype="multipart/form-data"
|
|
||||||
th:action="@{convert-to-pdf}">
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label" for="fileInput">Choose Image</label>
|
|
||||||
</div>
|
|
||||||
<br><br>
|
|
||||||
<button type="submit" class="btn btn-primary">Convert</button>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{common :: filelist}"></th:block>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br><br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>PDF to img</h2>
|
|
||||||
<form method="post" enctype="multipart/form-data"
|
|
||||||
th:action="@{convert-from-pdf}">
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label" for="fileInput">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Image Format</label> <select class="form-control"
|
|
||||||
name="imageFormat">
|
|
||||||
<option value="jpg">JPEG</option>
|
|
||||||
<option value="png">PNG</option>
|
|
||||||
<option value="gif">GIF</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary">Convert</button>
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{footer.html :: footer}"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,11 +0,0 @@
|
|||||||
<div th:fragment="footer">
|
|
||||||
<link rel="stylesheet"
|
|
||||||
href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
|
|
||||||
<footer id="footer" class="text-center py-3">
|
|
||||||
<a href="https://github.com/Frooodle/Stirling-PDF" target="_blank" class="mx-1">
|
|
||||||
<i class="fab fa-github fa-2x"></i>
|
|
||||||
</a> <a href="https://hub.docker.com/r/frooodle/s-pdf" target="_blank"
|
|
||||||
class="mx-1"> <i class="fab fa-docker fa-2x"></i>
|
|
||||||
</a>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
@ -1,108 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<th:block th:insert="~{common :: head}"></th:block>
|
|
||||||
<title>S-PDF</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div th:insert="~{navbar.html :: navbar}"></div>
|
|
||||||
<!-- Jumbotron -->
|
|
||||||
<div class="jumbotron jumbotron-fluid" id="jumbotron">
|
|
||||||
<div class="container">
|
|
||||||
<h1 class="display-4">Stirling PDF</h1>
|
|
||||||
<p class="lead">Your locally hosted one-stop-shop for all your
|
|
||||||
PDF needs. (Made 100% in ChatGPT in 1 day as a experiment)</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Features -->
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row h-100">
|
|
||||||
<div class="col-4 h-100">
|
|
||||||
<div class="dark-card card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Merge PDFs</h5>
|
|
||||||
<p class="card-text">Easily merge multiple PDFs into one.</p>
|
|
||||||
<a href="#" class="btn btn-primary" th:href="@{merge-pdfs}">Go</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-4 h-100">
|
|
||||||
<div class="dark-card card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Split PDFs</h5>
|
|
||||||
<p class="card-text">Split PDFs into multiple documents</p>
|
|
||||||
<a href="#" class="btn btn-primary" th:href="@{split-pdfs}">Go</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-4 h-100">
|
|
||||||
<div class="dark-card card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Add image to PDF</h5>
|
|
||||||
<p class="card-text">Adds image/watermark to a PDF</p>
|
|
||||||
<a href="#" class="btn btn-primary" th:href="@{add-image}">Go</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="row h-100">
|
|
||||||
<div class="col-4 h-100">
|
|
||||||
<div class="dark-card card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Convert to/from PDF</h5>
|
|
||||||
<p class="card-text">Convert images to/from PDF.</p>
|
|
||||||
<a href="#" class="btn btn-primary" th:href="@{convert-pdf}">Go</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-4 h-100">
|
|
||||||
<div class="dark-card card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">PDF Organizer</h5>
|
|
||||||
<p class="card-text">Remove/Rearrange pages in any order</p>
|
|
||||||
<a href="#" class="btn btn-primary" th:href="@{pdf-organizer}">Go</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-4 h-100">
|
|
||||||
<div class="dark-card card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Rotate PDFs</h5>
|
|
||||||
<p class="card-text">Easily rotate your PDFs.</p>
|
|
||||||
<a href="#" class="btn btn-primary" th:href="@{rotate-pdf}">Go</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="row h-100">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="col-4 h-100">
|
|
||||||
<div class="dark-card card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Compress PDFs</h5>
|
|
||||||
<p class="card-text">Compress PDFs to reduce their file size.</p>
|
|
||||||
<a href="#" class="btn btn-primary" th:href="@{compress-pdf}">Go</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{footer.html :: footer}"></div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,106 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
<head>
|
|
||||||
<th:block th:insert="~{common :: head}"></th:block>
|
|
||||||
<title>S-PDF MergePDFs</title>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div th:insert="~{navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container" id="dropContainer">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6" >
|
|
||||||
<h2>Merge multiple PDFs (2+)</h2>
|
|
||||||
<form action="merge-pdfs" method="post"
|
|
||||||
enctype="multipart/form-data">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Select (or drag & drop) all PDFs to merge</label>
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" multiple> <label
|
|
||||||
class="custom-file-label">Choose PDFs</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<ul id="selectedFiles" class="list-group"></ul>
|
|
||||||
</div>
|
|
||||||
<div class="form-group text-center">
|
|
||||||
<button type="submit" class="btn btn-primary">Merge</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
document.getElementById("fileInput").addEventListener("change", function() {
|
|
||||||
var files = this.files;
|
|
||||||
var list = document.getElementById("selectedFiles");
|
|
||||||
list.innerHTML = "";
|
|
||||||
for (var i = 0; i < files.length; i++) {
|
|
||||||
var item = document.createElement("li");
|
|
||||||
item.className = "list-group-item d-flex justify-content-between align-items-center";
|
|
||||||
item.textContent = files[i].name;
|
|
||||||
item.innerHTML += '<div><button class="btn btn-secondary move-up">Move Up</button> <button class="btn btn-secondary move-down">Move Down</button></div>';
|
|
||||||
list.appendChild(item);
|
|
||||||
}
|
|
||||||
var moveUpButtons = document.querySelectorAll(".move-up");
|
|
||||||
for (var i = 0; i < moveUpButtons.length; i++) {
|
|
||||||
moveUpButtons[i].addEventListener("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
var parent = this.parentNode.parentNode;
|
|
||||||
var grandParent = parent.parentNode;
|
|
||||||
if (parent.previousElementSibling) {
|
|
||||||
grandParent.insertBefore(parent, parent.previousElementSibling);
|
|
||||||
updateFiles();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var moveDownButtons = document.querySelectorAll(".move-down");
|
|
||||||
for (var i = 0; i < moveDownButtons.length; i++) {
|
|
||||||
moveDownButtons[i].addEventListener("click", function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
var parent = this.parentNode.parentNode;
|
|
||||||
var grandParent = parent.parentNode;
|
|
||||||
if (parent.nextElementSibling) {
|
|
||||||
grandParent.insertBefore(parent.nextElementSibling, parent);
|
|
||||||
updateFiles();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateFiles() {
|
|
||||||
var dataTransfer = new DataTransfer();
|
|
||||||
var liElements = document.querySelectorAll("#selectedFiles li");
|
|
||||||
|
|
||||||
for (var i = 0; i < liElements.length; i++) {
|
|
||||||
var fileNameFromList = liElements[i].innerText.replace("\nMove Up Move Down","");
|
|
||||||
var fileFromFiles
|
|
||||||
for (var j = 0; j < files.length; j++) {
|
|
||||||
var file = files[j];
|
|
||||||
if(file.name === fileNameFromList){
|
|
||||||
dataTransfer.items.add(file);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.getElementById("fileInput").files = dataTransfer.files;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{footer.html :: footer}"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,49 +0,0 @@
|
|||||||
<div th:fragment="navbar">
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
||||||
<div class="container">
|
|
||||||
<a class="navbar-brand" href="#" th:href="@{home}">Stirling PDF</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse"
|
|
||||||
data-target="#navbarNav" aria-controls="navbarNav"
|
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav">
|
|
||||||
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{merge-pdfs}"
|
|
||||||
th:classappend="${currentPage}=='merge-pdfs' ? 'active' : ''">Merge
|
|
||||||
PDFs</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{split-pdfs}"
|
|
||||||
th:classappend="${currentPage}=='split-pdfs' ? 'active' : ''">Split
|
|
||||||
PDFs</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{convert-pdf}"
|
|
||||||
th:classappend="${currentPage}=='convert-pdf' ? 'active' : ''">Convert
|
|
||||||
to/from PDF</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{add-image}"
|
|
||||||
th:classappend="${currentPage}=='add-image' ? 'active' : ''">Add
|
|
||||||
image to PDF</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{pdf-organizer}"
|
|
||||||
th:classappend="${currentPage}=='pdf-organizer' ? 'active' : ''">PDF
|
|
||||||
Organizer</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{rotate-pdf}"
|
|
||||||
th:classappend="${currentPage}=='rotate-pdf' ? 'active' : ''">Rotate PDF</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{compress-pdf}"
|
|
||||||
th:classappend="${currentPage}=='compress-pdf' ? 'active' : ''">Compress PDF</a></li>
|
|
||||||
|
|
||||||
<input type="checkbox" id="toggle-dark-mode"
|
|
||||||
th:onclick="javascript:toggleDarkMode()">
|
|
||||||
<a class="nav-link" href="#" for="toggle-dark-mode">Dark Mode</a>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
@ -1,42 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
<head>
|
|
||||||
<th:block th:insert="~{common :: head}"></th:block>
|
|
||||||
<title>S-PDF Organizer</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div th:insert="~{navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>PDF Page Organizer</h2>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form th:action="@{rearrange-pages}" method="post"
|
|
||||||
enctype="multipart/form-data">
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label" for="fileInput">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="pageOrder">Page Order (Enter a comma-separated
|
|
||||||
list of page numbers) :</label> <input type="text" class="form-control"
|
|
||||||
id="fileInput" name="pageOrder"
|
|
||||||
placeholder="(e.g. 1,3,2 or 4-8,2,10-12)" required>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary">Rearrange
|
|
||||||
Pages</button>
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{footer.html :: footer}"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,47 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<th:block th:insert="~{common :: head}"></th:block>
|
|
||||||
<title>S-PDF Add-Image</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div th:insert="~{navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>Rotate PDF</h2>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form action="#" th:action="@{rotate-pdf}" th:object="${rotateForm}"
|
|
||||||
method="post" enctype="multipart/form-data">
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label" for="fileInput">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label for="angle">Select rotation angle (in multiples of
|
|
||||||
90 degrees):</label> <select id="angle" class="form-control" name="angle">
|
|
||||||
<option value="90">90</option>
|
|
||||||
<option value="180">180</option>
|
|
||||||
<option value="270">270</option>
|
|
||||||
<option value="-90">-90</option>
|
|
||||||
<option value="-180">-180</option>
|
|
||||||
<option value="-270">-270</option>
|
|
||||||
</select> <br>
|
|
||||||
<button type="submit" class="btn btn-primary">Rotate</button>
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{footer.html :: footer}"></div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,49 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
<head>
|
|
||||||
<th:block th:insert="~{common :: head}"></th:block>
|
|
||||||
<title>S-PDF Split PDFs</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div th:insert="~{navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h1>Split PDF</h1>
|
|
||||||
<p>The numbers you select are the page number you wish to do a
|
|
||||||
split on</p>
|
|
||||||
<p>As such selecting 1,3,7-8 would split a 10 page document into
|
|
||||||
6 separate PDFS with:</p>
|
|
||||||
<p>Document #1: Page 1</p>
|
|
||||||
<p>Document #2: Page 2 and 3</p>
|
|
||||||
<p>Document #3: Page 4, 5 and 6</p>
|
|
||||||
<p>Document #4: Page 7</p>
|
|
||||||
<p>Document #5: Page 8</p>
|
|
||||||
<p>Document #6: Page 9 and 10</p>
|
|
||||||
|
|
||||||
<form th:action="@{split-pages}" method="post"
|
|
||||||
enctype="multipart/form-data">
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label" for="fileInput">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="pages">Enter pages to split on:</label> <input
|
|
||||||
type="text" class="form-control" id="pages" name="pages"
|
|
||||||
placeholder="1,3,5-10">
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{common :: filelist}"></th:block>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{footer.html :: footer}"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in New Issue
Block a user