Skip to content

Commit

Permalink
changed readme, cleanup travis-ci config
Browse files Browse the repository at this point in the history
  • Loading branch information
yakovmeister committed Apr 12, 2018
1 parent f961706 commit c83e043
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 39 deletions.
12 changes: 6 additions & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"presets": [
"env",
"stage-0",
"stage-1",
"stage-2"
]
"presets": [
"env",
"stage-0",
"stage-1",
"stage-2"
]
}
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ install:
language: node_js
node_js:
- 4.1.2
- 4.8.4
- 5.12.0
- 6.0.0
- 6.8.1
- 6.10.0
- 7.10.0
- 8.0.0
- 8.5.0
- 9.2.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdf2pic",
"version": "1.2.5",
"version": "1.2.6",
"description": "A utility for converting pdf to image and base64 format.",
"main": "index.js",
"license": "MIT",
Expand Down
54 changes: 26 additions & 28 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PDF2Pic
[![Build Status](https://travis-ci.org/yakovmeister/pdf2image.svg?branch=1.0)](https://travis-ci.org/yakovmeister/pdf2image)
[![Version](https://img.shields.io/badge/version-1.2.5-blue.svg)](https://github.com/yakovmeister/pdf2image/tree/1.0)
[![Version](https://img.shields.io/badge/version-1.2.6-blue.svg)](https://github.com/yakovmeister/pdf2image/tree/1.0)
A utility for converting pdf to image and base64 format.

## Prerequisite
Expand All @@ -10,8 +10,10 @@ A utility for converting pdf to image and base64 format.

## Features

* converts pdf to image, duh.
* converts pdf to base64.
* converts pdf to image.
* converts pdf to base64.
* customizable output.
* customizable image quality.

## Dependencies

Expand All @@ -31,46 +33,42 @@ npm install -S pdf2pic
```javascript
let PDF2Pic = require('pdf2pic').default
let converter = new PDF2Pic({
density: 100, // output pixels per inch
savename: "untitled", // output file name
savedir: "./images", // output file location
format: "png", // output file format
size: 600 // output size in pixels
density: 100, // output pixels per inch
savename: "untitled", // output file name
savedir: "./images", // output file location
format: "png", // output file format
size: 600 // output size in pixels
})

// by default the first page of the pdf will be converted
// to image
converter.convert("/path/to/pdf/sample.pdf")
.then(resolve => {
console.log("image converted successfully")
})
.then(resolve => {
console.log("image converted successfully")
})

// or you can also convert bulk
// in this example we will only convert pages 1 4 and 6
converter.convertBulk("path/to/pdf/sample.pdf", [1,4,6])
.then(resolve => {
console.log("image converted successfully")
})
.then(resolve => {
console.log("image converted successfully")
})


// fuck it, we can also convert all pages to pdf by
// we can also convert all pages to pdf by
// supplying -1 as second argument
converter.convertBulk("path/to/pdf/sample.pdf", -1)
.then(resolve => {
console.log("image converted successfully")
})
.then(resolve => {
console.log("image converted successfully")
})


// you can also directly convert pdf to base64 of an image
converter.convertToBase64("path/to/pdf/sample.pdf")
.then(resolve => {
if(resolve.base64) {
// assuming you're using some ORM to save base64 to db
db.model.table('users').update({id: "1", image: resolve.base64})
}
})
.then(resolve => {
if (resolve.base64) {
// assuming you're using some ORM to save base64 to db
db.model.table('users').update({id: "1", image: resolve.base64})
}
})
```

## Issues

* running convert() after running convertToBase64() doesn't save the file.

0 comments on commit c83e043

Please sign in to comment.