From 67f7adb68fe133eacff14d16c0aa6278a22d1afc 2014-02-06 22:22:50 From: Brian E. Granger Date: 2014-02-06 22:22:50 Subject: [PATCH] Adding basic append_pdf in OutputArea. --- diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 563565a..6e2e1f5 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -252,6 +252,7 @@ var IPython = (function (IPython) { 'image/svg+xml', 'image/png', 'image/jpeg', + 'application/pdf', 'text/plain' ]; @@ -620,6 +621,17 @@ var IPython = (function (IPython) { }; + OutputArea.prototype.append_pdf = function (pdf, md, element) { + var type = 'application/pdf'; + var toinsert = this.create_output_subarea(md, "output_pdf", type); + var a = $('').attr('href', 'data:application/pdf;base64,'+pdf); + a.attr('target', '_blank'); + a.text('View PDF') + toinsert.append(a); + element.append(toinsert); + return toinsert; + } + OutputArea.prototype.append_latex = function (latex, md, element) { // This method cannot do the typesetting because the latex first has to // be on the page. @@ -807,6 +819,7 @@ var IPython = (function (IPython) { "image/svg+xml" : "svg", "image/png" : "png", "image/jpeg" : "jpeg", + "application/pdf" : "pdf", "text/latex" : "latex", "application/json" : "json", "application/javascript" : "javascript", @@ -818,6 +831,7 @@ var IPython = (function (IPython) { "svg" : "image/svg+xml", "png" : "image/png", "jpeg" : "image/jpeg", + "pdf" : "application/pdf", "latex" : "text/latex", "json" : "application/json", "javascript" : "application/javascript", @@ -830,6 +844,7 @@ var IPython = (function (IPython) { 'image/svg+xml', 'image/png', 'image/jpeg', + 'application/pdf', 'text/plain' ]; @@ -842,6 +857,7 @@ var IPython = (function (IPython) { "text/latex" : OutputArea.prototype.append_latex, "application/json" : OutputArea.prototype.append_json, "application/javascript" : OutputArea.prototype.append_javascript, + "application/pdf" : OutputArea.prototype.append_pdf }; IPython.OutputArea = OutputArea;