1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 23:28:06 +02:00

Allow subpixel anti-aliasing for most of the content.

This commit is contained in:
Yury Delendik 2015-11-16 10:50:02 -06:00
parent f096e4ab91
commit 1d8800370a
7 changed files with 111 additions and 55 deletions

View file

@ -50,6 +50,12 @@ var SimpleTextLayerBuilder = (function SimpleTextLayerBuilderClosure() {
this.ctx = ctx;
this.viewport = viewport;
this.textCounter = 0;
// clear canvas
ctx.save();
ctx.fillStyle = 'rgb(255,255,255)';
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.restore();
}
SimpleTextLayerBuilder.prototype = {
@ -271,6 +277,7 @@ var Driver = (function DriverClosure() {
_nextPage: function Driver_nextPage(task, loadError) {
var self = this;
var failure = loadError || '';
var ctx;
if (!task.pdfDoc) {
var dataUrl = this.canvas.toDataURL('image/png');
@ -301,7 +308,11 @@ var Driver = (function DriverClosure() {
// Empty the canvas
this.canvas.width = 1;
this.canvas.height = 1;
this._clearCanvas();
ctx = this.canvas.getContext('2d', {alpha: false});
ctx.save();
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 1, 1);
ctx.restore();
this._snapshot(task, '');
return;
@ -311,7 +322,8 @@ var Driver = (function DriverClosure() {
try {
this._log(' Loading page ' + task.pageNum + '/' +
task.pdfDoc.numPages + '... ');
var ctx = this.canvas.getContext('2d');
this.canvas.mozOpaque = true;
ctx = this.canvas.getContext('2d', {alpha: false});
task.pdfDoc.getPage(task.pageNum).then(function(page) {
var viewport = page.getViewport(PDF_TO_CSS_UNITS);
self.canvas.width = viewport.width;
@ -371,7 +383,7 @@ var Driver = (function DriverClosure() {
},
_clearCanvas: function Driver_clearCanvas() {
var ctx = this.canvas.getContext('2d');
var ctx = this.canvas.getContext('2d', {alpha: false});
ctx.beginPath();
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
},