Skip to content

Commit dc33b24

Browse files
committed
Merge branch 'refs/heads/master' into text-select
2 parents b1ae237 + beb3107 commit dc33b24

File tree

8 files changed

+69
-25
lines changed

8 files changed

+69
-25
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ bundle: | $(BUILD_DIR)
6363
@cd src; \
6464
cat $(PDF_JS_FILES) > all_files.tmp; \
6565
sed '/PDFJSSCRIPT_INCLUDE_ALL/ r all_files.tmp' pdf.js > ../$(BUILD_TARGET); \
66+
sed -i '' "s/PDFJSSCRIPT_BUNDLE_VER/`git log --format="%H" -n 1`/" ../$(BUILD_TARGET); \
6667
rm -f *.tmp; \
6768
cd ..
6869

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,17 @@ workings of PDF and pdf.js:
9595
## Contributing
9696

9797
pdf.js is a community-driven project, so contributors are always welcome.
98-
Simply fork our repo and contribute away. A great place to start is our
99-
[open issues](https://github.com/mozilla/pdf.js/issues). For better consistency and
100-
long-term stability, please do look around the code and try to follow our conventions.
98+
Simply fork our repo and contribute away. Good starting places for picking
99+
a bug are the top error messages and TODOs in our corpus report:
100+
101+
+ http://people.mozilla.com/~bdahl/corpusreport/test/ref/
102+
103+
and of course our open Github issues:
104+
105+
+ https://github.com/mozilla/pdf.js/issues
106+
107+
For better consistency and long-term stability, please do look around the
108+
code and try to follow our conventions.
101109
More information about the contributor process can be found on the
102110
[contributor wiki page](https://github.com/mozilla/pdf.js/wiki/Contributing).
103111

@@ -152,9 +160,9 @@ See the bot repo for details:
152160

153161
## Additional resources
154162

155-
Our demo site is here:
163+
Gallery of user projects and modifications:
156164

157-
+ http://mozilla.github.com/pdf.js/web/viewer.html
165+
+ https://github.com/mozilla/pdf.js/wiki/Gallery-of-user-projects-and-modifications
158166

159167
You can read more about pdf.js here:
160168

src/canvas.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,9 @@ var CanvasGraphics = (function canvasGraphics() {
689689
setStrokeColor: function canvasGraphicsSetStrokeColor(/*...*/) {
690690
var cs = this.current.strokeColorSpace;
691691
var color = cs.getRgb(arguments);
692-
this.setStrokeRGBColor.apply(this, color);
692+
var color = Util.makeCssRgb.apply(null, cs.getRgb(arguments));
693+
this.ctx.strokeStyle = color;
694+
this.current.strokeColor = color;
693695
},
694696
getColorN_IR_Pattern: function canvasGraphicsGetColorN_IR_Pattern(IR, cs) {
695697
if (IR[0] == 'TilingPattern') {
@@ -724,8 +726,9 @@ var CanvasGraphics = (function canvasGraphics() {
724726
},
725727
setFillColor: function canvasGraphicsSetFillColor(/*...*/) {
726728
var cs = this.current.fillColorSpace;
727-
var color = cs.getRgb(arguments);
728-
this.setFillRGBColor.apply(this, color);
729+
var color = Util.makeCssRgb.apply(null, cs.getRgb(arguments));
730+
this.ctx.fillStyle = color;
731+
this.current.fillColor = color;
729732
},
730733
setFillColorN_IR: function canvasGraphicsSetFillColorN(/*...*/) {
731734
var cs = this.current.fillColorSpace;
@@ -737,27 +740,49 @@ var CanvasGraphics = (function canvasGraphics() {
737740
}
738741
},
739742
setStrokeGray: function canvasGraphicsSetStrokeGray(gray) {
740-
this.setStrokeRGBColor(gray, gray, gray);
743+
if (!(this.current.strokeColorSpace instanceof DeviceGrayCS))
744+
this.current.strokeColorSpace = new DeviceGrayCS();
745+
746+
var color = Util.makeCssRgb(gray, gray, gray);
747+
this.ctx.strokeStyle = color;
748+
this.current.strokeColor = color;
741749
},
742750
setFillGray: function canvasGraphicsSetFillGray(gray) {
743-
this.setFillRGBColor(gray, gray, gray);
751+
if (!(this.current.fillColorSpace instanceof DeviceGrayCS))
752+
this.current.fillColorSpace = new DeviceGrayCS();
753+
754+
var color = Util.makeCssRgb(gray, gray, gray);
755+
this.ctx.fillStyle = color;
756+
this.current.fillColor = color;
744757
},
745758
setStrokeRGBColor: function canvasGraphicsSetStrokeRGBColor(r, g, b) {
759+
if (!(this.current.strokeColorSpace instanceof DeviceRgbCS))
760+
this.current.strokeColorSpace = new DeviceRgbCS();
761+
746762
var color = Util.makeCssRgb(r, g, b);
747763
this.ctx.strokeStyle = color;
748764
this.current.strokeColor = color;
749765
},
750766
setFillRGBColor: function canvasGraphicsSetFillRGBColor(r, g, b) {
767+
if (!(this.current.fillColorSpace instanceof DeviceRgbCS))
768+
this.current.fillColorSpace = new DeviceRgbCS();
769+
751770
var color = Util.makeCssRgb(r, g, b);
752771
this.ctx.fillStyle = color;
753772
this.current.fillColor = color;
754773
},
755774
setStrokeCMYKColor: function canvasGraphicsSetStrokeCMYKColor(c, m, y, k) {
775+
if (!(this.current.strokeColorSpace instanceof DeviceCmykCS))
776+
this.current.strokeColorSpace = new DeviceCmykCS();
777+
756778
var color = Util.makeCssCmyk(c, m, y, k);
757779
this.ctx.strokeStyle = color;
758780
this.current.strokeColor = color;
759781
},
760782
setFillCMYKColor: function canvasGraphicsSetFillCMYKColor(c, m, y, k) {
783+
if (!(this.current.fillColorSpace instanceof DeviceCmykCS))
784+
this.current.fillColorSpace = new DeviceCmykCS();
785+
761786
var color = Util.makeCssCmyk(c, m, y, k);
762787
this.ctx.fillStyle = color;
763788
this.current.fillColor = color;

src/evaluator.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,9 @@ var PartialEvaluator = (function partialEvaluator() {
522522
var cmapObj = xref.fetchIfRef(toUnicode);
523523
var charToUnicode = [];
524524
if (isName(cmapObj)) {
525-
error('ToUnicode file cmap translation not implemented');
525+
var isIdentityMap = cmapObj.name.substr(0, 9) == 'Identity-';
526+
if (!isIdentityMap)
527+
error('ToUnicode file cmap translation not implemented');
526528
} else if (isStream(cmapObj)) {
527529
var tokens = [];
528530
var token = '';

src/pdf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ var PDFJS = {};
77
// Use strict in our context only - users might not want it
88
'use strict';
99

10+
PDFJS.build = 'PDFJSSCRIPT_BUNDLE_VER';
11+
1012
// Files are inserted below - see Makefile
1113
/* PDFJSSCRIPT_INCLUDE_ALL */
1214

1315
}).call((typeof window === 'undefined') ? this : window);
14-

test/driver.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,29 @@ function load() {
5656
}
5757

5858
function cleanup() {
59-
var styleSheet = document.styleSheets[0];
60-
if (styleSheet) {
59+
// Clear out all the stylesheets since a new one is created for each font.
60+
while (document.styleSheets.length > 0) {
61+
var styleSheet = document.styleSheets[0];
6162
while (styleSheet.cssRules.length > 0)
6263
styleSheet.deleteRule(0);
64+
var ownerNode = styleSheet.ownerNode;
65+
ownerNode.parentNode.removeChild(ownerNode);
6366
}
6467
var guard = document.getElementById('content-end');
6568
var body = document.body;
6669
while (body.lastChild !== guard)
6770
body.removeChild(body.lastChild);
71+
72+
// Wipe out the link to the pdfdoc so it can be GC'ed.
73+
for (var i = 0; i < manifest.length; i++) {
74+
if (manifest[i].pdfDoc) {
75+
manifest[i].pdfDoc.destroy();
76+
delete manifest[i].pdfDoc;
77+
}
78+
}
6879
}
6980

7081
function nextTask() {
71-
// If there is a pdfDoc on the last task executed, destroy it to free memory.
72-
if (task && task.pdfDoc) {
73-
task.pdfDoc.destroy();
74-
delete task.pdfDoc;
75-
}
7682
cleanup();
7783

7884
if (currentTaskIdx == manifest.length) {

test/test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,18 @@ def verifyPDFs(manifestList):
323323
if os.access(f, os.R_OK):
324324
fileMd5 = hashlib.md5(open(f, 'rb').read()).hexdigest()
325325
if 'md5' not in item:
326-
print 'ERROR: Missing md5 for file "' + f + '".',
326+
print 'WARNING: Missing md5 for file "' + f + '".',
327327
print 'Hash for current file is "' + fileMd5 + '"'
328328
error = True
329329
continue
330330
md5 = item['md5']
331331
if fileMd5 != md5:
332-
print 'ERROR: MD5 of file "' + f + '" does not match file.',
332+
print 'WARNING: MD5 of file "' + f + '" does not match file.',
333333
print 'Expected "' + md5 + '" computed "' + fileMd5 + '"'
334334
error = True
335335
continue
336336
else:
337-
print 'ERROR: Unable to open file for reading "' + f + '".'
337+
print 'WARNING: Unable to open file for reading "' + f + '".'
338338
error = True
339339
return not error
340340

@@ -365,7 +365,8 @@ def setUp(options):
365365
downloadLinkedPDFs(manifestList)
366366

367367
if not verifyPDFs(manifestList):
368-
raise Exception('ERROR: failed to verify pdfs.')
368+
print 'Unable to verify the checksum for the files that are used for testing.'
369+
print 'Please re-download the files, or adjust the MD5 checksum in the manifest for the files listed above.\n'
369370

370371
for b in testBrowsers:
371372
State.taskResults[b.name] = { }

test/test_manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
{ "id": "intelisa-load",
2121
"file": "pdfs/intelisa.pdf",
22-
"md5": "f3ed5487d1afa34d8b77c0c734a95c79",
22+
"md5": "f5712097d29287a97f1278839814f682",
2323
"link": true,
2424
"rounds": 1,
2525
"type": "load"
@@ -194,7 +194,7 @@
194194
},
195195
{ "id": "f1040",
196196
"file": "pdfs/f1040.pdf",
197-
"md5": "7323b50c6d28d959b8b4b92c469b2469",
197+
"md5": "b59272ce19b4a0c5808c8861441b0741",
198198
"link": true,
199199
"rounds": 1,
200200
"type": "load"

0 commit comments

Comments
 (0)