Convert from MS Office, images to PDF, get thumbnails for file previews, optimize files for quick rendering.
Built with:
- Node.js
- Express.js
- PDFTron Node.js SDK
I put together a get started blog to walk through this project.
And you can follow this step-by-step video to recreate it yourself.
Clone the repo and run:
The server will be listening on port 9000. http://localhost:9000
To test the proper functionality of the file server, you can run:
The endpoint returns all files present in the files directory in JSON format.
GET http://localhost:9000/files
The endpoint returns the requested file.
GET http://localhost:9000/files/:filename
The endpoint returns the thumbnail for the specified file. Uses PDFTron Node.js API.
GET http://localhost:9000/thumbnail/:filename
The endpoint converts the file to a PDF. Conversion is possible for the following file formats: DOC, DOCX, PPTX, PPT, XLSX, PNG, JPEG, JPG, TIFF, TXT. Uses PDFTron Node.js API.
GET http://localhost:9000/convert/:filename
The endpoint converts the HTML to a PDF. There are several settings available to get the best results. Uses PDFTron Node.js API for HTML2PDF.
GET http://localhost:9000/convertHTML/:filename-:pathToHTML
Converts an HTML form to a PDF
http://localhost:9000/convertHTML/myhtml-index.html
The endpoint converts the PDF to an optimized PDF to be used with PDFTron WebViewer. Uses PDFTron Node.js API.
GET http://localhost:9000/optimize/:filename
Returns text from a PDF at a specified page number.
GET http://localhost:9000/textextract/:filename-:pagenumber
Creates a blank PDF with a single page.
GET http://localhost:9000/generate/:filename
Replaces a placeholder string in a PDF.
GET http://localhost:9000/replaceContent/:name
Replaces placeholder strings in the template PDF letter with provided name and returns a ready to be sent file. The _
replaced with spaces.
http://localhost:9000/replaceContent/John_Smith
Watermarks a PDF document with the provided watermark.
GET http://localhost:9000/watermark/:filename-:watermark
Places a watermark on every page in red.
http://localhost:9000/watermark/webviewer.pdf-awesome