Nihilism Philisophy Major

    gulp-pdftocairo

    0.2.0 • Public • Published

    gulp-pdftocairo Build Status npm version Dependency Status

    A gulp-compatible wrapper for pdftocairo that converts PDF to PNG/JPEG/PS/EPS/SVG

    Introduction

    A quick wrapper for pdftocairo so that I can convert pdf files to a few different formats. Supports file streams containing either streamed or buffered data (except no streams for raster formats since pdftocairo is buggy :() and since gulp says horrible things will happen if I buffer streamed files to cover up for this.

    This is my first gulp plugin. Feedback on the things done wrong is welcome.

    TODO

    • Add more command line options or at least just let you pass arbitrary arguments

    Example

    This can easily be used in a gulpfile to convert a pdf to various other formats. A simple gulpfile would be:

    var gulp = require('gulp')
      , pdftocairo = require('gulp-pdftocairo')
     
    gulp.task('to-png', function() {
      return gulp.src('*.pdf')
        .pipe( pdftocairo({format: 'png', resolution: 800}) )
        .pipe( gulp.dest('./') )
    })

    Install

    To use this, you'll need pdftocairo installed, which can probably be installed with a package manager. Currently left as an exercise for the reader.

    $ npm install gulp-pdtocairo

    API

    require('gulp-pdftocairo')( options )

    Create a transform stream that operates on file objects.

    Options:

    • format: Must be one of svg, png, ps, eps, jpg
    • resolution: For raster files, specifies the resolution of the output
    • transparent: For raster files supporting alpha (i.e. png), whether background is transparent or not
    • command: defaults to pdftocairo

    Returns: a gulp-compatible transform stream

    Testing

    Testing is performed using a mocha/chai and a pdftocairo test stub (test/stubs/pdftocairo.js) that does just enough to pass the tests as if it were pdftocairo. To test with the real thing, just change the PDFTOCAIRO variable in the test/test.js

    Credits

    (c) 2015 Ricky Reusser. MIT License

    Install

    npm i gulp-pdftocairo

    DownloadsWeekly Downloads

    1

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • rreusser