npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-pdftotext

v1.0.4

Published

A npm module wrapping the `pdftotext` utitility software

Downloads

3,790

Readme

pdftotext-module

This is an npm module wrapping over pdftotext utitility software . For pdftotool utitility software click here.

PREREQUISITES

This Package needs pdftotext installed in the host machine and added to the environment variable PATH in the host machine. You can download the pdftotext software from http://www.xpdfreader.com/download.html.

INSTALLATION

npm install node-pdftotext --save

Usage

Example

const pdftotext = require('node-pdftotext');
let options = { pdfPath: "E:\\pdfs\\example.pdf", layout: true, first: 3 };
pdftotext(options, err => {
    if (err) {
        console.log(err);
    }
    else {
        console.log('converted to txt');
    }
});

1. Options Object

You need to pass an options object with the following properties as the first argument :-

  1. pdfPath - Providing this in the options object is compulsory. This should be a path like string. In the absence of this property, the function will pass an error in the callback.

  2. txtPath - This is an optional option. This is a path like string. If you want to alter the path of the text file then set this option.

  3. first - First page to be converted. This should be a int like Number. This is optional.

  4. last - Last page to be converted. This should be a int like Number. This is optional.

  5. layout - Maintain (as best as possible) the original physical layout of the text. The default is to ´undo’ physical layout (columns, hyphenation, etc.) and output the text in reading order. If the −fixed option is given, character spacing within each line will be determined by the specified character pitch. This is to be a boolean. This option is optional. Set this to be true to set.

  6. simple - Similar to −layout, but optimized for simple one-column pages. This mode will do a better job of maintaining horizontal spacing, but it will only work properly with a single column of text. This is to be a boolean. This option is optional. Set this to be true to set.

  7. table - Table mode is similar to physical layout mode, but optimized for tabular data, with the goal of keeping rows and columns aligned (at the expense of inserting extra whitespace). If the −fixed option is given, character spacing within each line will be determined by the specified character pitch. This is to be a boolean. This option is optional. Set this to be true to set.

  8. lineprinter - Line printer mode uses a strict fixed-character-pitch and -height layout. That is, the page is broken into a grid, and characters are placed into that grid. If the grid spacing is too small for the actual characters, the result is extra whitespace. If the grid spacing is too large, the result is missing whitespace. The grid spacing can be specified using the fixed and linespacing options. If one or both are not given on the command line, pdftotext will attempt to compute appropriate value(s). This is to be a boolean. This option is optional. Set this to be true to set.

  9. raw - Keep the text in content stream order. Depending on how the PDF file was generated, this may or may not be useful. This is to be a boolean. This option is optional. Set this to be true to set.

  10. fixed - Specify the character pitch (character width), in points, for physical layout, table, or line printer mode. This is ignored in all other modes. This is to be a Number. This option is optional.

  11. linespacing number - Specify the line spacing, in points, for line printer mode. This is ignored in all other modes. This is to be a Number. This option is optional.

  12. clip - Text which is hidden because of clipping is removed before doing layout, and then added back in. This can be helpful for tables where clipped (invisible) text would overlap the next column. This is to be a boolean. This option is optional. Set this to be true to set.

  13. nodiag - Diagonal text, i.e., text that is not close to one of the 0, 90, 180, or 270 degree axes, is discarded. This is useful to skip watermarks drawn on top of body text, etc. This is to be a boolean. This option is optional. Set this to be true to set.

  14. nopgbrk - Don’t insert page breaks (form feed characters) between pages. This is to be a boolean. This option is optional. Set this to be true to set.

  15. ownerPassword - Specify the owner password for the PDF file. Providing this will bypass all security restrictions. This is to be a string containing the password. This option is optional.

  16. userPassword - Specify the user password for the PDF file. This is to be a string containing the password. This option is optional.

2. Callback Function

You need to pass a callback function as the second parameter. In case of error error object would be passed into the callback.