Skip to content

Instantly share code, notes, and snippets.

View brendandahl's full-sized avatar

Brendan Dahl brendandahl

  • Google
  • San Francisco, CA
View GitHub Profile
@brendandahl
brendandahl / gist:1953439
Created March 1, 2012 21:43 — forked from jviereck/gist:1944694
About Printing On The Web

Version: 29-Feb-2012
Author: Julian Viereck <jviereck (dot) dev (at) googlemail (dot) com>

About Printing On The Web

tl;dr: Printing on the web is very limited. There is CSS3 Paged Media "Last Call" spec, that improves things, but has not been adopted by browsers yet. How about creating a new "WebPrintAPI" that does not use the DOM but is more like a simple canvas API? Would such a simple API be helpful for your printing needs on the web, or is it just suitable for very special use cases like PDF.JS?

About this document

This document is intended to sum up the current state of printing using the open web platform. It should serve as a foundation for discussion on how to get proper printing support added to the PDF.JS project (adding printing support is tracked here).

@brendandahl
brendandahl / f1040.otf.base64
Created March 6, 2012 23:44
Failing CID Font
data:font/opentype;base64,T1RUTwAJAIAAAwAQQ0ZGIGMPZ3YAAACcAAACVk9TLzJD0CsGAAAC9AAAAGBjbWFw4ObhHQAAA1QAAABCaGVhZKsnT1UAAAOYAAAANmhoZWEC/wHkAAAD0AAAACRobXR4AAAAAAAAA/QAAAAQbWF4cAAEUAAAAAQEAAAABm5hbWXnhlCzAAAEDAAAAoJwb3N0AAMAAAAABpAAAAAgAQAEAgABAQEjTU1YUURRK1VuaXZlcnNhbFN0ZC1OZXdzd2l0aENvbW1QaQABAQE3+B0B+BcEhPt3+nH5kAUdAAACKA8dAAABnRH4HgwV+Bv4HIsMHu8MIh0AAAIvDCQdAAACUQwlAAUCAAEABgAOAP8BDAEnQWRvYmVJZGVudGl0eUNvcHlyaWdodCAxOTg4LCAxOTk1LCAyMDAyICwgMjAwM0Fkb2JlIFN5c3RlbXMgSW5jb3Jwb3JhdGVkLiBBbGwgUmlnaHRzIFJlc2VydmVkLiBVbml2ZXJzYWwgaXMgYSB0cmFkZW1hcmsgb2YgSGVpZGVsYmVyZ2VyIERydWNrbWFzY2hpbmVuIEFHLCBleGNsdXNpdmVseSBsaWNlbnNlZCB0aHJvdWdoIExpbm90eXBlIExpYnJhcnkgR21iSCwgYW5kIG1heSBiZSByZWdpc3RlcmVkIGluIGNlcnRhaW4ganVyaXNkaWN0aW9ucy4vRlNUeXBlIDQgZGVmVW5pdmVyc2FsU3RkLU5ld3N3aXRoQ29tbVBpAAAABAEBTlFqhPiIi7347L0Bi734JL0DiwT4iPlQ/IgG9477xRX7PveTBffoBvsg+8AV9z73kwX8kgf8Bl4V9z73k/c++5MF/Ab4vxX3PvuT+z77kwUO96wO+nz7cvpkAZf6ZAP6cPeeFf5k+HwF/mQHDvp8+2j6ZAGX+mQD+nD7aBX8fPpk/Hz+ZAUOAAABAGEAYwABAQEQHQAAAA4dAAACQxL4Hwwmi4v5iYsG+3eLB7sKuw
@brendandahl
brendandahl / gist:2038213
Created March 14, 2012 17:53
pdf.js stats format
[
{
"browser": "firefox",
"page": 1,
"pdf": "tracemonkey-eq",
"round": 0,
"stats": [
{
"end": 1331675927704,
"name": "Page Request",
@brendandahl
brendandahl / rta.md
Created April 9, 2012 16:39
Ready to Assemble Design Pattern

Ready to Assemble Design Pattern

IKEA Furniture Design Pattern (Assembly Service Included)

Motivation:

In pdf.js we need to do as much processing as possible in the worker thread. The result of this work is then often used in the main thread to rebuild an object. There is currently no consistent way to do this.

Ready to Assemble Furniture Process:

Producer

@brendandahl
brendandahl / gist:2579276
Created May 2, 2012 19:01
Change Channel Owner
// Keep the URL the same so the browser sees it as the same.
channel.originalURI = aRequest.URI;
channel.asyncOpen(proxy, aContext);
var securityManager = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
log('got secruity manager!');
var uri = ioService.newURI('resource://pdf.js/web/viewer.html', null, null);
var principal = securityManager.getCodebasePrincipal(uri);
log('created principal!');
channel.owner = principal;
log('hey we changed the owner!');
@brendandahl
brendandahl / proxyctx.js
Created July 25, 2012 18:33
Proxy Canvas
var Proxy2dContext = function() {
this.actions = [];
this.deps = {};
};
Proxy2dContext.prototype = {
callFunction: function(method, args) {
// convert args to real array
args = Array.prototype.slice.call(args);
this.actions.push([0, method, args]);
},
@brendandahl
brendandahl / gist:3373993
Created August 16, 2012 22:00
Check Messages Between Web Workers
var path = [];
function check(obj) {
if (typeof obj === 'object') {
for (key in obj) {
if (!obj.hasOwnProperty)
continue;
if (!obj.hasOwnProperty(key))
continue;
var nextObj = obj[key];
if (nextObj instanceof Dict || nextObj instanceof XRef) {
@brendandahl
brendandahl / example.html
Created September 18, 2012 17:30
mozPrintCallback
<!DOCTYPE html>
<html>
<head>
<title>mozPrintCallback</title>
</head>
<body>
<canvas id="canvas" width="200" height="200"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
canvas.mozPrintCallback = function(printState) {
@brendandahl
brendandahl / go.sh
Created October 2, 2012 17:30
Build pdf.js and Copy to Gaia
#!/bin/sh
pushd .;
cd ~/projects/mine/pdf.js
node make b2g
cp -R ~/projects/mine/pdf.js/build/b2g/content ~/projects/mine/gaia/apps/pdfjs/;
cd ~/projects/mine/gaia
rm -rf profile
make
/Applications/B2G.app/Contents/MacOS/b2g -jsconsole -profile ~/projects/mine/gaia/profile/
popd;
@brendandahl
brendandahl / sbw.diff
Created October 15, 2012 16:22
sbw support
diff --git a/src/core.js b/src/core.js
index 8e07078..3fa7d6f 100644
--- a/src/core.js
+++ b/src/core.js
@@ -110,7 +110,9 @@ var Page = (function PageClosure() {
return shadow(this, 'mediaBox', obj);
},
get view() {
+ var userUnit = this.inheritPageProp('UserUnit');
var mediaBox = this.mediaBox;