Pedro Fonseca 1c655f0ba0
Upload File Size Limit (#3334)
# Description of Changes

The change this PR aims to introduce is a setting for enabling an upload
file size limit. The author of the issue mentioned in this PR wanted
this feature as they themselves enforced a limit of 50MB file sizes on
their NGINX configuration.
This was implemented by adding an entry to the
[settings.yml.template](e52fc0e478/src/main/resources/settings.yml.template)
file. This entry has two sub-configurations in which you declare if the
application should enable upload file size limiting and then you declare
the limit itself.

For this to be available in code, a new field in the
[System](e52fc0e478/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java (L280))
class was added, one named `uploadLimit`.

After that, inside the [AppConfig](url) class, a new thymeleaf bean was
created, one called `uploadLimit`. This bean takes the values available
in the `System` class and creates a `long` value representing the limit
value. This value is interpreted as non-existent if it is `0`, otherwise
it is the value in `bytes` of the upload limit.

In order to make this value available in the
[common.html](e52fc0e478/src/main/resources/templates/fragments/common.html)
file, where the submitFile form is imported from, a new controller
[GlobalUploadLimitWebController](e52fc0e478/src/main/java/stirling/software/SPDF/controller/web/GlobalUploadLimitWebController.java)
was created. This controller has the tag `ControllerAdvice` so that
every controller has the `ModelAttributes` defined within it. I am not
sure if this was a good approach but upon first investigations, I
couldn't find another method to make these attributes available in every
Controller, or template. If there is already a place like this in the
code with this specific purpose, please let me know so I can fix it.

After making these attributes available, I updated the code in
`common.html`to now display the upload limit if it is defined. This was
done with localization in mind.

Lastly, the
[downloader.js](e52fc0e478/src/main/resources/static/js/downloader.js)
and
[fileInput.js](e52fc0e478/src/main/resources/static/js/fileInput.js)
files to include logic to enforce the upload limit if it is defined.

The UI updates, when the upload limit is defined, are as so:
<img width="708" alt="image"
src="https://github.com/user-attachments/assets/4852fa10-2ec3-45cb-83e6-41a102f256d4"
/>

When the limit is disabled, the page looks exactly as it did before any
implementation:
<img width="707" alt="image"
src="https://github.com/user-attachments/assets/21e5e810-ffdc-4a99-a16d-491aea103709"
/>\\

Thank you.

Closes #2903

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [x] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [x] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [x] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### UI Changes (if applicable)

- [x] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [x] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.

---------

Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
2025-04-14 09:36:33 +00:00
2025-02-04 11:24:35 +00:00
2025-04-14 09:36:33 +00:00
2024-12-30 15:49:28 +00:00
2024-12-17 23:23:16 +01:00
2025-03-11 14:12:00 +00:00
2025-01-12 13:46:40 +00:00
2024-09-02 11:01:17 +01:00
2025-01-14 15:32:15 +00:00

Stirling-PDF

Docker Pulls Discord OpenSSF Scorecard GitHub Repo stars

Stirling PDF - Open source locally hosted web PDF editor | Product Hunt Deploy to DO

Stirling-PDF is a robust, locally hosted web-based PDF manipulation tool using Docker. It enables you to carry out various operations on PDF files, including splitting, merging, converting, reorganizing, adding images, rotating, compressing, and more. This locally hosted web application has evolved to encompass a comprehensive set of features, addressing all your PDF requirements.

All files and PDFs exist either exclusively on the client side, reside in server memory only during task execution, or temporarily reside in a file solely for the execution of the task. Any file downloaded by the user will have been deleted from the server by that point.

Homepage: https://stirlingpdf.com

All documentation available at https://docs.stirlingpdf.com/

stirling-home

Features

  • 50+ PDF Operations
  • Parallel file processing and downloads
  • Dark mode support
  • Custom download options
  • Custom 'Pipelines' to run multiple features in a automated queue
  • API for integration with external scripts
  • Optional Login and Authentication support (see here for documentation)
  • Database Backup and Import (see here for documentation)
  • Enterprise features like SSO see here

PDF Features

Page Operations

  • View and modify PDFs - View multi-page PDFs with custom viewing, sorting, and searching. Plus, on-page edit features like annotating, drawing, and adding text and images. (Using PDF.js with Joxit and Liberation fonts)
  • Full interactive GUI for merging/splitting/rotating/moving PDFs and their pages
  • Merge multiple PDFs into a single resultant file
  • Split PDFs into multiple files at specified page numbers or extract all pages as individual files
  • Reorganize PDF pages into different orders
  • Rotate PDFs in 90-degree increments
  • Remove pages
  • Multi-page layout (format PDFs into a multi-paged page)
  • Scale page contents size by set percentage
  • Adjust contrast
  • Crop PDF
  • Auto-split PDF (with physically scanned page dividers)
  • Extract page(s)
  • Convert PDF to a single page
  • Overlay PDFs on top of each other
  • PDF to a single page
  • Split PDF by sections

Conversion Operations

  • Convert PDFs to and from images
  • Convert any common file to PDF (using LibreOffice)
  • Convert PDF to Word/PowerPoint/others (using LibreOffice)
  • Convert HTML to PDF
  • Convert PDF to XML
  • Convert PDF to CSV
  • URL to PDF
  • Markdown to PDF

Security & Permissions

  • Add and remove passwords
  • Change/set PDF permissions
  • Add watermark(s)
  • Certify/sign PDFs
  • Sanitize PDFs
  • Auto-redact text

Other Operations

  • Add/generate/write signatures
  • Split by Size or PDF
  • Repair PDFs
  • Detect and remove blank pages
  • Compare two PDFs and show differences in text
  • Add images to PDFs
  • Compress PDFs to decrease their filesize (using qpdf)
  • Extract images from PDF
  • Remove images from PDF
  • Extract images from scans
  • Remove annotations
  • Add page numbers
  • Auto-rename files by detecting PDF header text
  • OCR on PDF (using Tesseract OCR)
  • PDF/A conversion (using LibreOffice)
  • Edit metadata
  • Flatten PDFs
  • Get all information on a PDF to view or export as JSON
  • Show/detect embedded JavaScript

📖 Get Started

Visit our comprehensive documentation at docs.stirlingpdf.com for:

  • Installation guides for all platforms
  • Configuration options
  • Feature documentation
  • API reference
  • Security setup
  • Enterprise features

Supported Languages

Stirling-PDF currently supports 39 languages!

Language Progress
Arabic (العربية) (ar_AR) 84%
Azerbaijani (Azərbaycan Dili) (az_AZ) 83%
Basque (Euskara) (eu_ES) 48%
Bulgarian (Български) (bg_BG) 93%
Catalan (Català) (ca_CA) 90%
Croatian (Hrvatski) (hr_HR) 81%
Czech (Česky) (cs_CZ) 92%
Danish (Dansk) (da_DK) 80%
Dutch (Nederlands) (nl_NL) 80%
English (English) (en_GB) 100%
English (US) (en_US) 100%
French (Français) (fr_FR) 92%
German (Deutsch) (de_DE) 95%
Greek (Ελληνικά) (el_GR) 92%
Hindi (हिंदी) (hi_IN) 92%
Hungarian (Magyar) (hu_HU) 89%
Indonesian (Bahasa Indonesia) (id_ID) 81%
Irish (Gaeilge) (ga_IE) 92%
Italian (Italiano) (it_IT) 98%
Japanese (日本語) (ja_JP) 89%
Korean (한국어) (ko_KR) 93%
Norwegian (Norsk) (no_NB) 87%
Persian (فارسی) (fa_IR) 88%
Polish (Polski) (pl_PL) 96%
Portuguese (Português) (pt_PT) 91%
Portuguese Brazilian (Português) (pt_BR) 94%
Romanian (Română) (ro_RO) 76%
Russian (Русский) (ru_RU) 94%
Serbian Latin alphabet (Srpski) (sr_LATN_RS) 60%
Simplified Chinese (简体中文) (zh_CN) 93%
Slovakian (Slovensky) (sk_SK) 69%
Slovenian (Slovenščina) (sl_SI) 95%
Spanish (Español) (es_ES) 94%
Swedish (Svenska) (sv_SE) 88%
Thai (ไทย) (th_TH) 80%
Tibetan (བོད་ཡིག་) (zh_BO) 89%
Traditional Chinese (繁體中文) (zh_TW) 99%
Turkish (Türkçe) (tr_TR) 77%
Ukrainian (Українська) (uk_UA) 97%
Vietnamese (Tiếng Việt) (vi_VN) 74%

Stirling PDF Enterprise

Stirling PDF offers an Enterprise edition of its software. This is the same great software but with added features, support and comforts. Check out our Enterprise docs

🤝 Looking to contribute?

Join our community:

Description
#1 Locally hosted web application that allows you to perform various operations on PDF files
Readme MIT 99 MiB
Languages
Java 52.8%
HTML 20.8%
JavaScript 16.8%
CSS 4%
Rich Text Format 1.7%
Other 3.9%