forked from mozilla/pdf.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve copy/paste by inserting spaces into textChunks if we deem it …
…appropriate. Add test re same. PR mozilla#5783.
- Loading branch information
speedplane
committed
Mar 4, 2015
1 parent
fa0f09b
commit 03fae4b
Showing
5 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,3 +118,4 @@ | |
!issue5481.pdf | ||
!issue5567.pdf | ||
!issue5701.pdf | ||
!US6205527_page1.pdf |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | ||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ | ||
/* globals PDFJS, expect, it, describe, Promise, combineUrl, waitsFor, | ||
isArray, MissingPDFException */ | ||
|
||
'use strict'; | ||
|
||
function waitsForPromiseResolved(promise, successCallback) { | ||
var data; | ||
promise.then(function(val) { | ||
data = val; | ||
successCallback(data); | ||
}, | ||
function(error) { | ||
// Shouldn't get here. | ||
expect(false).toEqual(true); | ||
}); | ||
waitsFor(function() { | ||
return data !== undefined; | ||
}, 20000); | ||
} | ||
|
||
describe('text-extract', function() { | ||
var pdfURL = combineUrl(window.location.href, '../pdfs/US6205527_page1.pdf'); | ||
var resolvePromise; | ||
var pagePromise = new Promise(function (resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
PDFJS.getDocument(pdfURL).then(function(doc) { | ||
doc.getPage(1).then(function(data) { | ||
resolvePromise(data); | ||
}); | ||
}); | ||
var page; | ||
waitsForPromiseResolved(pagePromise, function(data) { | ||
page = data; | ||
}); | ||
it('gets text content', function () { | ||
waitsForPromiseResolved(pagePromise, function (data) { | ||
var textPromise = page.getTextContent(); | ||
waitsForPromiseResolved(textPromise, function (data) { | ||
expect(!!data.items).toEqual(true); | ||
var text = data.items.map(function (d) { return d.str; }).join(''); | ||
// Make sure the text is ordered properly. | ||
expect(text.indexOf('Disclosed is an apparatus, a system, a') > 0) | ||
.toEqual(true); | ||
expect(text.indexOf('device to the computer system; (b) preparing ' + | ||
'a storage. media of the peripheral storage') > 0).toEqual(true); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters