1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-23 15:21:25 +01:00

Cleanup, Updated Docs

This commit is contained in:
Felix Kaspar 2024-10-04 19:34:26 +02:00
parent 74079512d0
commit b7c70c83b4
16 changed files with 113 additions and 151 deletions

View File

@ -20,16 +20,16 @@ This file should introduce you with the concepts and tools used in this project.
## Folder structure
- (abandoned) client-ionic- An old test of
- client-tauri - The frontend
- (abandoned) client-vanilla - The initial test to see if it is possible to run Operators in the browser environment of the user in addition to having a backend. Will be removed once development on the fronend/client-tauri has started.
- server-node - Functions and Classes that are shared between frontend and backend e.g. Operators
- client-tauri - The frontend - Can be built to web and to a desktop app (with extra functions) using tauri.
- server-node - The backend - Provides extra functionality for the web client.
- shared-operatons - Components (e.g. Operators) that are shared between frontend and backend.
## Adding a PDF Operation
StirlingPDF aims to support as many types of operations as possible, including some that cannot be executed in the client. Because of this, we have decided to move some of the shared functionality into it's own node module so that it can be shared by both client and server.
## Adding a PDF Operator
An Operator is either shared by the server and the client or it might have different implementations based on if its executed by the client, desktop-backend or web-backend. The current structure allows us to define where the Operator can be run.
## PDF Library Docs
- [pdf-lib](https://pdf-lib.js.org) - js
- [pdfcpu](https://pdfcpu.io) - go-wasm
- [opencv-wasm](https://www.npmjs.com/package/opencv-wasm) - ?-wasm
- [mozilla's pdfjs-dist/pdf.js](https://www.npmjs.com/package/pdfjs-dist) - js
- [pdfcpu](https://pdfcpu.io) - go-wasm
- [opencv-wasm](https://www.npmjs.com/package/opencv-wasm) - c++-wasm

189
README.md
View File

@ -2,6 +2,9 @@
This is the development repository for the new StirlingPDF backend. With the power of JS, WASM & GO this will provide almost all functionality SPDF can do currently directly on the client. For automation purposes this will still provide an API to automate your workflows.
![alt text](https://media.discordapp.net/attachments/1174462312904663120/1272615545719619674/image.png?ex=6700d5d6&is=66ff8456&hm=3e36a0c2214f2de07ba4ff4833f86aed5f2f3447f61fe80f5396654b202139b8&=&format=webp&quality=lossless)
This image is here to reflect current progress and will be updated accordingly.
## Try the new API!
[![Run in Postman](https://run.pstmn.io/button.svg)](https://documenter.getpostman.com/view/30633786/2s9YRB1Wto)
@ -77,146 +80,80 @@ If you are interested in learning about this, take a look at the Example workflo
### Rewrite Roadmap
* [x] Client side PDF-Manipulation
* [x] Workflows
* [X] Client side PDF-Manipulation
* [X] Workflows
* [X] passportjs backend (auth)
* [ ] Auth in frontend
* [ ] Feature equivalent with S-PDF v1
* [ ] Stateful UI
* [ ] Node based editing of Workflows
* [ ] Propper auth using passportjs
### Functions
Current functions of spdf and their progress in this repo.
#### Page Operations
| Status | Feature | Description |
| ------ | ------------------------ | ----------- |
| 🚧A | Merge | |
| 🚧A | Split | |
| 🚧A | Organize | |
| 🚧S | Rotate | |
| 🚧A | Remove Pages | |
| 🚧A | Multi-Page Layout | |
| ❌ | Adjust page size/scale | |
| 🚧A | Auto Split Pages | |
| ❌ | Adjust Colours/Contrast | |
| ❌ | Crop | |
| 🚧A | Extract Pages | |
| ❌ | PDF to Single large Page | |
#### PDF Functions
| Status | Feature | Description |
| ------ | -------------------------------------------------- | ----------- |
| ✔️ | arrange | |
| ✔️ | extract | |
| ✔️ | impose | |
| ✔️ | merge | |
| ✔️ | remove blank | |
| ✔️ | remove | |
| ✔️ | rotate pages | |
| ✔️ | scale content | |
| ✔️ | scale pages | |
| ✔️ | split by preset | |
| ✔️ | split by index | |
| ✔️ | update metadata | |
| ✔️ | pdf to single large page | |
| 🚧 | remove annotations | |
| 🚧 | flatten | |
| 🚧 | overlay pdfs | |
| 🚧 | compress | |
| 🚧 | change permissions | |
| 🚧 | pdf to pdf/a | |
| 🚧 | add page numbers | |
| 🚧 | add image | |
| 🚧 | add watermark | |
| 🚧 | auto rename | |
| 🚧 | add stamp | |
| ❌ | repair | |
| ❌ | sign with cert | |
| ❌ | ocr | |
| ❌ | auto split by size/count (+split by preset) | |
| ❌ | split pdfs by sections/chapters (+split by preset) | |
| ❌ | adjust colors/contrast | |
| ❌ | adjust colors/contrast | |
| ❌ | sanitize | |
| ❌ | sign | |
| ❌ | basic text editing | |
| ❌ | auto redact | |
#### Generic Filetype (Filetypes are not supported by workflows yet. Coming Soon™)
#### Convert
| Status | Feature | Description |
| ------ | ------------------- | ----------- |
| ❌ | Image to PDF | |
| 🚧S | Convert file to PDF | |
| ❌ | URL to PDF | |
| ❌ | HTML to PDF | |
| ❌ | Markdown to PDF | |
| ❌ | PDF to Image | |
| ❌ | PDF to Word | |
| ❌ | PDF to Presentation | |
| ❌ | PDF to Text/RTF | |
| ❌ | PDF to HTML | |
| ❌ | PDF to PDF/A | |
| 🚧 | image to pdf | |
| 🚧 | pdf to image | |
| 🚧 | extract images | |
| 🚧 | show javascript | |
| ❌ | convert file to pdf | |
| ❌ | pdf to word | |
| ❌ | pdf to presentation | |
| ❌ | pdf to rtf | |
| ❌ | pdf to html | |
| ❌ | pdf to xml | |
| ❌ | url/website to pdf | |
| ❌ | markdown to pdf | |
| ❌ | pdf to csv | |
| ❌ | get all info | |
| ❌ | compare | |
#### Security
| Status | Feature | Description |
| ------ | --------------------- | ----------- |
| ❌ | Add Password | |
| ❌ | Remove Password | |
| ❌ | Change Permissions | |
| ❌ | Add Watermark | |
| ❌ | Sign with Certificate | |
| ❌ | Sanitize | |
| ❌ | Auto Redact | |
#### Miscellaneous
| Status | Feature | Description |
| ------ | --------------------------- | ----------- |
| ❌ | OCR | |
| ❌ | Add image | |
| ❌ | Compress | |
| ❌ | Extract Images | |
| 🚧S | Change Metadata | |
| 🚧A | Detect/Split Scanned photos | |
| ❌ | Sign | |
| ❌ | Flatten | |
| ❌ | Repair | |
| 🚧A | Remove Blank Pages | |
| ❌ | Compare/Diff | |
| ❌ | Add Page Numbers | |
| ❌ | Auto Rename | |
| ❌ | Get info | |
| ❌ | Show JS | |
✔️: Done, 🚧: Started Developement, ❌: Planned Feature
A: Available in the internal API, S: Available on the node server, C: Available in the client
✔️: Done, 🚧: Possible with current Libraries, ❌: Planned Feature
## Contribute
For initial instructions look at [CONTRIBUTE.md](./CONTRIBUTE.md)
<!--
///// CONVERT 2 pdf
file2pdf
url2pdf
html2pdf
md2pdf
image2pdf
///// CONVERT from pdf
pdf2image
flatten
pdf2pdf/a
pdf2word
pdf2presentation
pdf2rtf
pdf2html
pdf2xml
///// SINGLE
merge
rotate
crop
pageNumbers
colours/contrast
addPassword
removePassword
compress
changeMetadata
change Permissions
OCR
sanitise
repair
compare
extract images
signWith certificate
impose
adjust page size/scale
auto rename
getAllInfo
showJS
redact
pdf2singleLargePage
///// SPLITTING
split
auto split
detect/split scanned
///// REARRANGE
- organise pages (remove/re-arrange)
- removePages
- removeBlank
- extractPages
///// ADD OBJECTS
add image
add watermark
sign
*/
-->

View File

@ -13,6 +13,9 @@ import i18next from "i18next";
import resourcesToBackend from "i18next-resources-to-backend";
import { listOperatorNames } from "@stirling-pdf/shared-operations/src/workflow/operatorAccessor";
import AuthenticatedRoute from "./components/AuthenticatedRoute";
import Login from "./pages/Auth/Login";
import Logout from "./pages/Auth/Logout";
import Register from "./pages/Auth/Register";
i18next.use(LanguageDetector).use(initReactI18next).use(resourcesToBackend((language: string, namespace: string) => import(`@stirling-pdf/shared-operations/public/locales/${namespace}/${language}.json`).catch((e) => console.warn("some component tried to render with an unsupported language, falling back to en", e))))
.init({
@ -35,9 +38,9 @@ export default function App() {
<Routes>
<Route path="/auth" element={<Layout />}>
<Route index element={<Navigate to="/auth/login" />}/>
<Route path="login" element={"login test string"}></Route>
<Route path="logout" element={"logout test string"}></Route>
<Route path="register" element={"register test string"}></Route>
<Route path="login" element={<Login />}></Route>
<Route path="logout" element={<Logout />}></Route>
<Route path="register" element={<Register />}></Route>
<Route path="*" element={<NoMatch />} />
</Route>

View File

@ -2,3 +2,12 @@
// TODO: Check if user login is enabled on this server
import styles from './Auth.module.css';
function Login() {
return (
"Login Test Page"
);
}
export default Login;

View File

@ -1,2 +1,13 @@
// TODO: Delete user info in localstorage. Send request to logout endport session cookie will be removed automatically.
// TODO: Delete user info in localstorage. Send request to logout endpoint -> session cookie will be removed automatically.
// TODO: Check if user login is enabled on this server
import styles from './Auth.module.css';
function Logout() {
return (
"Logout Test Page"
);
}
export default Logout;

View File

@ -1,2 +1,13 @@
// TODO: Register user and login in the same request.
// TODO: Check if user registration & login is enabled on this server
import styles from './Auth.module.css';
function Register() {
return (
"Register Test Page"
);
}
export default Register;

View File

@ -1,4 +1,3 @@
import { PdfFile } from "../../wrappers/PdfFile";
import { PDFPageProxy } from "pdfjs-dist/types/src/display/api";
import { Image, ImageKind } from "image-js";

View File

@ -1,4 +1,3 @@
import jsQR from "jsqr";
import { PdfFile } from "../../wrappers/PdfFile";

View File

@ -1,4 +1,3 @@
import { PDFPageProxy } from "pdfjs-dist/types/src/display/api";
import * as PDFJS from "pdfjs-dist";

View File

@ -1,4 +1,3 @@
import { PdfFile, RepresentationType } from "../../wrappers/PdfFile";
import { PDFDocument } from "pdf-lib";

View File

@ -1,4 +1,3 @@
/**
* @param pages A list of page indexes, or the number of total pages in the document (which will be converted into a list of page indexes).
* @returns A reversed list of page indexes.

View File

@ -1,4 +1,3 @@
/**
* @param selection An array of page indexes already selected.
* @param pageCount The number of pages of the pdfDocument.

View File

@ -1,4 +1,3 @@
import { PdfFile } from "../../wrappers/PdfFile";
export async function sortPdfArray(

View File

@ -1,4 +1,3 @@
import { PdfFile } from "../../wrappers/PdfFile";
import { getPages } from "./getPagesByIndex";

View File

@ -3,7 +3,6 @@ import { Action } from "../../declarations/Action";
import Joi from "@stirling-tools/joi";
import { MaterialSymbolProps } from "react-material-symbols";
export interface ValidationResult {
valid: boolean,
reason?: string