Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pdf.js #183

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e90431c
start to use es6 with node 4.3
modestysn Feb 28, 2016
58ba486
add working parsering output for testing
modestysn Feb 28, 2016
2ff97a7
v1.0.0: prepare for new release by updating readme, unit test and rem…
modestysn Feb 28, 2016
c2ed894
v1.0.1: pre-release
modestysn Feb 28, 2016
ae8e9d1
v1.0.1: removed test output folder
modestysn Feb 28, 2016
6929aec
v1.0.2: formatted all float number precision to be 3; refactored top …
modestysn Feb 29, 2016
773fb4b
v1.0.3: expose getAllFieldsTypes from PDFParser
modestysn Mar 1, 2016
95eb897
v1.0.4: moved getAllFieldsTypes from PDFPArser to lib/pdfjs
modestysn Mar 1, 2016
a82c93c
v1.0.5: enable ('-m') merging broken text blocks
modestysn Mar 2, 2016
fc9f5f2
disabled remeasure in fonts.js for canvas.js
modestysn Mar 3, 2016
43c35de
v1.0.6: refactor getMergedTextBlocksIfNeeded. More tests needed
modestysn Mar 4, 2016
eab8f05
v1.0.7: document -m swtich for auto-merging broken text blocks
modestysn Mar 5, 2016
70ca4c7
v1.0.8: breaking change for x coordinate page unit conversion, client…
modestysn Mar 6, 2016
124b1fb
v1.0.9: fixed issue #21 and #26
modestysn Mar 9, 2016
eefb087
v1.1.1: fix issue #42, #43 and #54
modestysn Mar 10, 2016
29e70c1
v1.1.2: refactor event pdfjs_parseDataReady: signal end of parsed dat…
modestysn Mar 15, 2016
7a18a6d
v1.1.3: refactor: start to implement transform stream
modestysn Mar 17, 2016
cfe890e
v1.1.4: complete transform stream
modestysn Mar 18, 2016
eeb44e2
v1.1.5: stream clean up and adjust raw text line detection
modestysn Mar 19, 2016
551591b
readme.md typo
skdfjoaf May 31, 2016
842b9f1
Merge pull request #67 from haaaiiimmm/patch-1
modesty Jun 25, 2016
3e0d229
correct readme typo
modestysn Jul 2, 2016
4dd6f22
add testing pdf for issue #64
modestysn Jul 2, 2016
e0d5a00
v1.1.6: only merge two adjacent text blocks
modestysn Jul 5, 2016
e962744
[fix] Cannot find module './pdf2json/PDFParser'
Jul 28, 2016
ab2175b
Added parameters this and 1 to PDFParser in readme
xdvarpunen Aug 1, 2016
849a81c
add .npmignore file
aantthony Sep 9, 2016
c5e0a26
Merge pull request #75 from ericson-cepeda/patch-1
modesty Sep 9, 2016
9cdab1f
Merge pull request #77 from xdvarpunen/master
modesty Sep 9, 2016
246442d
Merge pull request #86 from SwiftHero/master
modesty Sep 9, 2016
c5551c2
v1.1.7: replaced underscore with lodash. also merged pull request for…
modestysn Sep 11, 2016
3fe724d
v1.1.8: add travis yaml, update required node version to be 4.5.0
modestysn Sep 11, 2016
689caf1
Extended the fix for issue #42 and added additional hybrid dual boldi…
todorowww Jan 24, 2017
0e0f416
chore(ignore) add .idea to .gitignore
ydfzgyj Apr 20, 2017
0e37002
fix(canvas) remove leading word spacing after render
ydfzgyj Apr 20, 2017
9482c6a
fix(canvas) split word when spacing is a positive number but very big
ydfzgyj Apr 20, 2017
d63de2d
Merge pull request #108 from todorowww/master
modesty Apr 22, 2017
0433368
Merge pull request #117 from ydfzgyj/spacing-adjustment
modesty Apr 22, 2017
14c9626
Fixed bug on some pdfs with fields
Dec 6, 2017
c7d6836
Merge pull request #144 from miguelduarte42/master
modesty Dec 20, 2017
30b4e6e
Document Pages->Texts->R->TS in readme.md
davemevans Apr 18, 2018
030d85d
Do not fail if url is undefined
neko6 May 21, 2018
b50fb26
Merge pull request #153 from bbcrddave/patch-1
modesty May 26, 2018
132d32a
Merge pull request #159 from ranhalprin/do_not_fail_url_undefined
modesty May 26, 2018
008e0b6
users can get the selected value from dropdowns
ejminmehranian Jul 23, 2018
762cec1
Merge pull request #166 from ejminmehranian/master
modesty Sep 18, 2018
47fe493
Update pdf.js
AVert Apr 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
*.swp
*.out
node_modules/

target/
.idea
11 changes: 11 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## generic files to ignore
*~
*.lock
*.DS_Store
*.swp
*.out
node_modules/
target/

.gitignore
test
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "4.5.0"
3 changes: 2 additions & 1 deletion base/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2220,8 +2220,9 @@ var Font = (function FontClosure() {
// name ArialBlack for example will be replaced by Helvetica.
this.black = (name.search(/Black/g) != -1);

//MQZ Dec.03.2013 Disable font.remeasure
// if at least one width is present, remeasure all chars when exists
this.remeasure = Object.keys(this.widths).length > 0;
//this.remeasure = Object.keys(this.widths).length > 0;

this.encoding = properties.baseEncoding;
this.noUnicodeAdaptation = true;
Expand Down
3 changes: 2 additions & 1 deletion base/core/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ var RefSetCache = (function RefSetCacheClosure() {
},

has: function RefSetCache_has(ref) {
return ('R' + ref.num + '.' + ref.gen) in this.dict;
//MQZ. 03/08/2016 fix https://github.com/modesty/pdf2json/issues/26
return !!ref ? ('R' + ref.num + '.' + ref.gen) in this.dict : false;
},

put: function RefSetCache_put(ref, obj) {
Expand Down
5 changes: 3 additions & 2 deletions base/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,9 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
var start = Date.now();
page.extractTextContent().then(function(textContent) {
promise.resolve(textContent);
log('text indexing: page=%d - time=%dms', pageNum,
Date.now() - start);
//MQZ 03/17/2016 comment out log
//log('text indexing: page=%d - time=%dms', pageNum,
// Date.now() - start);
}, function (e) {
// Skip errored pages
promise.reject(e);
Expand Down
27 changes: 14 additions & 13 deletions base/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
this.ctx.font = rule;

//MQZ.Oct.23.2012. enable font detection
if (!fontObj.spaceWidth) {
var spaceId = isArray(fontObj.toFontChar) ? fontObj.toFontChar.indexOf(32) : -1;
fontObj.spaceWidth = (spaceId >= 0 && isArray(fontObj.widths)) ? fontObj.widths[spaceId] : 250;
}
this.ctx.setFont(fontObj);
this.ctx.setFont(fontObj);
},
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
this.current.textRenderingMode = mode;
Expand Down Expand Up @@ -1100,19 +1095,22 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.processingType3 = null;
} else {
ctx.save();
var tx = 0;

//MQZ Dec.04.2013 handles leading word spacing
var tx = 0;
if (wordSpacing !== 0) {
var firstGlyph = _.find(glyphs, function(g) { return _.isObject(g);});
if (firstGlyph && (firstGlyph.fontChar === ' ' || firstGlyph.unicode === ' ')) {
if (_.find(glyphs, function(g) { return _.isObject(g) && g.unicode !== ' ';})) {
current.x += wordSpacing * fontSize * textHScale;
tx = wordSpacing * fontSize * textHScale;
}
}
}

current.x += tx
this.applyTextTransforms();
current.x -= tx
// MQZ-GYJ Apr.20.2017 handles leading word spacing over

var lineWidth = current.lineWidth;
var a1 = current.textMatrix[0], b1 = current.textMatrix[1];
Expand Down Expand Up @@ -1167,9 +1165,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
scaledY = 0;
}

//MQZ Dec.03.2013 Disable font.remeasure
font.remeasure = false;

if (font.remeasure && width > 0) {
// some standard fonts may not have the exact width, trying to
// rescale per character
Expand Down Expand Up @@ -1274,7 +1269,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}

//MQZ Nov.28.2012 Adjust Text Positions, and also make it a string
var stGlyphs = [];
var stGlyphs = [];
var spaceWidth = font.spaceWidth;
if (!font.spaceWidth) {
var spaceId = isArray(font.toFontChar) ? font.toFontChar.indexOf(32) : -1;
spaceWidth = (spaceId >= 0 && isArray(font.widths)) ? font.widths[spaceId] : 250;
}

for (var i = 0; i < arrLength; ++i) {
var e = arr[i];
Expand All @@ -1289,7 +1289,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
}
else {
if (-e >= font.spaceWidth) {
//MQZ-GYJ. Apr.20.2017 split word when spacing is a positive number but very big
if (Math.abs(e) >= spaceWidth) {
if (vertical) {
current.y += spacingLength;
} else {
Expand Down
2 changes: 1 addition & 1 deletion base/shared/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() {

// Lets URLs beginning with 'www.' default to using the 'http://' protocol.
function addDefaultProtocolToUrl(url) {
if (url.indexOf('www.') === 0) {
if (url && url.indexOf('www.') === 0) {
return ('http://' + url);
}
return url;
Expand Down
6 changes: 3 additions & 3 deletions base/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ function error(msg) {
// Join the arguments into a single string for the lines below.
msg = [].join.call(arguments, ' ');
} else {
log('Error: ' + msg);
//log('Error: ' + msg);
}
log(backtrace());
PDFJS.LogManager.notify('error', msg);
//log(backtrace());
//PDFJS.LogManager.notify('error', msg);
throw new Error(msg);
}

Expand Down
Loading