This is the backend of PDFLite, which primarily offers three main features.
-
Compress PDF
- This feature uses
ghostscript
. - There are quality such as
screen
,ebook
,printer
,prepress
.
- This feature uses
-
Convert PDF to DOC
-
Compress img
-
Accepts any image type
-
There are quality range from 0 to 100.
- Best quality is between 20 to 80
-
- python3
- ghostscript
- AWS account with S3 bucket
$ mkdir myproject
$ cd myproject
$ python3 -m venv .venv
- To activate virtual environment
$ . .venv/bin/activate
- install dependencies
$ pip install -r requirement.txt
# in .env file
AWS_BUCKET_NAME=your_bucket_name
AWS_ACCESS_KEY=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AWS_DOMAIN=http://your_bucket_name.s3.amazonaws.com/
- To run flask server
$ flask --debug run
Bucket policy should look like this
{
"Version": "2012-10-17",
"Id": "IDxyz",
"Statement": [
{
"Sid": "Stmt731289371238",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<bucketname>/<key>"
}
]
}
- You can get policy examples from here
- Or you can generate policy from here
- NOTE: untick block public access.
- Files uploaded to a S3 bucket can be accessed via a public URL that usually looks like this:
https://nextagram-backend.s3.amazonaws.com/nextagram.jpg
https://<bucket_name>.s3.amazonaws.com/<filename>.<extension>