Skip to content

Instantly share code, notes, and snippets.

tiarno / gist:8a2995e70cee42f01e79
Last active Mar 15, 2021
find PDF font info with PyPDF2, example code
View gist:8a2995e70cee42f01e79
from PyPDF2 import PdfFileReader
from pprint import pprint
def walk(obj, fnt, emb):
If there is a key called 'BaseFont', that is a font that is used in the document.
If there is a key called 'FontName' and another key in the same dictionary object
that is called 'FontFilex' (where x is null, 2, or 3), then that fontname is
tiarno / iframe_vis.js
Last active Jan 29, 2020
javascript: is element inside an iframe visible within the viewport?
View iframe_vis.js
// Given an iframe id and an anchor id that is present within the iframe,
// determine whether the element is visible/present inside the window viewport.
// This is not about the css 'display' property; this shows whether
// the window viewport contains the element.
var isVisible = function (anchor, iframe_id) {
var ifrId = iframe_id || 'bv_page';
var ifrOffset = window.parent.document.getElementById(ifrId).offsetTop;
var myloc = document.getElementById(anchor).offsetTop + ifrOffset;
var viewtop = window.parent.scrollY;
tiarno / wk_toc.xsl
Created Apr 30, 2019
XSL for Creating an Appendix with wkhtmltopdf
View wk_toc.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
indent="yes" />
<xsl:template match="outline:outline">
tiarno /
Last active Feb 17, 2017
PDF Checking

PDF Testing Gist

These two files, and are code examples to go along with a blog article:

See the article for details on how to test your PDFs for broken internal and external links and for unembedded fonts.

tiarno / enable-local-fonts
Last active Jan 19, 2016 — forked from mpg/enable-local-fonts
Enable fonts from texmf-local using updmap-sys --enable Map
View enable-local-fonts
# Enable fonts from texmf-local using updmap-sys --enable Map
# Manuel Pégourié-Gonnard, 2010; WTFPL v2.
find -H `kpsewhich --var-value TEXMFLOCAL` -name '*.map' | while read file
updmap-sys --nohash --nomkmap --enable Map `basename $file`
tiarno / phantomjs_mathjax.
Created Aug 21, 2013
phantomjs testing script to evaluate a page, wait for a response from MathJax, and close the page. Use in conjunction with mathjax_test.js script; all this does is load the page so any errors flagged from the mathjax_test code is posted to the error database. the two scripts need each other in order to test the file. This script expects a single…
View phantomjs_mathjax.
var url = require('system').args[1];
var page = require('webpage').create();
function waitFor(testFn, onSuccessFn, timeOut) {
var start = new Date().getTime();
var condition = false;
var interval = setInterval(function() {
if ( (new Date().getTime() - start < timeOut) && !condition ) {
condition = testFn();
} else {
tiarno / mathjax_test.js
Created Jul 30, 2013
MathJax testing for TeX and rendering errors. Create HTML page (with math) to include the MathJax library and then include this file. When the page is loaded, the js console will show when errors are encountered and the data about the error will be POSTed via ajax to a rest-type service named here as 'service/mathmltest'. That service should acc…
View mathjax_test.js
function ajaxRequest(){
return new XMLHttpRequest(async=false);
function mltest (){
var filename = window.location.href.substr(window.location.href.lastIndexOf("/")+1);
MathJax.Hub.Config({TeX: {noUndefined: {disabled: true}}});
MathJax.Hub.Queue(function() {console.log('finished rendering');});
MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
console.log('error encountered');
var mydata = {};
tiarno / mathjax_error_flags.html
Last active Dec 20, 2015
JavaScript/MathJax method to flag for errors on a page containing TeX math: Flags for either TeX errors (undefined control sequence) or Math errors (for example, missing brace). Code stolen from a couple of threads on MathJax Users Google Group:!msg/mathjax-users/ct4drdifuyI/h61GSTt_-bAJ…
View mathjax_error_flags.html
<!DOCTYPE html>
<title>Encapsulate Trapping of Math and TeX errors</title>
<script type="text/x-mathjax-config">
// Turn off NoErrors extension
TeX: {noErrors: {disabled: true}}
// Set flag function for TeX Errors (undefined cs)
tiarno / node_cluster.js
Created Feb 18, 2015
NodeJS server receives LaTeX, returns SVG
View node_cluster.js
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
var createServer = function(port) {
var mjAPI = require("node_modules/MathJax-node/lib/mj-single");
MathJax: {
SVG: {
font: "STIX-Web"