doc-thumbnail
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

doc-thumbnail

This utility creates a preview thumbnail from a document. It requires unoconv and ImageMagick (convert) to be installed.

API

interface BaseConfig{
	width?: number;
	height?: number;
	imagemagickPath?: string;
}
interface DocPreviewConf extends BaseConfig{
	unoconvPath?: string;
}
async function docPreview(filepath: string, conf: DocPreviewConf = {}): NodeJS.ReadableStream;
async function imgPreview(filepath: string, conf: BaseConfig = {})

To generate a preview of a PDF file you can use the imgPreview function, since the underlying ImageMagick can handle PDF files directly.

Example

const {docPreview, imgPreview} = require("doc-thumbnail");
let ws = FS.createWriteStream("example.odt.jpg");
let ts = await docPreview("example.odt", {height: 200});
ts.pipe(ws);

let ws2 = FS.createWriteStream("example.png.jpg");
let ts2 = await docPreview("example.png", {height: 200});
ts2.pipe(ws2);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    2

Package Sidebar

Install

npm i doc-thumbnail

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

12.6 kB

Total Files

6

Last publish

Collaborators

  • lal12