Comparing version 0.1.9 to 0.1.10
{ | ||
"name": "pdf2json", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "A PDF file parser that converts PDF binaries to text based JSON, powered by a fork of PDF.JS", | ||
@@ -57,4 +57,4 @@ "keywords": [ | ||
"readme": "", | ||
"_id": "pdf2json@0.1.9", | ||
"_id": "pdf2json@0.1.10", | ||
"_from": "pdf2json" | ||
} |
@@ -136,3 +136,4 @@ | ||
if (error) { | ||
nodeUtil._logN.call(self, 'An error occurred while rendering the page.' + error); | ||
nodeUtil._logN.call(self, 'An error occurred while rendering the page ' + (self.id + 1) + ';\n' + error); | ||
//TOGO: emit error event | ||
} | ||
@@ -142,3 +143,2 @@ else { | ||
_.extend(self, ctx.canvas); | ||
} | ||
@@ -145,0 +145,0 @@ |
@@ -223,2 +223,4 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | ||
} | ||
//MQZ Jan.22.2013: trying to merged kerning spaced text | ||
this.lastSTParam = []; | ||
} | ||
@@ -300,3 +302,23 @@ | ||
if (fnName !== 'dependency') { | ||
this[fnName].apply(this, argsArray[i]); | ||
//MQZ.Jan.22. trying to merge kerning text | ||
var goOn = true; | ||
if (fnName == 'showSpacedText') { | ||
if (this.lastSTParam.length > 0) { | ||
this.lastSTParam[0] = this.lastSTParam[0].concat(argsArray[i][0].slice(0)); | ||
console.log("merged:" + JSON.stringify(this.lastSTParam[0])); | ||
this[fnName].apply(this, this.lastSTParam); | ||
this.lastSTParam = []; | ||
goOn = false; | ||
} | ||
else if ( i + 3 < fnArray.length) { | ||
if (fnArray[i+1] === 'setCharSpacing' && fnArray[i+2] === 'setWordSpacing' && | ||
fnArray[i+3] === 'showSpacedText') { | ||
this.lastSTParam = argsArray[i].slice(0); //clone it | ||
goOn = false; | ||
} | ||
} | ||
} | ||
if (goOn) { | ||
this[fnName].apply(this, argsArray[i]); | ||
} | ||
} else { | ||
@@ -876,4 +898,6 @@ var deps = argsArray[i]; | ||
var sText = ""; | ||
var spacingLength = 0; | ||
// console.log("In spacedText:" + JSON.stringify(arr) + ";this.current = " + this.current.x + "," + this.current.y + ";"); | ||
var charWidth = {min:0.220 * fontSize * textHScale, max: 0.35 * fontSize * textHScale}; | ||
var sText = ""; | ||
var spacingLength = 0; | ||
for (var i = 0; i < arrLength; ++i) { | ||
@@ -886,13 +910,19 @@ var e = arr[i]; | ||
var spTextWidth = 0; | ||
if (spacingLength > 0.1) { | ||
if (spacingLength >= charWidth.max) { | ||
spTextWidth = this.showText(sText, true); | ||
sText = ""; | ||
current.x += spacingLength; | ||
if (textSelection) | ||
canvasWidth += spacingLength + spTextWidth; | ||
} | ||
current.x += spacingLength; | ||
if (textSelection) | ||
canvasWidth += spacingLength + spTextWidth; | ||
else if (spacingLength >= charWidth.min) { | ||
sText += " ";//converting -220 to -350 kerning to be a space character | ||
} | ||
else { | ||
// console.log("ignored kerning of " + e + " in #" + i + " of " + JSON.stringify(arr)); | ||
} | ||
} | ||
else | ||
else if (i > 0) | ||
current.x -= spacingLength; | ||
} else if (isString(e)) { | ||
@@ -910,5 +940,7 @@ // var shownCanvasWidth = this.showText(e, true); | ||
//MQZ. Nov.28.2012 Disable character based rendering, make it a string | ||
var shownCanvasWidth = this.showText(sText, true); | ||
if (textSelection) | ||
canvasWidth += shownCanvasWidth; | ||
if (sText) { | ||
var shownCanvasWidth = this.showText(sText, true); | ||
if (textSelection) | ||
canvasWidth += shownCanvasWidth; | ||
} | ||
@@ -915,0 +947,0 @@ if (textSelection) { |
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
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
29280756
26572