mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Exposes all functional members via lib exports and use them in viewer.
This commit is contained in:
parent
1d12aed5ca
commit
1e3e14e6b2
25 changed files with 174 additions and 102 deletions
|
@ -9,7 +9,7 @@ var queryParams = query ? JSON.parse('{' + query.split('&').map(function (a) {
|
|||
var url = queryParams.file || '../../test/pdfs/liveprogramming.pdf';
|
||||
var scale = +queryParams.scale || 1.5;
|
||||
|
||||
function renderDocument(pdf) {
|
||||
function renderDocument(pdf, svgLib) {
|
||||
var numPages = pdf.numPages;
|
||||
// Using promise to fetch the page
|
||||
|
||||
|
@ -37,7 +37,7 @@ function renderDocument(pdf) {
|
|||
anchor.appendChild(container);
|
||||
|
||||
return page.getOperatorList().then(function (opList) {
|
||||
var svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs);
|
||||
var svgGfx = new svgLib.SVGGraphics(page.commonObjs, page.objs);
|
||||
return svgGfx.getSVG(opList, viewport).then(function (svg) {
|
||||
container.appendChild(svg);
|
||||
});
|
||||
|
@ -49,14 +49,17 @@ function renderDocument(pdf) {
|
|||
|
||||
// In production, the bundled pdf.js shall be used instead of RequireJS.
|
||||
require.config({paths: {'pdfjs': '../../src'}});
|
||||
require(['pdfjs/display/api', 'pdfjs/display/svg'], function (api, svg) {
|
||||
require(['pdfjs/display/api', 'pdfjs/display/svg', 'pdfjs/display/global'],
|
||||
function (api, svg, global) {
|
||||
// In production, change this to point to the built `pdf.worker.js` file.
|
||||
PDFJS.workerSrc = '../../src/worker_loader.js';
|
||||
global.PDFJS.workerSrc = '../../src/worker_loader.js';
|
||||
|
||||
// In production, change this to point to where the cMaps are placed.
|
||||
PDFJS.cMapUrl = '../../external/bcmaps/';
|
||||
PDFJS.cMapPacked = true;
|
||||
global.PDFJS.cMapUrl = '../../external/bcmaps/';
|
||||
global.PDFJS.cMapPacked = true;
|
||||
|
||||
// Fetch the PDF document from the URL using promises.
|
||||
api.getDocument(url).then(renderDocument);
|
||||
api.getDocument(url).then(function (doc) {
|
||||
renderDocument(doc, svg);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue