**
Providing tooling to work with PDF documents, usually in the form of an API.
- HTTP Protocols
- Integration Test
- Echo Framework
- show PDF description detail
- split PDF
- trim PDF
- remove PDF
- merge PDF (combine multiple PDF)
- convert JPG to PDF
- compress PDF
- reorder PDF pages
- lock PDF
- to run the API use
go run cmd/api/*.goormake api - to test run
go test -v ./...ormake test - to see test coverage, run
test makecandgo tool cover -html=coverage.out
- Get PDF file info
This example request shows information about the pdf file
http://localhost:1323/api/v1/pdf/info?path=/storage/testPdf&name=camry_ebrochure.pdf
- Split PDF
This example request generates single or multiples splitted pdf files based on selected_pages field input
curl -X POST http://localhost:1323/api/v1/pdf/split \
-H 'Content-Type: application/json' \
-d '{
"name": "yle-flyers-sample.pdf",
"path": "/storage/testPdf",
"selected_pages": ["3-29","1-2","32-36"]
}'
- Trim PDF
This example request generates a single pdf file that contains all of the targeted files.
curl -X POST http://localhost:1323/api/v1/pdf/trim \
-H 'Content-Type: application/json' \
-d '{
"inname": "yle-flyers-sample.pdf",
"inpath": "/storage/testPdf",
"outname": "yle-flyers-sample_trimmed.pdf",
"outpath": "/storage/testPdf",
"target_pages": ["1-3","8-9"]
}'
- Remove PDF
This example request generates a new copy of the pdf with the removed pages listed on 'target_pages' field
curl -X POST http://localhost:1323/api/v1/pdf/remove \
-H 'Content-Type: application/json' \
-d '{
"inname": "yle-flyers-sample.pdf",
"inpath": "/storage/testPdf",
"outname": "yle-flyers-sample_removed.pdf",
"outpath": "/storage/testPdf",
"target_pages": ["1-3","5","8-9"]
}'
- Merge PDFs
This example request merges two or more pdf files
curl -X POST http://localhost:1323/api/v1/pdf/merge \
-H 'Content-Type: application/json' \
-d '{
"infiles": [
{
"name": "camry_ebrochure.pdf",
"path": "/storage/testPdf"
},
{
"name": "mirai_ebrochure.pdf",
"path": "/storage/testPdf"
}
],
"outfile": "camry_mirai_ebrochure.pdf"
}'
- Convert JPG to PDF
This example request creates a single pdf file from single or multiple image(s)
curl -X POST http://localhost:1323/api/v1/pdf/jpg-to-pdf \
-H 'Content-Type: application/json' \
-d '{
"infiles": [
{
"name": "dhiva-krishna-YApS6TjKJ9c-unsplash.jpg",
"path": "/storage/testImage"
},
{
"name": "dima-panyukov-DwxlhTvC16Q-unsplash.jpg",
"path": "/storage/testImage"
},
{
"name": "kenny-eliason-FcyipqujfGg-unsplash.jpg",
"path": "/storage/testImage"
}
],
"outfile": "jpg-to-pdf-output.pdf",
"outpath": "/storage/testImage",
"configs": {
"page_size": "A4",
"scale": 0.95
}
}'
- Compress PDF
This example request generates a new compressed pdf file from the original pdf
curl -X POST http://localhost:1323/api/v1/pdf/compress \
-H 'Content-Type: application/json' \
-d '{
"infile": "camry_ebrochure.pdf",
"inpath": "/storage/testPdf",
"outfile": "camry_ebrochure_compressed.pdf",
"outpath": "/storage/testPdf"
}'
- Reorder PDF pages*
This request example generates new pdf file containing pages that have been sorted based on new_page_order field input.
curl -X POST http://localhost:1323/api/v1/pdf/reorder \
-H 'Content-Type: application/json' \
-d '{
"inname": "yle-flyers-sample.pdf",
"inpath": "/storage/testPdf",
"outname": "yle-flyers-sample_reordered.pdf",
"outpath": "/storage/testPdf",
"new_page_order": ["3-31","1-2","32-36"]
}'
issue: pdfcpu/pdfcpu#687
- It wraps the absolutely amazing pdfcpu api library
- Heavily inspired by ilovepdf, smallpdf, pdf2go, pdf.io, etc.
- PDF Sample 1 by Toyota
- PDF Sample 2 by Cambridge English
- Car Photo 1 by Dhiva Krishna on Unsplash
- Car Photo 2 by Dima Panyukov on Unsplash
- Car Photo 3 Photo by Kenny Eliason on Unsplash