Comparing version 1.0.0-alpha.5 to 2.0.0-alpha.1
'use strict' | ||
var Document = exports.Document = require('./element/document') | ||
exports.createDocument = function(style) { | ||
return new Document(style) | ||
} | ||
const util = require('./util') | ||
var TTFFont = exports.TTFFont = require('./element/font/ttf') | ||
exports.createTTFFont = function(src) { | ||
return new TTFFont(src) | ||
} | ||
exports.Document = require('./document') | ||
exports.Font = require('./font') | ||
const PDFImage = require('./image/pdf') | ||
const JPEGImage = require('./image/jpeg') | ||
var Image = exports.Image = require('./image') | ||
exports.createImage = function(src) { | ||
return new Image(src) | ||
exports.Image = class Image { | ||
constructor(b) { | ||
const src = util.toArrayBuffer(b) | ||
switch (determineType(src)) { | ||
case 'pdf': | ||
return new PDFImage(src) | ||
case 'jpeg': | ||
return new JPEGImage(src) | ||
default: | ||
throw new TypeError('Unsupported image type') | ||
} | ||
} | ||
} | ||
exports.Parser = require('./pdf/parser/document') | ||
function determineType(buffer) { | ||
const pdf = String.fromCharCode.apply(null, new Uint8Array(buffer, 0, 5)) | ||
if (pdf === '%PDF-') { | ||
return 'pdf' | ||
} | ||
var isClient = typeof window !== 'undefined' && !!window.document | ||
// trick browserify | ||
var fs = (require)('fs') | ||
exports.load = function(path, callback) { | ||
if (isClient) { | ||
var xhr = new XMLHttpRequest() | ||
xhr.open('GET', path, true) | ||
xhr.responseType = 'arraybuffer' | ||
const view = new DataView(buffer) | ||
if (view.getUint8(0) === 0xff || view.getUint8(1) === 0xd8) { | ||
return 'jpeg' | ||
} | ||
if (xhr.overrideMimeType) { | ||
xhr.overrideMimeType('text/plain; charset=x-user-defined') | ||
} else { | ||
xhr.setRequestHeader('Accept-Charset', 'x-user-defined') | ||
} | ||
return null | ||
} | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
callback(null, xhr.response) | ||
} else { | ||
callback(new Error(xhr.statusText), null) | ||
} | ||
} | ||
exports.ExternalDocument = require('./external') | ||
xhr.send(null) | ||
} else { | ||
fs.readFile(path, callback) | ||
} | ||
} | ||
exports.mm = 0.0393700787 * 72 | ||
exports.cm = exports.mm * 10 |
{ | ||
"name": "pdfjs", | ||
"author": { | ||
"name": "Markus Ast", | ||
"email": "npm.m@rkusa.st" | ||
}, | ||
"version": "1.0.0-alpha.5", | ||
"homepage": "https://github.com/rkusa/pdfjs", | ||
"author": "Markus Ast <npm.m@rkusa.st>", | ||
"version": "2.0.0-alpha.1", | ||
"description": "A Portable Document Format (PDF) generation library targeting both the server- and client-side.", | ||
@@ -15,22 +11,17 @@ "keywords": [ | ||
"license": "MIT", | ||
"main": "lib/index", | ||
"homepage": "https://github.com/rkusa/pdfjs", | ||
"bugs": "https://github.com/rkusa/pdfjs/issues", | ||
"main": "lib/", | ||
"scripts": { | ||
"test": "tap strict test/index.js", | ||
"prepublish": "browserify lib/index.js --debug --standalone pdfjs --detect-globals false | exorcist dist/pdfjs.js.map > dist/pdfjs.js" | ||
"test": "node --harmony-async-await test/index.js test/pdfs/**/*.js" | ||
}, | ||
"dependencies": { | ||
"base-64": "^0.1.0", | ||
"debug": "^2.2", | ||
"linebreak": "^0.3.0", | ||
"node-uuid": "^1.4", | ||
"ttfjs": "^0.4.0", | ||
"unorm": "^1.3" | ||
"opentype.js": "^0.6.2", | ||
"unorm": "^1.4.1", | ||
"uuid": "^3.0.1" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^10.2", | ||
"exorcist": "^0.4.0", | ||
"glob": "^5.0", | ||
"tap": "^1.0" | ||
"tape": "^4.6.3" | ||
}, | ||
"bugs": "https://github.com/rkusa/pdfjs/issues", | ||
"repository": { | ||
@@ -41,4 +32,4 @@ "type": "git", | ||
"engines": { | ||
"node": ">=0.8" | ||
"node": ">=7" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
![pdfjs](https://raw.githubusercontent.com/rkusa/pdfjs/master/logo/pdfjs.png) | ||
![pdfjs](https://cdn.rawgit.com/rkusa/pdfjs/2.x/logo.svg) | ||
@@ -7,38 +7,39 @@ A Portable Document Format (PDF) generation library targeting both the server- and client-side. | ||
[![Dependency Status][deps]](https://david-dm.org/rkusa/pdfjs) | ||
[![Build Status][drone]](https://ci.rkusa.st/github.com/rkusa/pdfjs) | ||
[![Build Status][travis]](https://travis-ci.org/rkusa/pdfjs) | ||
[Documentation](docs) | ||
## 1.0.0 Breaking Changes | ||
pdfjs 1.0.0-alpha.1 (still in development; expected to be buggy) contains a rewritten layout engine (layout engine of pdfjs `<=0.5` reached its limits), i.e., both API and layout behavior has changed completely. Install with: | ||
```bash | ||
npm install pdfjs@1.0.0-alpha.1 | ||
npm install rkusa/pdfjs@2.0.0-alpha.1 | ||
``` | ||
## 2.0.0 Breaking Changes | ||
Version `2.0.0` is a re-write. I tried completely different approaches of the last years. Finally, this version has streaming layouting with smart content chunking, which allows for having a small memory footprint even when creating a PDF document with thousands of pages. I highly expect to settle with this implementation. | ||
---------------- | ||
### Features | ||
- Text (many formatting options) | ||
- Text (with common formatting options) | ||
- Images (JPEGs, other **PDFs**) | ||
- Tables (fixed layout, header row, before page break rows) | ||
- Tables (fixed layout, header row) | ||
- Header & Footer | ||
- TTF Font embedding (as CID fonts, i.e., support for fonts with large character sets) | ||
- AFM fonts && OTF font embedding (as CID fonts, i.e., support for fonts with large character sets) | ||
- Add existing PDFs (merge them or add them as page templates) | ||
**Missing:** AFM fonts are currently not implemented. | ||
If you are missing a feature, feel free to submit a PR or to ask for it. | ||
## MIT License | ||
### History | ||
Copyright (c) 2013-2015 Markus Ast | ||
- *v2.x* - streaming layouting with smart content chunking | ||
- *v1.x* - calculate whole document layout upfront | ||
- *v0.x* - in-memory layouting with rollbacks | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
## MIT License | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
[MIT](LICENSE) | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
[npm]: http://img.shields.io/npm/v/pdfjs.svg?style=flat-square | ||
[deps]: http://img.shields.io/david/rkusa/pdfjs.svg?style=flat-square | ||
[drone]: http://ci.rkusa.st/api/badge/github.com/rkusa/pdfjs/status.svg?branch=master&style=flat-square | ||
[npm]: https://img.shields.io/npm/v/pdfjs.svg?style=flat-square | ||
[deps]: https://img.shields.io/david/rkusa/pdfjs.svg?style=flat-square | ||
[travis]: https://img.shields.io/travis/rkusa/pdfjs/master.svg?style=flat-square |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
891148
4
1
74
45
1
3984
1
+ Addedopentype.js@^0.6.2
+ Addeduuid@^3.0.1
+ Addedopentype.js@0.6.9(transitive)
+ Addeduuid@3.4.0(transitive)
- Removedbase-64@^0.1.0
- Removeddebug@^2.2
- Removednode-uuid@^1.4
- Removedttfjs@^0.4.0
- Removedbase-64@0.1.0(transitive)
- Removeddebug@2.6.9(transitive)
- Removedms@2.0.0(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedstructjs@0.2.2(transitive)
- Removedttfjs@0.4.0(transitive)
Updatedunorm@^1.4.1