Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
5894bfa
Move API specific compatibility options from `src/shared/compatibilit…
Snuffleupagus Feb 17, 2018
09da99b
Introduce a `AppOptions` abstraction in preparation for a complete re…
Snuffleupagus Feb 17, 2018
81c5509
Move various viewer components options from `PDFJS`/`PDFViewerApplica…
Snuffleupagus Feb 17, 2018
57165af
Move the `defaultUrl` parameter from the `appConfig` and into `AppOpt…
Snuffleupagus Feb 17, 2018
b0956a5
Refactor how the default viewer handles the worker options, by making…
Snuffleupagus Feb 17, 2018
b674409
Move the `maxImageSize` option from the global `PDFJS` object and int…
Snuffleupagus Feb 17, 2018
3c2fbdf
Move the `cMapUrl` and `cMapPacked` options from the global `PDFJS` o…
Snuffleupagus Feb 17, 2018
f3900c4
Move the `isEvalSupported` option from the global `PDFJS` object and …
Snuffleupagus Feb 17, 2018
c7c5835
Move the `disableFontFace` option from the global `PDFJS` object and …
Snuffleupagus Feb 17, 2018
69d7191
Move the `disableAutoFetch` option from the global `PDFJS` object and…
Snuffleupagus Feb 17, 2018
b69abf1
Move the `disableRange` option from the global `PDFJS` object and int…
Snuffleupagus Feb 17, 2018
05c05bd
Move the `disableStream` option from the global `PDFJS` object and in…
Snuffleupagus Feb 17, 2018
1d03ad0
Move the `disableCreateObjectURL` option from the global `PDFJS` obje…
Snuffleupagus Feb 17, 2018
2125538
Move the `pdfBug` option from the global `PDFJS` object and into `get…
Snuffleupagus Feb 17, 2018
4b4fcec
Ensure that we only pass in the necessary parameters when initializin…
Snuffleupagus Feb 17, 2018
b8606ab
[api-major] Completely remove the global `PDFJS` object
Snuffleupagus Feb 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/acroforms/acroforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

'use strict';

PDFJS.GlobalWorkerOptions.workerSrc =
pdfjsDistBuildPdf.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.js';

var DEFAULT_URL = '../../test/pdfs/f1040.pdf';
Expand All @@ -24,20 +24,20 @@ var DEFAULT_SCALE = 1.0;
var container = document.getElementById('pageContainer');

// Fetch the PDF document from the URL using promises.
PDFJS.getDocument(DEFAULT_URL).then(function (doc) {
pdfjsDistBuildPdf.getDocument(DEFAULT_URL).then(function (doc) {
// Use a promise to fetch and render the next page.
var promise = Promise.resolve();

for (var i = 1; i <= doc.numPages; i++) {
promise = promise.then(function (pageNum) {
return doc.getPage(pageNum).then(function (pdfPage) {
// Create the page view.
var pdfPageView = new PDFJS.PDFPageView({
var pdfPageView = new pdfjsDistWebPdfViewer.PDFPageView({
container: container,
id: pageNum,
scale: DEFAULT_SCALE,
defaultViewport: pdfPage.getViewport(DEFAULT_SCALE),
annotationLayerFactory: new PDFJS.DefaultAnnotationLayerFactory(),
annotationLayerFactory: new pdfjsDistWebPdfViewer.DefaultAnnotationLayerFactory(),
renderInteractiveForms: true,
});

Expand Down
6 changes: 3 additions & 3 deletions examples/browserify/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

// Hello world example for browserify.

require('pdfjs-dist');
var pdfjsLib = require('pdfjs-dist');

var pdfPath = '../helloworld/helloworld.pdf';

// Setting worker path to worker bundle.
PDFJS.GlobalWorkerOptions.workerSrc =
pdfjsLib.GlobalWorkerOptions.workerSrc =
'../../build/browserify/pdf.worker.bundle.js';

// Loading a document.
var loadingTask = PDFJS.getDocument(pdfPath);
var loadingTask = pdfjsLib.getDocument(pdfPath);
loadingTask.promise.then(function (pdfDocument) {
// Request a first page
return pdfDocument.getPage(1).then(function (pdfPage) {
Expand Down
20 changes: 12 additions & 8 deletions examples/components/pageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@

'use strict';

if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
if (!pdfjsDistBuildPdf.getDocument || !pdfjsDistWebPdfViewer.PDFPageView) {
alert('Please build the pdfjs-dist library using\n' +
' `gulp dist-install`');
}

// The workerSrc property shall be specified.
//
PDFJS.GlobalWorkerOptions.workerSrc =
pdfjsDistBuildPdf.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.js';

// Some PDFs need external cmaps.
//
// PDFJS.cMapUrl = '../../node_modules/pdfjs-dist/cmaps/';
// PDFJS.cMapPacked = true;
var CMAP_URL = '../../node_modules/pdfjs-dist/cmaps/';
var CMAP_PACKED = true;

var DEFAULT_URL = '../../web/compressed.tracemonkey-pldi-09.pdf';
var PAGE_TO_VIEW = 1;
Expand All @@ -37,18 +37,22 @@ var SCALE = 1.0;
var container = document.getElementById('pageContainer');

// Loading document.
PDFJS.getDocument(DEFAULT_URL).then(function (pdfDocument) {
pdfjsDistBuildPdf.getDocument({
url: DEFAULT_URL,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
}).then(function(pdfDocument) {
// Document loaded, retrieving the page.
return pdfDocument.getPage(PAGE_TO_VIEW).then(function (pdfPage) {
// Creating the page view with default parameters.
var pdfPageView = new PDFJS.PDFPageView({
var pdfPageView = new pdfjsDistWebPdfViewer.PDFPageView({
container: container,
id: PAGE_TO_VIEW,
scale: SCALE,
defaultViewport: pdfPage.getViewport(SCALE),
// We can enable text/annotations layers, if needed
textLayerFactory: new PDFJS.DefaultTextLayerFactory(),
annotationLayerFactory: new PDFJS.DefaultAnnotationLayerFactory()
textLayerFactory: new pdfjsDistWebPdfViewer.DefaultTextLayerFactory(),
annotationLayerFactory: new pdfjsDistWebPdfViewer.DefaultAnnotationLayerFactory(),
});
// Associates the actual page with the view, and drawing it
pdfPageView.setPdfPage(pdfPage);
Expand Down
22 changes: 13 additions & 9 deletions examples/components/simpleviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@

'use strict';

if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
if (!pdfjsDistBuildPdf.getDocument || !pdfjsDistWebPdfViewer.PDFViewer) {
alert('Please build the pdfjs-dist library using\n' +
' `gulp dist-install`');
}

// The workerSrc property shall be specified.
//
PDFJS.GlobalWorkerOptions.workerSrc =
pdfjsDistBuildPdf.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.js';

// Some PDFs need external cmaps.
//
// PDFJS.cMapUrl = '../../node_modules/pdfjs-dist/cmaps/';
// PDFJS.cMapPacked = true;
var CMAP_URL = '../../node_modules/pdfjs-dist/cmaps/';
var CMAP_PACKED = true;

var DEFAULT_URL = '../../web/compressed.tracemonkey-pldi-09.pdf';
var SEARCH_FOR = ''; // try 'Mozilla';

var container = document.getElementById('viewerContainer');

// (Optionally) enable hyperlinks within PDF files.
var pdfLinkService = new PDFJS.PDFLinkService();
var pdfLinkService = new pdfjsDistWebPdfViewer.PDFLinkService();

var pdfViewer = new PDFJS.PDFViewer({
var pdfViewer = new pdfjsDistWebPdfViewer.PDFViewer({
container: container,
linkService: pdfLinkService,
});
pdfLinkService.setViewer(pdfViewer);

// (Optionally) enable find controller.
var pdfFindController = new PDFJS.PDFFindController({
pdfViewer: pdfViewer
var pdfFindController = new pdfjsDistWebPdfViewer.PDFFindController({
pdfViewer: pdfViewer,
});
pdfViewer.setFindController(pdfFindController);

Expand All @@ -60,7 +60,11 @@ container.addEventListener('pagesinit', function () {
});

// Loading document.
PDFJS.getDocument(DEFAULT_URL).then(function (pdfDocument) {
pdfjsDistBuildPdf.getDocument({
url: DEFAULT_URL,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
}).then(function(pdfDocument) {
// Document loaded, specifying document for the viewer and
// the (optional) linkService.
pdfViewer.setDocument(pdfDocument);
Expand Down
22 changes: 13 additions & 9 deletions examples/components/singlepageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@

'use strict';

if (!PDFJS.PDFSinglePageViewer || !PDFJS.getDocument) {
if (!pdfjsDistBuildPdf.getDocument || !pdfjsDistWebPdfViewer.PDFSinglePageViewer) {
alert('Please build the pdfjs-dist library using\n' +
' `gulp dist-install`');
}

// The workerSrc property shall be specified.
//
PDFJS.GlobalWorkerOptions.workerSrc =
pdfjsDistBuildPdf.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.js';

// Some PDFs need external cmaps.
//
// PDFJS.cMapUrl = '../../node_modules/pdfjs-dist/cmaps/';
// PDFJS.cMapPacked = true;
var CMAP_URL = '../../node_modules/pdfjs-dist/cmaps/';
var CMAP_PACKED = true;

var DEFAULT_URL = '../../web/compressed.tracemonkey-pldi-09.pdf';
var SEARCH_FOR = ''; // try 'Mozilla';

var container = document.getElementById('viewerContainer');

// (Optionally) enable hyperlinks within PDF files.
var pdfLinkService = new PDFJS.PDFLinkService();
var pdfLinkService = new pdfjsDistWebPdfViewer.PDFLinkService();

var pdfSinglePageViewer = new PDFJS.PDFSinglePageViewer({
var pdfSinglePageViewer = new pdfjsDistWebPdfViewer.PDFSinglePageViewer({
container: container,
linkService: pdfLinkService,
});
pdfLinkService.setViewer(pdfSinglePageViewer);

// (Optionally) enable find controller.
var pdfFindController = new PDFJS.PDFFindController({
pdfViewer: pdfSinglePageViewer
var pdfFindController = new pdfjsDistWebPdfViewer.PDFFindController({
pdfViewer: pdfSinglePageViewer,
});
pdfSinglePageViewer.setFindController(pdfFindController);

Expand All @@ -60,7 +60,11 @@ container.addEventListener('pagesinit', function () {
});

// Loading document.
PDFJS.getDocument(DEFAULT_URL).then(function (pdfDocument) {
pdfjsDistBuildPdf.getDocument({
url: DEFAULT_URL,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
}).then(function(pdfDocument) {
// Document loaded, specifying document for the viewer and
// the (optional) linkService.
pdfSinglePageViewer.setDocument(pdfDocument);
Expand Down
4 changes: 2 additions & 2 deletions examples/learning/helloworld.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ <h1>'Hello, world!' example</h1>
//
// The workerSrc property shall be specified.
//
PDFJS.GlobalWorkerOptions.workerSrc =
pdfjsDistBuildPdf.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.js';

//
// Asynchronous download PDF
//
PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf) {
pdfjsDistBuildPdf.getDocument(url).then(function getPdfHelloWorld(pdf) {
//
// Fetch the first page
//
Expand Down
4 changes: 2 additions & 2 deletions examples/learning/helloworld64.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ <h1>'Hello, world!' example</h1>
//
// The workerSrc property shall be specified.
//
PDFJS.GlobalWorkerOptions.workerSrc =
pdfjsDistBuildPdf.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.js';

// Opening PDF by passing its binary data as a string. It is still preferable
// to use Uint8Array, but string or array-like structure will work too.
PDFJS.getDocument({data: pdfData}).then(function getPdfHelloWorld(pdf) {
pdfjsDistBuildPdf.getDocument({data: pdfData}).then(function getPdfHelloWorld(pdf) {
// Fetch the first page.
pdf.getPage(1).then(function getPageHelloWorld(page) {
var scale = 1.5;
Expand Down
6 changes: 3 additions & 3 deletions examples/learning/prevnext.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ <h1>'Previous/Next' example</h1>
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
// shall be specified.
//
// PDFJS.GlobalWorkerOptions.workerSrc =
// '../../node_modules/pdfjs-dist/build/pdf.worker.js';
pdfjsDistBuildPdf.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.js';

var pdfDoc = null,
pageNum = 1,
Expand Down Expand Up @@ -117,7 +117,7 @@ <h1>'Previous/Next' example</h1>
/**
* Asynchronously downloads PDF.
*/
PDFJS.getDocument(url).then(function (pdfDoc_) {
pdfjsDistBuildPdf.getDocument(url).then(function (pdfDoc_) {
pdfDoc = pdfDoc_;
document.getElementById('page_count').textContent = pdfDoc.numPages;

Expand Down
Loading