Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkirkell/3a0aebf72033b2a96ec1 to your computer and use it in GitHub Desktop.
Save jkirkell/3a0aebf72033b2a96ec1 to your computer and use it in GitHub Desktop.
Crocodoc.addDataProvider('page-offset', function (scope) {
return {
get: function (type, key) {
var $p, dp = scope.getDataProvider(type);
if (type === 'metadata') {
$p = dp.get(type);
return $p.then(function (data) {
data.numpages += 1;
var page,
exceptions = data.dimensions.exceptions,
newExceptions = {};
for (page in exceptions) {
newExceptions[parseInt(page, 10) + 1] = exceptions[page];
}
data.dimensions.exceptions = newExceptions;
return data;
}).promise({
abort: $p.abort
});
} else if (type === 'page-svg' || type === 'page-text') {
key -= 1;
if (key === 0) {
return $.Deferred().resolve('').promise({
abort: function () {}
});
}
return dp.get(type, key);
} else if (type === 'page-img') {
key -= 1;
if (key === 0) {
return $.Deferred().resolve(new Image()).promise({
abort: function () {}
});
}
return dp.get(type, key);
}
}
};
});
.crocodoc-page:first-child {
visibility: hidden !important;
}
var viewer = Crocodoc.createViewer('.container', {
url: '...',
dataProviders: {
metadata: 'page-offset',
'page-svg': 'page-offset',
'page-text': 'page-offset',
'page-img': 'page-offset'
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment