Skip to content

Commit

Permalink
New: Turn on rendering of interactive forms (#349)
Browse files Browse the repository at this point in the history
This enables rendering of content within interactive forms
  • Loading branch information
tonyjin authored Aug 30, 2017
1 parent 53fa9f5 commit 77a38a0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/viewers/doc/DocBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,13 @@ class DocBaseViewer extends BaseViewer {
initViewer(pdfUrl) {
this.bindDOMListeners();

// Initialize PDF.js in container
// Initialize pdf.js in container
this.pdfViewer = new PDFJS.PDFViewer({
container: this.docEl,
linkService: new PDFJS.PDFLinkService(),
// Enhanced text selection uses more memory, so disable on mobile
enhanceTextSelection: !this.isMobile
enhanceTextSelection: !this.isMobile,
renderInteractiveForms: true
});

// Use chunk size set in viewer options if available
Expand Down
34 changes: 34 additions & 0 deletions src/lib/viewers/doc/__tests__/DocBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,40 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => {
stubs.emit = sandbox.stub(docBase, 'emit');
});

it('should turn on enhanced text selection if not on mobile and turn on rendering of interactive forms', () => {
docBase.options.location = {
locale: 'en-US'
};
docBase.isMobile = false;
sandbox.stub(PDFJS, 'getDocument').returns(Promise.resolve({}));

docBase.initViewer('');

expect(stubs.pdfViewerStub).to.be.calledWith({
container: sinon.match.any,
linkService: sinon.match.any,
enhanceTextSelection: true,
renderInteractiveForms: true
});
});

it('should turn off enhanced text selection if on mobile', () => {
docBase.options.location = {
locale: 'en-US'
};
docBase.isMobile = true;
sandbox.stub(PDFJS, 'getDocument').returns(Promise.resolve({}));

docBase.initViewer('');

expect(stubs.pdfViewerStub).to.be.calledWith({
container: sinon.match.any,
linkService: sinon.match.any,
enhanceTextSelection: false,
renderInteractiveForms: true
});
});

it('should set a chunk size based on viewer options if available', () => {
const url = 'url';
const rangeChunkSize = 100;
Expand Down

0 comments on commit 77a38a0

Please sign in to comment.