Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d1dd8fc604 | |||
| 24395a1ddd | |||
| 02a3396b5f | |||
| 64ae78ad7a | |||
| 00000344bb |
@@ -1,13 +0,0 @@
|
|||||||
# These are supported funding model platforms
|
|
||||||
|
|
||||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
|
||||||
patreon: # Replace with a single Patreon username
|
|
||||||
open_collective: # Replace with a single Open Collective username
|
|
||||||
ko_fi: # Replace with a single Ko-fi username
|
|
||||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
||||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
||||||
liberapay: # Replace with a single Liberapay username
|
|
||||||
issuehunt: # Replace with a single IssueHunt username
|
|
||||||
otechie: # Replace with a single Otechie username
|
|
||||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
|
||||||
custom: ['https://paypal.me/froodleplex?country.x=GB&locale.x=en_GB'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "gradle" # See documentation for possible values
|
|
||||||
directory: "/" # Location of package manifests
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# For most projects, this workflow file will not need changing; you simply need
|
|
||||||
# to commit it to your repository.
|
|
||||||
#
|
|
||||||
# You may wish to alter this file to override the set of languages analyzed,
|
|
||||||
# or to provide custom queries or build logic.
|
|
||||||
#
|
|
||||||
# ******** NOTE ********
|
|
||||||
# We have attempted to detect the languages in your repository. Please check
|
|
||||||
# the `language` matrix defined below to confirm you have the correct set of
|
|
||||||
# supported CodeQL languages.
|
|
||||||
#
|
|
||||||
name: "CodeQL"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "main" ]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [ "main" ]
|
|
||||||
schedule:
|
|
||||||
- cron: '15 12 * * 1'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
analyze:
|
|
||||||
name: Analyze
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set up JDK 17
|
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
java-version: '17'
|
|
||||||
distribution: 'temurin'
|
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@v2
|
|
||||||
with:
|
|
||||||
languages: java
|
|
||||||
|
|
||||||
- uses: gradle/gradle-build-action@v2.3.3
|
|
||||||
with:
|
|
||||||
gradle-version: 7.6
|
|
||||||
arguments: assemble --no-build-cache
|
|
||||||
|
|
||||||
- name: Perform CodeQL analysis
|
|
||||||
uses: github/codeql-action/analyze@v2
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
name: Push Docker Image with VersionNumber
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- main
|
|
||||||
jobs:
|
|
||||||
push:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set up JDK 17
|
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
java-version: '17'
|
|
||||||
distribution: 'temurin'
|
|
||||||
|
|
||||||
|
|
||||||
- uses: gradle/gradle-build-action@v2.3.3
|
|
||||||
with:
|
|
||||||
gradle-version: 7.6
|
|
||||||
arguments: clean build
|
|
||||||
|
|
||||||
- name: Make Gradle wrapper executable
|
|
||||||
run: chmod +x gradlew
|
|
||||||
|
|
||||||
- name: Get version number
|
|
||||||
id: versionNumber
|
|
||||||
run: echo "::set-output name=versionNumber::$(./gradlew printVersion --quiet | tail -1)"
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v2.1.0
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_HUB_API }}
|
|
||||||
|
|
||||||
- name: Setup buildx
|
|
||||||
run: |
|
|
||||||
docker buildx create --name mybuilder
|
|
||||||
docker buildx use mybuilder
|
|
||||||
|
|
||||||
- name: Build and push versioned amd64 and v8
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
run: |
|
|
||||||
docker buildx build --platform="linux/amd64,linux/arm64/v8" --push --tag "frooodle/s-pdf:${{ steps.versionNumber.outputs.versionNumber }}" .
|
|
||||||
|
|
||||||
|
|
||||||
- name: Build and push latest amd64 and v8
|
|
||||||
if: github.ref == 'refs/heads/master'
|
|
||||||
run: |
|
|
||||||
docker buildx build --platform="linux/amd64,linux/arm64/v8" --push --tag "frooodle/s-pdf:latest" .
|
|
||||||
|
|
||||||
|
|
||||||
-109
@@ -1,109 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
### Eclipse ###
|
|
||||||
.metadata
|
|
||||||
bin/
|
|
||||||
tmp/
|
|
||||||
*.tmp
|
|
||||||
*.bak
|
|
||||||
*.swp
|
|
||||||
*~.nib
|
|
||||||
local.properties
|
|
||||||
.settings/
|
|
||||||
.loadpath
|
|
||||||
.recommenders
|
|
||||||
|
|
||||||
|
|
||||||
# Gradle
|
|
||||||
.gradle
|
|
||||||
.lock
|
|
||||||
|
|
||||||
# External tool builders
|
|
||||||
.externalToolBuilders/
|
|
||||||
|
|
||||||
# Locally stored "Eclipse launch configurations"
|
|
||||||
*.launch
|
|
||||||
|
|
||||||
# PyDev specific (Python IDE for Eclipse)
|
|
||||||
*.pydevproject
|
|
||||||
|
|
||||||
# CDT-specific (C/C++ Development Tooling)
|
|
||||||
.cproject
|
|
||||||
|
|
||||||
# CDT- autotools
|
|
||||||
.autotools
|
|
||||||
|
|
||||||
# Java annotation processor (APT)
|
|
||||||
.factorypath
|
|
||||||
|
|
||||||
# PDT-specific (PHP Development Tools)
|
|
||||||
.buildpath
|
|
||||||
|
|
||||||
# sbteclipse plugin
|
|
||||||
.target
|
|
||||||
|
|
||||||
# Tern plugin
|
|
||||||
.tern-project
|
|
||||||
|
|
||||||
# TeXlipse plugin
|
|
||||||
.texlipse
|
|
||||||
|
|
||||||
# STS (Spring Tool Suite)
|
|
||||||
.springBeans
|
|
||||||
|
|
||||||
# Code Recommenders
|
|
||||||
.recommenders/
|
|
||||||
|
|
||||||
# Annotation Processing
|
|
||||||
.apt_generated/
|
|
||||||
.apt_generated_test/
|
|
||||||
|
|
||||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
|
||||||
.cache-main
|
|
||||||
.scala_dependencies
|
|
||||||
.worksheet
|
|
||||||
|
|
||||||
# Uncomment this line if you wish to ignore the project description file.
|
|
||||||
# Typically, this file would be tracked if it contains build/dependency configurations:
|
|
||||||
#.project
|
|
||||||
|
|
||||||
### Eclipse Patch ###
|
|
||||||
# Spring Boot Tooling
|
|
||||||
.sts4-cache/
|
|
||||||
|
|
||||||
### Git ###
|
|
||||||
# Created by git for backups. To disable backups in Git:
|
|
||||||
# $ git config --global mergetool.keepBackup false
|
|
||||||
*.orig
|
|
||||||
|
|
||||||
# Created by git when using merge tools for conflicts
|
|
||||||
*.BACKUP.*
|
|
||||||
*.BASE.*
|
|
||||||
*.LOCAL.*
|
|
||||||
*.REMOTE.*
|
|
||||||
*_BACKUP_*.txt
|
|
||||||
*_BASE_*.txt
|
|
||||||
*_LOCAL_*.txt
|
|
||||||
*_REMOTE_*.txt
|
|
||||||
|
|
||||||
### Java ###
|
|
||||||
# Compiled class file
|
|
||||||
*.class
|
|
||||||
|
|
||||||
# Log file
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# BlueJ files
|
|
||||||
*.ctxt
|
|
||||||
|
|
||||||
# Mobile Tools for Java (J2ME)
|
|
||||||
.mtj.tmp/
|
|
||||||
|
|
||||||
# Package Files #
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.nar
|
|
||||||
*.ear
|
|
||||||
*.zip
|
|
||||||
*.tar.gz
|
|
||||||
*.rar
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM openjdk:17-jdk-slim
|
|
||||||
COPY build/libs/*.jar app.jar
|
|
||||||
EXPOSE 8080
|
|
||||||
ENV LOG_LEVEL=INFO
|
|
||||||
ENTRYPOINT ["java","-jar","/app.jar","-Dlogging.level=${LOG_LEVEL}"]
|
|
||||||
Vendored
-33
@@ -1,33 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
stages {
|
|
||||||
stage('Build') {
|
|
||||||
steps {
|
|
||||||
sh 'chmod 755 gradlew'
|
|
||||||
sh './gradlew build'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Docker Build') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
def appVersion = sh(returnStdout: true, script: './gradlew printVersion -q').trim()
|
|
||||||
def image = "frooodle/s-pdf:$appVersion"
|
|
||||||
sh "docker build -t $image ."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Docker Push') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
def appVersion = sh(returnStdout: true, script: './gradlew printVersion -q').trim()
|
|
||||||
def image = "frooodle/s-pdf:$appVersion"
|
|
||||||
withCredentials([string(credentialsId: 'docker_hub_access_token', variable: 'DOCKER_HUB_ACCESS_TOKEN')]) {
|
|
||||||
sh "docker login --username frooodle --password $DOCKER_HUB_ACCESS_TOKEN"
|
|
||||||
sh "docker push $image"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
@@ -1,69 +1,20 @@
|
|||||||
# Stirling-PDF
|
## Usage
|
||||||
|
|
||||||
This is a locally hosted web application that allows you to perform various operations on PDF files, such as splitting and adding images.
|
[Helm](https://helm.sh) must be installed to use the charts. Please refer to
|
||||||
|
Helm's [documentation](https://helm.sh/docs) to get started.
|
||||||
|
|
||||||
Started off as a 100% ChatGPT made application, slowly moving away from that as more features are added
|
Once Helm has been set up correctly, add the repo as follows:
|
||||||
|
|
||||||
I will support and fix/add things to this if there is a demand [Discord](https://discord.gg/Cn8pWhQRxZ)
|
`helm repo add <alias> https://docs.stirlingpdf.com/Stirling-PDF`
|
||||||
|
|
||||||
|
If you had already added this repo earlier, run `helm repo update` to retrieve
|
||||||
|
the latest versions of the packages. You can then run `helm search repo <alias>` to see the charts.
|
||||||
|
|
||||||

|
To install the <chart-name> chart:
|
||||||
|
|
||||||
|
helm install <chart-name> <alias>/<chart-name>
|
||||||
|
|
||||||
## Features
|
To uninstall the chart:
|
||||||
|
|
||||||
- Split PDFs into multiple files at specified page numbers or extract all pages as individual files.
|
helm delete <chart-name>
|
||||||
- Merge multiple PDFs together into a single resultant file
|
|
||||||
- Convert PDFs to and from images
|
|
||||||
- Reorganize PDF pages into different orders.
|
|
||||||
- Add images to PDFs at specified locations.
|
|
||||||
- Rotating PDFs in 90 degree increments.
|
|
||||||
- Compressing PDFs to decrease their filesize.
|
|
||||||
- Add and remove passwords
|
|
||||||
- Set PDF Permissions
|
|
||||||
- Add watermark(s)
|
|
||||||
- Dark mode support.
|
|
||||||
|
|
||||||
## Technologies used
|
|
||||||
- Spring Boot + Thymeleaf
|
|
||||||
- PDFBox
|
|
||||||
- e-iceblue spire.pdf.free (for PDF compression untill i find a nicer way)
|
|
||||||
- HTML, CSS, JavaScript
|
|
||||||
- Docker
|
|
||||||
|
|
||||||
## How to use
|
|
||||||
|
|
||||||
### Locally
|
|
||||||
|
|
||||||
Prerequisites
|
|
||||||
- Java 17 or later
|
|
||||||
- Gradle 7.0 or later
|
|
||||||
|
|
||||||
1. Clone or download the repository.
|
|
||||||
2. Build the project using Gradle by running `./gradlew build`
|
|
||||||
3. Start the application by running `./gradlew bootRun` or by calling the build jar in build/libs with java -jar jarName.jar
|
|
||||||
|
|
||||||
|
|
||||||
### Docker
|
|
||||||
https://hub.docker.com/r/frooodle/s-pdf
|
|
||||||
|
|
||||||
Docker Run
|
|
||||||
```
|
|
||||||
docker run -p 8080:8080 frooodle/s-pdf
|
|
||||||
```
|
|
||||||
Docker Compose
|
|
||||||
```
|
|
||||||
version: '3.3'
|
|
||||||
services:
|
|
||||||
s-pdf:
|
|
||||||
ports:
|
|
||||||
- '8080:8080'
|
|
||||||
image: frooodle/s-pdf
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to View
|
|
||||||
1. Open a web browser and navigate to `http://localhost:8080/`
|
|
||||||
2. Use the application by following the instructions on the website.
|
|
||||||
|
|
||||||
## Note
|
|
||||||
The application is currently not thread-safe
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'java'
|
|
||||||
id 'org.springframework.boot' version '3.0.2'
|
|
||||||
id 'io.spring.dependency-management' version '1.1.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
group = 'stirling.software'
|
|
||||||
version = '0.3.0'
|
|
||||||
sourceCompatibility = '17'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
url "https://repo.e-iceblue.com/nexus/content/groups/public/"
|
|
||||||
name "com.e-iceblue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
|
||||||
implementation 'org.apache.pdfbox:pdfbox:2.0.27'
|
|
||||||
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
|
|
||||||
implementation 'e-iceblue:spire.pdf.free:5.1.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named('test') {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
task printVersion {
|
|
||||||
println project.version
|
|
||||||
}
|
|
||||||
|
|
||||||
Vendored
BIN
Binary file not shown.
-5
@@ -1,5 +0,0 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
@@ -1,240 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright © 2015-2021 the original authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
|
||||||
#
|
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
app_path=$0
|
|
||||||
|
|
||||||
# Need this for daisy-chained symlinks.
|
|
||||||
while
|
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
||||||
[ -h "$app_path" ]
|
|
||||||
do
|
|
||||||
ls=$( ls -ld "$app_path" )
|
|
||||||
link=${ls#*' -> '}
|
|
||||||
case $link in #(
|
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD=maximum
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "$( uname )" in #(
|
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
|
||||||
Darwin* ) darwin=true ;; #(
|
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
|
||||||
NONSTOP* ) nonstop=true ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
||||||
else
|
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD=java
|
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
||||||
case $MAX_FD in #(
|
|
||||||
max*)
|
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
|
||||||
warn "Could not query maximum file descriptor limit"
|
|
||||||
esac
|
|
||||||
case $MAX_FD in #(
|
|
||||||
'' | soft) :;; #(
|
|
||||||
*)
|
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
|
||||||
# * args from the command line
|
|
||||||
# * the main class name
|
|
||||||
# * -classpath
|
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if "$cygwin" || "$msys" ; then
|
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
for arg do
|
|
||||||
if
|
|
||||||
case $arg in #(
|
|
||||||
-*) false ;; # don't mess with options #(
|
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
||||||
Vendored
-91
@@ -1,91 +0,0 @@
|
|||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
|
||||||
@rem ##########################################################################
|
|
||||||
@rem
|
|
||||||
@rem Gradle startup script for Windows
|
|
||||||
@rem
|
|
||||||
@rem ##########################################################################
|
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 69 KiB |
+24
@@ -0,0 +1,24 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
entries:
|
||||||
|
stirling-pdf-chart:
|
||||||
|
- apiVersion: v2
|
||||||
|
appVersion: 0.31.1
|
||||||
|
created: "2024-11-04T20:13:48.298110043Z"
|
||||||
|
description: locally hosted web application that allows you to perform various
|
||||||
|
operations on PDF files
|
||||||
|
digest: 49a6e968f0203e7390094ae7fa20bc3fb0542ebdf426501c170641e98d2a45e2
|
||||||
|
home: https://github.com/Stirling-Tools/Stirling-PDF
|
||||||
|
keywords:
|
||||||
|
- stirling-pdf
|
||||||
|
- helm
|
||||||
|
- charts repo
|
||||||
|
maintainers:
|
||||||
|
- name: Stirling-Tools
|
||||||
|
url: https://github.com/Stirling-Tools/Stirling-PDF
|
||||||
|
name: stirling-pdf-chart
|
||||||
|
sources:
|
||||||
|
- https://github.com/Stirling-Tools/Stirling-PDF
|
||||||
|
urls:
|
||||||
|
- https://github.com/Stirling-Tools/Stirling-PDF/releases/download/stirling-pdf-chart-1.0.1/stirling-pdf-chart-1.0.1.tgz
|
||||||
|
version: 1.0.1
|
||||||
|
generated: "2024-11-04T20:13:48.29811941Z"
|
||||||
@@ -1 +0,0 @@
|
|||||||
rootProject.name = 'S-PDF'
|
|
||||||
@@ -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,74 +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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return PdfUtils.pdfDocToWebResponse(document, pdfFile.getName() + "_compressed.pdf");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,77 +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 MergeController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MergeController.class);
|
|
||||||
|
|
||||||
@GetMapping("/merge-pdfs")
|
|
||||||
public String hello(Model model) {
|
|
||||||
model.addAttribute("currentPage", "merge-pdfs");
|
|
||||||
return "merge-pdfs";
|
|
||||||
}
|
|
||||||
|
|
||||||
@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,46 +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);
|
|
||||||
|
|
||||||
return PdfUtils.bytesToWebResponse(result, pdfFile.getName() + "_overlayed.pdf");
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("Failed to add image to PDF", e);
|
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +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("/home")
|
|
||||||
public String root(Model model) {
|
|
||||||
return "redirect:/";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/")
|
|
||||||
public String home(Model model) {
|
|
||||||
model.addAttribute("currentPage", "home");
|
|
||||||
return "home";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,128 +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;
|
|
||||||
|
|
||||||
import stirling.software.SPDF.utils.PdfUtils;
|
|
||||||
|
|
||||||
@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";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/delete-pages")
|
|
||||||
public String pageDeleter(Model model) {
|
|
||||||
model.addAttribute("currentPage", "delete-pages");
|
|
||||||
return "delete-pages";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/delete-pages")
|
|
||||||
public ResponseEntity<byte[]> deletePages(@RequestParam("fileInput") MultipartFile pdfFile,
|
|
||||||
@RequestParam("pagesToDelete") String pagesToDelete) throws IOException {
|
|
||||||
|
|
||||||
PDDocument document = PDDocument.load(pdfFile.getBytes());
|
|
||||||
|
|
||||||
// Split the page order string into an array of page numbers or range of numbers
|
|
||||||
String[] pageOrderArr = pagesToDelete.split(",");
|
|
||||||
|
|
||||||
List<Integer> pagesToRemove = pageOrderToString(pageOrderArr, document.getNumberOfPages());
|
|
||||||
|
|
||||||
for (int i = pagesToRemove.size() - 1; i >= 0; i--) {
|
|
||||||
int pageIndex = pagesToRemove.get(i);
|
|
||||||
document.removePage(pageIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PdfUtils.pdfDocToWebResponse(document, pdfFile.getName() + "_removed_pages.pdf");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Integer> pageOrderToString(String[] pageOrderArr, int totalPages) {
|
|
||||||
List<Integer> newPageOrder = new ArrayList<Integer>();
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return newPageOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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(",");
|
|
||||||
// int[] newPageOrder = new int[pageOrderArr.length];
|
|
||||||
int totalPages = document.getNumberOfPages();
|
|
||||||
|
|
||||||
List<Integer> newPageOrder = pageOrderToString(pageOrderArr, totalPages);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PdfUtils.pdfDocToWebResponse(document, pdfFile.getName() + "_rearranged.pdf");
|
|
||||||
} catch (IOException e) {
|
|
||||||
|
|
||||||
logger.error("Failed rearranging documents", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,60 +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));
|
|
||||||
}
|
|
||||||
|
|
||||||
return PdfUtils.pdfDocToWebResponse(document, pdfFile.getName() + "_rotated.pdf");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-70
@@ -1,70 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller.converters;
|
|
||||||
|
|
||||||
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 ConvertImgPDFController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ConvertImgPDFController.class);
|
|
||||||
|
|
||||||
@GetMapping("/img-to-pdf")
|
|
||||||
public String convertToPdfForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "img-to-pdf");
|
|
||||||
return "convert/img-to-pdf";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/pdf-to-img")
|
|
||||||
public String pdfToimgForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "pdf-to-img");
|
|
||||||
return "convert/pdf-to-img";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/img-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());
|
|
||||||
|
|
||||||
return PdfUtils.bytesToWebResponse(bytes, file.getName() + "_coverted.pdf");
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/pdf-to-img")
|
|
||||||
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,92 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller.security;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
|
|
||||||
import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
|
|
||||||
import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
|
|
||||||
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 PasswordController {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PasswordController.class);
|
|
||||||
|
|
||||||
@GetMapping("/add-password")
|
|
||||||
public String addPasswordForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "add-password");
|
|
||||||
return "security/add-password";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/remove-password")
|
|
||||||
public String removePasswordForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "remove-password");
|
|
||||||
return "security/remove-password";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/change-permissions")
|
|
||||||
public String permissionsForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "change-permissions");
|
|
||||||
return "security/change-permissions";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/remove-password")
|
|
||||||
public ResponseEntity<byte[]> compressPDF(@RequestParam("fileInput") MultipartFile fileInput,
|
|
||||||
@RequestParam(name = "password") String password) throws IOException {
|
|
||||||
PDDocument document = PDDocument.load(fileInput.getBytes(), password);
|
|
||||||
document.setAllSecurityToBeRemoved(true);
|
|
||||||
return PdfUtils.pdfDocToWebResponse(document, fileInput.getName() + "_password_removed.pdf");
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/add-password")
|
|
||||||
public ResponseEntity<byte[]> compressPDF(@RequestParam("fileInput") MultipartFile fileInput,
|
|
||||||
@RequestParam(defaultValue = "", name = "password") String password,
|
|
||||||
@RequestParam(defaultValue = "128", name = "keyLength") int keyLength,
|
|
||||||
@RequestParam(defaultValue = "false", name = "canAssembleDocument") boolean canAssembleDocument,
|
|
||||||
@RequestParam(defaultValue = "false", name = "canExtractContent") boolean canExtractContent,
|
|
||||||
@RequestParam(defaultValue = "false", name = "canExtractForAccessibility") boolean canExtractForAccessibility,
|
|
||||||
@RequestParam(defaultValue = "false", name = "canFillInForm") boolean canFillInForm,
|
|
||||||
@RequestParam(defaultValue = "false", name = "canModify") boolean canModify,
|
|
||||||
@RequestParam(defaultValue = "false", name = "canModifyAnnotations") boolean canModifyAnnotations,
|
|
||||||
@RequestParam(defaultValue = "false", name = "canPrint") boolean canPrint,
|
|
||||||
@RequestParam(defaultValue = "false", name = "canPrintFaithful") boolean canPrintFaithful)
|
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
PDDocument document = PDDocument.load(fileInput.getBytes());
|
|
||||||
AccessPermission ap = new AccessPermission();
|
|
||||||
|
|
||||||
ap.setCanAssembleDocument(!canAssembleDocument);
|
|
||||||
ap.setCanExtractContent(!canExtractContent);
|
|
||||||
ap.setCanExtractForAccessibility(!canExtractForAccessibility);
|
|
||||||
ap.setCanFillInForm(!canFillInForm);
|
|
||||||
ap.setCanModify(!canModify);
|
|
||||||
ap.setCanModifyAnnotations(!canModifyAnnotations);
|
|
||||||
ap.setCanPrint(!canPrint);
|
|
||||||
ap.setCanPrintFaithful(!canPrintFaithful);
|
|
||||||
StandardProtectionPolicy spp = new StandardProtectionPolicy(password, password, ap);
|
|
||||||
spp.setEncryptionKeyLength(keyLength);
|
|
||||||
|
|
||||||
spp.setPermissions(ap);
|
|
||||||
|
|
||||||
document.protect(spp);
|
|
||||||
|
|
||||||
return PdfUtils.pdfDocToWebResponse(document, fileInput.getName() + "_passworded.pdf");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package stirling.software.SPDF.controller.security;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
|
||||||
import org.apache.pdfbox.pdmodel.font.PDFont;
|
|
||||||
import org.apache.pdfbox.pdmodel.font.PDType1Font;
|
|
||||||
import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
|
|
||||||
import org.apache.pdfbox.util.Matrix;
|
|
||||||
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 WatermarkController {
|
|
||||||
|
|
||||||
@GetMapping("/add-watermark")
|
|
||||||
public String addWatermarkForm(Model model) {
|
|
||||||
model.addAttribute("currentPage", "add-watermark");
|
|
||||||
return "security/add-watermark";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/add-watermark")
|
|
||||||
public ResponseEntity<byte[]> addWatermark(@RequestParam("pdfFile") MultipartFile pdfFile,
|
|
||||||
@RequestParam("watermarkText") String watermarkText,
|
|
||||||
@RequestParam(defaultValue = "30", name = "fontSize") float fontSize,
|
|
||||||
@RequestParam(defaultValue = "0", name = "rotation") float rotation,
|
|
||||||
@RequestParam(defaultValue = "50", name = "widthSpacer") int widthSpacer,
|
|
||||||
@RequestParam(defaultValue = "50", name = "heightSpacer") int heightSpacer) throws IOException {
|
|
||||||
|
|
||||||
// Load the input PDF
|
|
||||||
PDDocument document = PDDocument.load(pdfFile.getInputStream());
|
|
||||||
|
|
||||||
// Create a page in the document
|
|
||||||
for (PDPage page : document.getPages()) {
|
|
||||||
// Get the page's content stream
|
|
||||||
PDPageContentStream contentStream = new PDPageContentStream(document, page,
|
|
||||||
PDPageContentStream.AppendMode.APPEND, true);
|
|
||||||
|
|
||||||
// Set font of watermark
|
|
||||||
PDFont font = PDType1Font.HELVETICA_BOLD;
|
|
||||||
contentStream.beginText();
|
|
||||||
contentStream.setFont(font, fontSize);
|
|
||||||
contentStream.setNonStrokingColor(Color.LIGHT_GRAY);
|
|
||||||
|
|
||||||
// Set size and location of watermark
|
|
||||||
float pageWidth = page.getMediaBox().getWidth();
|
|
||||||
float pageHeight = page.getMediaBox().getHeight();
|
|
||||||
float watermarkWidth = widthSpacer + font.getStringWidth(watermarkText) * fontSize / 1000;
|
|
||||||
float watermarkHeight = heightSpacer + fontSize;
|
|
||||||
int watermarkRows = (int) (pageHeight / watermarkHeight + 1);
|
|
||||||
int watermarkCols = (int) (pageWidth / watermarkWidth + 1);
|
|
||||||
|
|
||||||
// Add the watermark text
|
|
||||||
for (int i = 0; i < watermarkRows; i++) {
|
|
||||||
for (int j = 0; j < watermarkCols; j++) {
|
|
||||||
contentStream.setTextMatrix(Matrix.getRotateInstance((float) Math.toRadians(rotation),
|
|
||||||
j * watermarkWidth, i * watermarkHeight));
|
|
||||||
contentStream.showTextWithPositioning(new Object[] { watermarkText });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
contentStream.endText();
|
|
||||||
|
|
||||||
// Close the content stream
|
|
||||||
contentStream.close();
|
|
||||||
}
|
|
||||||
return PdfUtils.pdfDocToWebResponse(document, pdfFile.getName() + "_watermarked.pdf");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,168 +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;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
|
|
||||||
import com.spire.pdf.PdfDocument;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseEntity<byte[]> pdfDocToWebResponse(PdfDocument document, String docName) throws IOException {
|
|
||||||
|
|
||||||
// Open Byte Array and save document to it
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
document.saveToStream(baos);
|
|
||||||
// Close the document
|
|
||||||
document.close();
|
|
||||||
|
|
||||||
return PdfUtils.boasToWebResponse(baos, docName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseEntity<byte[]> pdfDocToWebResponse(PDDocument document, String docName) throws IOException {
|
|
||||||
|
|
||||||
// Open Byte Array and save document to it
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
document.save(baos);
|
|
||||||
// Close the document
|
|
||||||
document.close();
|
|
||||||
|
|
||||||
return PdfUtils.boasToWebResponse(baos, docName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseEntity<byte[]> boasToWebResponse(ByteArrayOutputStream baos, String docName)
|
|
||||||
throws IOException {
|
|
||||||
return PdfUtils.bytesToWebResponse(baos.toByteArray(), docName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseEntity<byte[]> bytesToWebResponse(byte[] bytes, String docName) throws IOException {
|
|
||||||
|
|
||||||
// Return the PDF as a response
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
||||||
headers.setContentLength(bytes.length);
|
|
||||||
headers.setContentDispositionFormData("attachment", docName);
|
|
||||||
return new ResponseEntity<>(bytes, headers, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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,14 +0,0 @@
|
|||||||
#page-container {
|
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content-wrap {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#footer {
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Add-Image')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/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 (Work in progress)</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="~{fragments/common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Compress')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/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="~{fragments/common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Image to PDF')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/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="@{img-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="~{fragments/common :: filelist}"></th:block>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='PDF to Image')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>PDF to Image</h2>
|
|
||||||
<form method="post" enctype="multipart/form-data"
|
|
||||||
th:action="@{pdf-to-img}">
|
|
||||||
<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="~{fragments/common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Page Remover')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>PDF Page remover</h2>
|
|
||||||
|
|
||||||
<form th:action="@{delete-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="pagesToDelete">Pages to delete (Enter a comma-separated
|
|
||||||
list of page numbers) :</label> <input type="text" class="form-control"
|
|
||||||
id="fileInput" name="pagesToDelete"
|
|
||||||
placeholder="(e.g. 1,2,6 or 1-10,15-30)" required>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary">Delete
|
|
||||||
Pages</button>
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{fragments/common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<div th:fragment="card" class="col-4 h-100">
|
|
||||||
<div class="dark-card card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title" th:text="${cardTitle}"></h5>
|
|
||||||
<p class="card-text" th:text="${cardText}"></p>
|
|
||||||
<a class="btn btn-primary" th:href="${cardLink}">Go</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,98 +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>
|
|
||||||
<title th:text="'S-PDF ' + ${title}"></title>
|
|
||||||
<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,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,87 +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="@{/}">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="@{pdf-organizer}"
|
|
||||||
th:classappend="${currentPage}=='pdf-organizer' ? 'active' : ''">Page
|
|
||||||
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 dropdown" th:classappend="${currentPage}=='pdf-to-img' OR ${currentPage}=='img-to-pdf' ? 'active' : ''">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
Convert
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{pdf-to-img}" th:classappend="${currentPage}=='pdf-to-img' ? 'active' : ''">PDF to Image</a>
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{img-to-pdf}" th:classappend="${currentPage}=='img-to-pdf' ? 'active' : ''">Image to PDF</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="nav-item dropdown" th:classappend="${currentPage}=='add-password' OR ${currentPage}=='remove-password' OR ${currentPage}=='change-permissions' OR ${currentPage}=='add-watermark' ? 'active' : ''">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
Security
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{add-password}" th:classappend="${currentPage}=='add-password' ? 'active' : ''">Add password (Encrypt)</a>
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{remove-password}" th:classappend="${currentPage}=='remove-password' ? 'active' : ''">Remove password (Decrypt)</a>
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{change-permissions}" th:classappend="${currentPage}=='change-permissions' ? 'active' : ''">Change permissions</a>
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{add-watermark}" th:classappend="${currentPage}=='add-watermark' ? 'active' : ''">Add Watermark</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="nav-item dropdown" th:classappend="${currentPage}=='delete-pages' OR ${currentPage}=='add-image' OR ${currentPage}=='compress-pdf' ? 'active' : ''">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
Others
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{add-image}" th:classappend="${currentPage}=='add-image' ? 'active' : ''">Add
|
|
||||||
image to PDF</a>
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{compress-pdf}" th:classappend="${currentPage}=='compress-pdf' ? 'active' : ''">Compress PDF</a>
|
|
||||||
<a class="dropdown-item" href="#" th:href="@{delete-pages}" th:classappend="${currentPage}=='delete-pages' ? 'active' : ''">Remove Pages</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{add-image}"
|
|
||||||
th:classappend="${currentPage}=='add-image' ? 'active' : ''"></a></li>
|
|
||||||
|
|
||||||
<li class="nav-item"><a class="nav-link" href="#"
|
|
||||||
th:href="@{compress-pdf}"
|
|
||||||
th:classappend="${currentPage}=='compress-pdf' ? 'active' : ''"></a></li>
|
|
||||||
|
|
||||||
<input type="checkbox" id="toggle-dark-mode" checked="true"
|
|
||||||
th:onclick="javascript:toggleDarkMode()">
|
|
||||||
<a class="nav-link" href="#" for="toggle-dark-mode">Dark Mode</a>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/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 th:replace="~{fragments/card :: card(cardTitle='Merge PDFs', cardText='Easily merge multiple PDFs into one.', cardLink='merge-pdfs')}"></div>
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Split PDFs', cardText='Split PDFs into multiple documents', cardLink='split-pdfs')}"></div>
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Rotate PDFs', cardText='Easily rotate your PDFs.', cardLink='rotate-pdf')}"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<div class="row h-100">
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Image to PDF', cardText='Convert a images (PNG, JPEG, GIF) to PDF.', cardLink='img-to-pdf')}"></div>
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='PDF to Image', cardText='Convert a PDF to a image. (PNG, JPEG, GIF)', cardLink='pdf-to-img')}"></div>
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='PDF Organizer', cardText='Remove/Rearrange pages in any order', cardLink='pdf-organizer')}"></div>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="row h-100">
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Add image onto PDF', cardText='Adds a image onto a set location on the PDF (Work in progress)', cardLink='add-image')}"></div>
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Add Watermark', cardText='Add a custom watermark to your PDF document.', cardLink='add-watermark')}"></div>
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Change Permissions', cardText='Change the permissions of your PDF document, such as print, copy, edit, etc.', cardLink='change-permissions')}"></div>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="row h-100">
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Remove Pages', cardText='Delete unwanted pages from your PDF document.', cardLink='remove-pages')}"></div>
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Add Password', cardText='Encrypt your PDF document with a password.', cardLink='add-password')}"></div>
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Remove Password', cardText='Remove password protection from your PDF document.', cardLink='remove-password')}"></div>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="row h-100">
|
|
||||||
<div th:replace="~{fragments/card :: card(cardTitle='Compress PDFs', cardText='Compress PDFs to reduce their file size.', cardLink='compress-pdf')}"></div>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Merge PDFs')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/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 required> <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>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Organizer')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/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="~{fragments/common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Rotate')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/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="~{fragments/common :: filelist}"></th:block>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Add Password')}"></th:block>
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>Add password (Encrypt)</h2>
|
|
||||||
|
|
||||||
<form action="add-password" method="post"
|
|
||||||
enctype="multipart/form-data">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Select PDF to encrypt</label>
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Password</label> <input type="password"
|
|
||||||
class="form-control" id="password" name="password" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Encryption Key Length</label> <select class="form-control"
|
|
||||||
id="keyLength" name="keyLength">
|
|
||||||
<option value="40">40</option>
|
|
||||||
<option value="128">128</option>
|
|
||||||
<option value="256">256</option>
|
|
||||||
</select> <small class="form-text text-muted">Higher values are
|
|
||||||
stronger, but lower values have better compatibility.</small>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Permissions to set</label>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canAssembleDocument" name="canAssembleDocument"> <label
|
|
||||||
class="form-check-label" for="canAssembleDocument">
|
|
||||||
Prevent assembly of document </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canExtractContent" name="canExtractContent"> <label
|
|
||||||
class="form-check-label" for="canExtractContent">
|
|
||||||
Prevent content extraction </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canExtractForAccessibility"
|
|
||||||
name="canExtractForAccessibility"> <label
|
|
||||||
class="form-check-label" for="canExtractForAccessibility">
|
|
||||||
Prevent extraction for accessibility </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canFillInForm" name="canFillInForm"> <label
|
|
||||||
class="form-check-label" for="canFillInForm"> Prevent
|
|
||||||
filling in form </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="canModify"
|
|
||||||
name="canModify"> <label class="form-check-label"
|
|
||||||
for="canModify"> Prevent modification </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canModifyAnnotations" name="canModifyAnnotations"> <label
|
|
||||||
class="form-check-label" for="canModifyAnnotations">
|
|
||||||
Prevent annotation modification </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="canPrint"
|
|
||||||
name="canPrint"> <label class="form-check-label"
|
|
||||||
for="canPrint"> Prevent printing </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canPrintFaithful" name="canPrintFaithful"> <label
|
|
||||||
class="form-check-label" for="canPrintFaithful"> Prevent
|
|
||||||
printing different formats </label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<div class="form-group text-center">
|
|
||||||
<button type="submit" class="btn btn-primary">Encrypt</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Add Watermark')}"></th:block>
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>Add Watermark</h2>
|
|
||||||
|
|
||||||
<form method="post" enctype="multipart/form-data" action="add-watermark">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Select PDF to add watermark to:</label>
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="watermarkText">Watermark Text:</label>
|
|
||||||
<input type="text" id="watermarkText" name="watermarkText" class="form-control" placeholder="Stirling-PDF" required/>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="fontSize">Font Size:</label>
|
|
||||||
<input type="text" id="fontSize" name="fontSize" class="form-control" value="30"/>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="rotation">Rotation (0-360):</label>
|
|
||||||
<input type="text" id="rotation" name="rotation" class="form-control" value="45"/>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="widthSpacer">widthSpacer (Space between each watermark horizontally):</label>
|
|
||||||
<input type="text" id="widthSpacer" name="widthSpacer" class="form-control" value="50"/>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="heightSpacer">heightSpacer (Space between each watermark vertically):</label>
|
|
||||||
<input type="text" id="heightSpacer" name="heightSpacer" class="form-control" value="50"/>
|
|
||||||
</div>
|
|
||||||
<div class="form-group text-center">
|
|
||||||
<input type="submit" value="Add Watermark" class="btn btn-primary"/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Change Permissions')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>Change permissions</h2>
|
|
||||||
<p>Warning to have these permissions be
|
|
||||||
unchangeable it is recommended to set them with a password via the
|
|
||||||
add-password page</p>
|
|
||||||
<form action="add-password" method="post"
|
|
||||||
enctype="multipart/form-data">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Select PDF to change permissions</label>
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput"> <label class="custom-file-label">Choose
|
|
||||||
PDF</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Permissions to set</label>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canAssembleDocument" name="canAssembleDocument"> <label
|
|
||||||
class="form-check-label" for="canAssembleDocument">
|
|
||||||
Prevent assembly of document </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canExtractContent" name="canExtractContent"> <label
|
|
||||||
class="form-check-label" for="canExtractContent">
|
|
||||||
Prevent content extraction </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canExtractForAccessibility"
|
|
||||||
name="canExtractForAccessibility"> <label
|
|
||||||
class="form-check-label" for="canExtractForAccessibility">
|
|
||||||
Prevent extraction for accessibility </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canFillInForm" name="canFillInForm"> <label
|
|
||||||
class="form-check-label" for="canFillInForm"> Prevent
|
|
||||||
filling in form </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="canModify"
|
|
||||||
name="canModify"> <label class="form-check-label"
|
|
||||||
for="canModify"> Prevent modification </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canModifyAnnotations" name="canModifyAnnotations"> <label
|
|
||||||
class="form-check-label" for="canModifyAnnotations">
|
|
||||||
Prevent annotation modification </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="canPrint"
|
|
||||||
name="canPrint"> <label class="form-check-label"
|
|
||||||
for="canPrint"> Prevent printing </label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox"
|
|
||||||
id="canPrintFaithful" name="canPrintFaithful"> <label
|
|
||||||
class="form-check-label" for="canPrintFaithful"> Prevent
|
|
||||||
printing different formats </label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<div class="form-group text-center">
|
|
||||||
<button type="submit" class="btn btn-primary">Change</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Remove password')}"></th:block>
|
|
||||||
|
|
||||||
<body> <div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/navbar.html :: navbar}"></div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<h2>Remove password (Decrypt)</h2>
|
|
||||||
|
|
||||||
<form action="add-password" method="post"
|
|
||||||
enctype="multipart/form-data">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Select PDF to Decrypt</label>
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input" id="fileInput"
|
|
||||||
name="fileInput" required> <label
|
|
||||||
class="custom-file-label">Choose PDF</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Password</label> <input type="password"
|
|
||||||
class="form-control" id="password" name="password" required>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
||||||
|
|
||||||
<th:block th:insert="~{fragments/common :: head(title='Split')}"></th:block>
|
|
||||||
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="page-container">
|
|
||||||
<div id="content-wrap">
|
|
||||||
<div th:insert="~{fragments/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" required>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
|
||||||
</form>
|
|
||||||
<th:block th:insert="~{fragments/common :: filelist}"></th:block>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div th:insert="~{fragments/footer.html :: footer}"></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user