Skip to content

Instantly share code, notes, and snippets.

@notmasteryet
notmasteryet / hacks.js
Created July 1, 2011 05:26
Hack for IE to support pdf.js
(function() {
try {
var a = new Uint8Array(1);
return; //no need
} catch(e) { }
function subarray(start, end) {
return this.slice(start, end);
}
@notmasteryet
notmasteryet / debug.js
Created January 18, 2012 03:15
pdf.js font instrumentation
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
// save the file as '<pdf.js>/font~/debug.js'
// bookmarklet -> javascript:(function(){if(window.fontDebugScript)%20return;%20var%20script%20=%20window.fontDebugScript%20=%20document.createElement('script');script.setAttribute('src',%20'../font~/debug.js');document.body.appendChild(script);})();
'use strict';
(function fontDebug() {
var fonts;
@notmasteryet
notmasteryet / minfont_test.html
Created February 4, 2012 18:35
Minimal test case for mininal font problem
<canvas id="c1"></canvas><br>
<script>
var c1 = document.getElementById("c1");
var ctx = c1.getContext("2d");
ctx.font = "12px serif";
ctx.fillText("test", 10, 25);
</script>
<canvas id="c2"></canvas><br>
<script>
@notmasteryet
notmasteryet / ie9.predictor.diff
Created February 3, 2012 01:51
ie9 predictor hack
diff --git a/src/stream.js b/src/stream.js
index fc16317..882e3f7 100644
--- a/src/stream.js
+++ b/src/stream.js
@@ -754,6 +754,10 @@ var PredictorStream = (function PredictorStreamClosure() {
default:
error('Unsupported predictor: ' + predictor);
}
+
+ // hack for TypedArray-less browsers
@notmasteryet
notmasteryet / gist:1623832
Created January 17, 2012 00:42
Small test for issue #999 for pdf.js
<html>
<script>
function run() {
var c = document.getElementById("c");
var ctx = c.getContext("2d");
ctx.font = "30px serif";
ctx.fillText("A", 20, 60);
ctx.fillText("B", 40, 60);
var c2 = document.getElementById("c2");
@notmasteryet
notmasteryet / start.bat
Created December 24, 2011 19:41
Mozilla build environment start file with out Visual Studio check (plus git)
@echo off
SETLOCAL
SET MOZBUILDDIR=%~dp0
SET MOZILLABUILD=%MOZBUILDDIR%
echo "Mozilla tools directory: %MOZBUILDDIR%"
REM Git path
set GIT_ROOT=C:\Program Files\Git
// HTMLElement dataset property
(function checkDatasetProperty() {
var div = document.createElement('div');
if ('dataset' in div)
return; // dataset property exists
Object.defineProperty(HTMLElement.prototype, 'dataset', {
get: function htmlElementDatasetGetter() {
// adding dataset field to the actual object
@notmasteryet
notmasteryet / gist:1436506
Created December 6, 2011 03:02
Some other bad pdfs
per pereba
chrome://pdf.js/content/web/viewer.html?file=http%3A%2F%2Fwww.popcyt.com%2F2210-md4.pdf
other with no portuguese accentuations (í,é,ã,â,à,ç,etc)
chrome://pdf.js/content/web/viewer.html?file=http%3A%2F%2Fwww.salto.sp.gov.br%2Fconcurso_02_2011_gcm_2.pdf
chrome://pdf.js/content/web/viewer.html?file=http%3A%2F%2Fwww.lfg.com.br%2Fconcursodebolsas%2Flista_preliminar_classificao.pdf
@notmasteryet
notmasteryet / pdfjs_webos.diff
Created December 3, 2011 16:33
attempt to fix pdf.js for webOS
diff --git a/src/core.js b/src/core.js
index 284b3cb..b8d5c98 100644
--- a/src/core.js
+++ b/src/core.js
@@ -316,7 +316,7 @@ var Page = (function pagePage() {
startRendering: function pageStartRendering(ctx, callback, textLayer) {
this.ctx = ctx;
this.callback = callback;
- this.textLayer = textLayer;
+ this.textLayer = false && textLayer;
@notmasteryet
notmasteryet / build_jpeg.html
Created September 13, 2011 01:39
Building JPEGs
<!DOCTYPE html>
<html>
<head>
<script>
function buildJpeg(data, components, transform, embed) {
var chunks = [];
// SOI
chunks.push([0xFF, 0xD8]);
// APP12