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

Minimal images support (updated) #253

Open
wants to merge 134 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 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
f77070c
initial commit
webcarrot Sep 30, 2016
8cd2fa7
duplicates, invalid position but works
webcarrot Oct 5, 2016
f23b322
KISS - minimal implementation, omit meta info
webcarrot Oct 6, 2016
8cf780d
remove debugger;
webcarrot Oct 6, 2016
d1fa1dd
format
webcarrot Oct 6, 2016
b46e126
add newline
webcarrot Oct 6, 2016
33c39da
no strict check
webcarrot Oct 6, 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
e208436
modify travisCI
kevin51jiang Oct 13, 2018
b0d5b81
Move back to 4.5.0
kevin51jiang Oct 13, 2018
b113498
I hope this wasn't the problem
kevin51jiang Oct 13, 2018
29a799d
Updated Version. 8.9.0 works well, but only in gitBash in admin mode.
kevin51jiang Oct 13, 2018
e8728ef
try removing the for loop
kevin51jiang Oct 13, 2018
85d1abf
Update p2j.forms.sh
kevin51jiang Oct 15, 2018
91efb1a
Updated lodash to remove vulnerabilities
Oct 16, 2018
c61de01
added check for newer file version
MasonVX Jan 28, 2019
9145e4d
fix(deps): update async to v2.6.1 to remove vulnerabilities
lgaticaq Jan 31, 2019
c833ecb
Update lodash to 4.17.15
drabinowitz Aug 30, 2019
550f66f
Merge pull request #189 from drabinowitz/update-lodash-4-17-15
modesty Sep 2, 2019
ec8dfaf
Merge pull request #179 from escaleno-ltda/bugfix/async
modesty Sep 2, 2019
6f71b62
Merge branch 'master' into master
modesty Sep 2, 2019
cb3a83b
Merge pull request #174 from morfie78/master
modesty Sep 2, 2019
3bd6a4b
build(deps): bump lodash from 4.17.11 to 4.17.13
dependabot[bot] Nov 2, 2019
62c15cf
Merge branch 'master' into master
modesty Feb 17, 2020
22b5579
Merge pull request #173 from kevin51jiang/master
modesty Feb 17, 2020
cb91def
Merge pull request #193 from modesty/dependabot/npm_and_yarn/lodash-4…
modesty Feb 17, 2020
2bc8081
public API to set password for an encrypted PDF
srijanshetty Feb 18, 2020
7fe28ed
Merge pull request #199 from srijanshetty/password-api
modesty Mar 15, 2020
7f31020
Merge branch 'master' into disable_cache_updated_file
modesty Mar 15, 2020
ea3299c
Merge pull request #181 from MasonVX/disable_cache_updated_file
modesty Mar 15, 2020
465eb53
MAINT: update depdencies and rebuild with merged PRs
modestysn Mar 15, 2020
19ceb41
MAINT: update node version
modestysn Mar 15, 2020
417ced2
Handle dropdown options with only a name
cmmcneill Jul 17, 2020
2fc9269
Update dependencies.
westy92 Dec 15, 2020
c3af5bb
Fix annotation bug
qlagraula Dec 18, 2020
6c0b270
Merge pull request #224 from westy92/update-dependencies
modesty Dec 19, 2020
3b2915f
Changed how dropdown option with only a name is added to PL
cmmcneill Jan 28, 2021
b072683
build(deps): bump xmldom from 0.4.0 to 0.5.0
dependabot[bot] Mar 13, 2021
4976506
Merge pull request #227 from modesty/dependabot/npm_and_yarn/xmldom-0…
modesty Mar 29, 2021
256ef14
fix license type to be valid spdx identifier
mojoaxel Apr 6, 2021
995bc50
Replace optimist with yargs
varney Apr 20, 2021
9c815f9
build(deps): bump lodash from 4.17.20 to 4.17.21
dependabot[bot] May 10, 2021
b59c380
Merge pull request #231 from modesty/dependabot/npm_and_yarn/lodash-4…
modesty May 23, 2021
d1efb45
Merge pull request #230 from varney/get-rid-of-optimist
modesty May 23, 2021
8eabb8a
Merge pull request #228 from mojoaxel/patch-1
modesty May 23, 2021
d9b72eb
Merge pull request #225 from AirIntServices/master
modesty May 23, 2021
f65ce18
Merge pull request #215 from cmmcneill/dropdown_options_fix
modesty May 23, 2021
5787377
update package.json, prep for release
modestysn Jun 8, 2021
b028552
release v1.2.2
modestysn Jun 8, 2021
885d073
dependency updates
modestysn Jun 12, 2021
6a2d894
publish v1.2.3
modestysn Jun 12, 2021
909bbb3
Fix "Callback must be a function" error
dumindu-dev Jul 15, 2021
a857928
Fixed infinite loop with paintFormXObjectEnd
cmmcneill Nov 13, 2020
368f12b
Warn instead of error when name token longer than spec
cmmcneill Jul 28, 2021
eeaab0e
Merge pull request #237 from dumdam/patch-2
modesty Jul 28, 2021
2ec45e7
Merge pull request #239 from cmmcneill/allow_long_name_tokens
modesty Jul 28, 2021
7cb6ad6
Safer paintFormXObjectEnd
cmmcneill Jul 29, 2021
75a3f0e
Update xmldom to 0.7.1
h3ku Aug 20, 2021
c323a1b
Merge pull request #238 from cmmcneill/fix_xobject_infinite_loop
modesty Sep 4, 2021
dbd058a
Merge pull request #241 from h3ku/master
modesty Sep 4, 2021
08aa555
publish @1.2.4
modestysn Sep 4, 2021
fa5105d
fix issue #243, also add test PDF for best error handling
modestysn Sep 19, 2021
231cfdf
fix issue #221, also add i221_tianjin_invoice.pdf to test
modestysn Sep 19, 2021
ebdad12
refactor test scripts, update README for test with exceptions
modestysn Sep 25, 2021
82192e3
bump dependency versions
modestysn Oct 2, 2021
1f544df
refactor pdfparser.js with es6 class and stream
modestysn Oct 3, 2021
ac42179
add lib/parserstream to centralize stream utils
modestysn Oct 3, 2021
b507b23
Prevent `Cannot read property 'vertical' of undefined`
xzhayon Oct 3, 2021
5be0566
Merge remote-tracking branch 'origin/master' into es6class
modestysn Oct 3, 2021
129904b
refactor lib/p2jcmd.js with es6 class
modestysn Oct 3, 2021
3247e74
refactor pdf.js with es6 class
modestysn Oct 9, 2021
84893cf
include full metadata in parsed data
modestysn Oct 9, 2021
18d2d7a
add Readable stream like events, like readable, data, error to PDF.js
modestysn Oct 10, 2021
fd29bb3
update README for major refactoring v1.3.0
modestysn Oct 10, 2021
5c08c38
1. remove formImage and Width; 2. add the use new stream events, read…
modestysn Oct 10, 2021
c0c6b46
update README for v1.3.o
modestysn Oct 12, 2021
5b5a18d
refactor anno, fill, image, line and unit with es6 class
modestysn Oct 14, 2021
972964f
refactor pdffields and pdfcanvas with es6 class
modestysn Oct 15, 2021
ceb73d2
add testingWithTable.pdf for issue 242
modestysn Oct 16, 2021
3784574
make sure only one error event raised when exception thrown, and proc…
modestysn Oct 18, 2021
1ffba32
catch and handle canvas exceptions
modestysn Oct 18, 2021
75871bb
accommodate higher version of npm
modestysn Oct 24, 2021
3369e1b
optional chainning and nullish coalescing for metadata null case
modestysn Oct 24, 2021
0eaa7a2
prep for v1.3.1 release
modestysn Oct 24, 2021
06a405f
remove lodash, prep for v2 release
modestysn Oct 29, 2021
ef0fe96
remove dependency: async
modestysn Oct 30, 2021
1271d2a
remove dependency: yargs
modestysn Nov 13, 2021
17ef9da
catch exceptions for StartRenderPage event
modestysn Nov 20, 2021
98bbef6
Merge branch 'master' into images
jonaskello Nov 25, 2021
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: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
*.swp
*.out
node_modules/
target/
.idea
.npmrc

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:
- "14.18.0"
18 changes: 11 additions & 7 deletions base/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,17 @@ var Page = (function PageClosure() {


var opList = new OperatorList(handler, self.pageIndex);

handler.send('StartRenderPage', {
transparency: partialEvaluator.hasBlendModes(self.resources),
pageIndex: self.pageIndex
});
partialEvaluator.getOperatorList(contentStream, self.resources, opList);
pageListPromise.resolve(opList);
try {
handler.send('StartRenderPage', {
transparency: partialEvaluator.hasBlendModes(self.resources),
pageIndex: self.pageIndex
});
partialEvaluator.getOperatorList(contentStream, self.resources, opList);
pageListPromise.resolve(opList);
}
catch(e) {
pageListPromise.reject(e);
}
});

var annotationsPromise = pdfManager.ensure(this, 'annotations');
Expand Down
6 changes: 3 additions & 3 deletions base/core/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,17 +553,17 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
function CipherTransformFactory(dict, fileId, password) {
var filter = dict.get('Filter');
if (!isName(filter) || filter.name != 'Standard')
error('unknown encryption method');
error('Error: unknown encryption method');
this.dict = dict;
var algorithm = dict.get('V');
if (!isInt(algorithm) ||
(algorithm != 1 && algorithm != 2 && algorithm != 4))
error('unsupported encryption algorithm');
error('Error: unsupported encryption algorithm');
this.algorithm = algorithm;
var keyLength = dict.get('Length') || 40;
if (!isInt(keyLength) ||
keyLength < 40 || (keyLength % 8) !== 0)
error('invalid key length');
error('Error: invalid key length');
// prepare keys
var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
Expand Down
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
4 changes: 3 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 Expand Up @@ -1000,6 +1001,7 @@ var XRef = (function XRefClosure() {
throw e;
}
log('(while reading XRef): ' + e);
error(e);
}

if (recoveryMode)
Expand Down
5 changes: 2 additions & 3 deletions base/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,8 @@ var Lexer = (function LexerClosure() {
str += String.fromCharCode(ch);
}
}
if (str.length > 128) {
error('Warning: name token is longer than allowed by the spec: ' +
str.length);
if (str.length > 127) {
warn('Name token is longer than allowed by the spec: ' + str.length);
}
return new Name(str);
},
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
13 changes: 9 additions & 4 deletions base/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,13 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
return;
}
stats.time('Rendering');
internalRenderTask.initalizeGraphics(transparency);
internalRenderTask.operatorListChanged();
try {//MQZ. catch canvas drawing exceptions
internalRenderTask.initalizeGraphics(transparency);
internalRenderTask.operatorListChanged();
}
catch(err) {
complete(err);
}
},
function pageDisplayReadPromiseError(reason) {
complete(reason);
Expand Down Expand Up @@ -862,8 +867,8 @@ var WorkerTransport = (function WorkerTransportClosure() {
promise.resolve({ data: buf, width: width, height: height});
}).bind(this);
//MQZ. Oct.17.2012 - disable image drawing
// img.src = imageUrl;
img.src = 'data:image/jpeg;base64,' + img.btoa(imageUrl);
img.src = imageUrl;
// img.src = 'data:image/jpeg;base64,' + img.btoa(imageUrl);
});
},

Expand Down
38 changes: 21 additions & 17 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 @@ -1041,7 +1036,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
showText: function CanvasGraphics_showText(glyphs, skipTextSelection) {
var ctx = this.ctx;
var current = this.current;
var font = current.font;
var font = current.font || {};
var fontSize = current.fontSize;
var fontSizeScale = current.fontSizeScale;
var charSpacing = current.charSpacing;
Expand Down Expand Up @@ -1100,19 +1095,20 @@ 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);});
var firstGlyph = glyphs.filter(g => g && ('fontChar' in g || 'unicode' in g))[0];
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 +1163,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 +1267,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 +1287,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 Expand Up @@ -1536,6 +1535,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var depth = this.current.paintFormXObjectDepth;
do {
this.restore();
this.current.paintFormXObjectDepth--;
// some pdf don't close all restores inside object
// closing those for them
} while (this.current.paintFormXObjectDepth >= depth);
Expand Down Expand Up @@ -1619,6 +1619,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},

endGroup: function CanvasGraphics_endGroup(group) {
//MQZ. make sure endGroup is always invoked after beginGroup
if (this.groupLevel == 0)
this.beginGroup(group);

this.groupLevel--;
var groupCtx = this.ctx;
this.ctx = this.groupStack.pop();
Expand Down
2 changes: 1 addition & 1 deletion base/display/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
var doc = this.metaDocument;
var rdf = doc.documentElement;

if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') { // Wrapped in <xmpmeta>
if (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') { // Wrapped in <xmpmeta>
rdf = rdf.firstChild;
while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf')
rdf = rdf.nextSibling;
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
31 changes: 17 additions & 14 deletions base/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ var OPS = PDFJS.OPS = {

//MQZ.Mar.22 Disabled Operators (to prevent image painting & annotation default appearance)
//paintJpegXObject, paintImageMaskXObject, paintImageMaskXObjectGroup, paintImageXObject, paintInlineImageXObject, paintInlineImageXObjectGroup
var NO_OPS = PDFJS.NO_OPS = [82, 83, 84, 85, 86, 87];
var NO_OPS = PDFJS.NO_OPS = [83, 84, 86, 87];
var NO_OPS_RANGE = PDFJS.NO_OPS_RANGE = [78, 79, 80, 81]; //range pairs, all ops with each pair will be skipped. !important!
var HTMLElement = typeof HTMLElement === "undefined" ?
function() { } : HTMLElement;


// Use only for debugging purposes. This should not be used in any code that is
// in mozilla master.
Expand Down Expand Up @@ -188,10 +191,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 Expand Up @@ -1229,9 +1232,9 @@ function loadJpegStream(id, imageUrl, objs) {
img.onload = (function loadJpegStream_onloadClosure() {
objs.resolve(id, img);
});
// img.src = imageUrl;
img.src = imageUrl;
//MQZ. Apr.09.2013 calls windows.btoa safely
img.src = 'data:image/jpeg;base64,' + img.btoa(imageUrl);
// img.src = 'data:image/jpeg;base64,' + img.btoa(imageUrl);
}

//MQZ Oct.18.2013 expose util methods
Expand All @@ -1241,18 +1244,18 @@ nodeUtil.p2jinfo = info;
nodeUtil.p2jwarn = warn;
nodeUtil.p2jerror = error;
nodeUtil.verbosity = function(verbo) {
if (!isNaN(verbo)) {
if (isNaN(verbo)) {
verbosity = WARNINGS;
}
else {
if (verbo <= ERRORS) {
verbo = ERRORS;
verbosity = ERRORS;
}
else if (verbo >= INFOS) {
verbo = INFOS;
verbosity = INFOS;
}

verbosity = verbo;
}
else {
verbosity = ERRORS;
else
verbosity = verbo;
}
};
nodeUtil.verbosity();
Expand Down
4 changes: 1 addition & 3 deletions bin/pdf2json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node

'use strict';

var P2JCMD = require('../lib/p2jcmd');
const P2JCMD = require('../lib/p2jcmd');
new P2JCMD().start();
13 changes: 13 additions & 0 deletions lib/imagedata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function ImageData(width, height) {
if (width && width instanceof Object) {
this.width = width.width;
this.height = width.height;
this.data = width.data;
} else {
this.width = width;
this.height = height;
this.data = new Uint8Array(width * height * 4);
}
};

module.exports = ImageData;
Loading