Giter Club home page Giter Club logo

nodejs-convert-file-server's Introduction

nodejs-convert-file-server

Screenshot

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.

Installation

Clone the repo and run:

npm start

The server will be listening on port 9000. http://localhost:9000

Test

To test the proper functionality of the file server, you can run:

npm test

API Calls

List file directory

The endpoint returns all files present in the files directory in JSON format.

HTTP Request

GET http://localhost:9000/files

Get file

The endpoint returns the requested file.

HTTP Request

GET http://localhost:9000/files/:filename

Get thumbnail

The endpoint returns the thumbnail for the specified file. Uses PDFTron Node.js API.

HTTP Request

GET http://localhost:9000/thumbnail/:filename

Convert to PDF

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.

HTTP Request

GET http://localhost:9000/convert/:filename

Convert to PDF from HTML

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.

HTTP Request

GET http://localhost:9000/convertHTML/:filename-:pathToHTML

Example

Converts an HTML form to a PDF http://localhost:9000/convertHTML/myhtml-index.html

Optimize PDF

The endpoint converts the PDF to an optimized PDF to be used with PDFTron WebViewer. Uses PDFTron Node.js API.

HTTP Request

GET http://localhost:9000/optimize/:filename

Extract Text from a PDF

Returns text from a PDF at a specified page number.

HTTP Request

GET http://localhost:9000/textextract/:filename-:pagenumber

Generate PDF

Creates a blank PDF with a single page.

HTTP Request

GET http://localhost:9000/generate/:filename

Replace Content in PDF

Replaces a placeholder string in a PDF.

HTTP Request

GET http://localhost:9000/replaceContent/:name

Example

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

Watermark PDF

Watermarks a PDF document with the provided watermark.

HTTP Request

GET http://localhost:9000/watermark/:filename-:watermark

Example

Places a watermark on every page in red. http://localhost:9000/watermark/webviewer.pdf-awesome

nodejs-convert-file-server's People

Contributors

andreysaf avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nodejs-convert-file-server's Issues

The problem of running http://localhost:9000/convert/document.docx

When I run http://localhost:9000/convert/document.docx, it occurs bugs below

(node:4008) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer. Received an instance of Error
at ServerResponse.end (_http_outgoing.js:745:13)
at D:\demo\nodejs-convert-file-server-master\app.js:272:11
(node:4008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4008) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Could you help me to fix this bug, thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.