Skip to content

kokizzu/handwritten.js

 
 

Repository files navigation

Welcome to handwritten.js πŸ‘‹

demo
Warning: ugly website ahead! HTML and CSS went AWOL :P. This is a temporary website made for desperate times while we wait on a proper demo-site, see #8.

Version License: MIT

Convert typed text to realistic handwriting!

In your code:

To use in browser, include <script src="https://raw.githubusercontent.com/alias-rahil/handwritten.js/master/docs/handwritten.js"></script> in one of your html files to get the latest version of handwritten.js. This will expose a global variable called handwritten which you can start using right away. Check the contents of docs/ folder for a simple implementation. For other versions, install the required version with npm and use browserify to compile it. Optionally, use babel-minify to compress the bundled javascript file.

Installation

npm install --save handwritten.js

Usage

const handwritten = require('handwritten.js')
const fs = require('fs')
const rawtext = "Hello, world!"
handwritten(rawtext).then((converted) => {
    converted.pipe(fs.createWriteStream('output.pdf'))
})

Command line usage:

Using without installation

npx handwritten.js -f "path/to/inputfile.txt" -o "path/to/outputfile.pdf"

Note: Use this method only if you plan to use handwritten.js for one time, installing handwritten.js globally (see-below) is recommended for multiple time usages.

Installation

npm install handwritten.js -g

Note: DO NOT use sudo to install global packages! The correct way is to tell npm where to install its global packages: npm config set prefix ~/.local. Make sure ~/.local/bin is added to PATH.

Usage after installation

handwritten.js -f "path/to/inputfile.txt" -o "path/to/outputfile.pdf"

API

Command line

handwritten.js -f path/to/inputfile.txt -o path/to/outputfile.pdf
handwritten.js -f path/to/inputfile.txt -o path/to/outputfile.pdf --ruled
handwritten.js -f path/to/inputfile.txt -o path/to/outputfolder --images png

Check --help or --version option for more details.

In code

handwritten(rawtext)
handwritten(rawtext, { ruled: true })
handwritten(rawtext, { outputtype: "jpeg/buf" })
handwritten(rawtext, { ruled: true, outputtype: "jpeg/b64" })

Default outputtype: "pdf". Supported output types are: pdf, jpeg/buf, jpeg/b64, png/buf and png/b64. If the output type is set to pdf, it returns a promise that will resolve in a pdfkit document instance. Else it will return a promise that will resolve in an array containing the buffer or base64 value of the images according to the output type provided.

Screenshot

lorem-ipsum.jpeg

Author

πŸ‘€ Rahil Kabani rahil.kabani.4@gmail.com

Show your support

Give a ⭐️ if this project helped you!

🀝 Contributing

Contributions, issues and feature requests are welcome! Feel free to check issues page.

handwritten.js only supports English letters. I am not planning to add support for other languages for now. Please do not make issues about this. However, I will merge pull requests if any. See the issue #18 for more details.

Credits

GDGVIT/HandWriter - For the cleaned dataset.

Handwritten.JS

🏠 Homepage

License

MIT

About

Convert typed text to realistic handwriting!

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%