Comments (3)
Hi,
the library does not include any utility for searching, but it is easy to implement (as it does the find controller):
Assuming that you have something like this: let pdfViewer = new PDFjsViewer(...)
, it is possible to extract the text from the pages and search it to identify in which page(s) is found the text:
for (iPage = 0; iPage < pdfViewer.pdf.numPages; iPage++) {
let currentPage = await pdfViewer.pdf.getPage(iPage + 1);
let currentText = await currentPage.getTextContent();
let buffer = [];
for (let item of currentText.items) {
buffer.push(item.str);
if (item.hasEOL) { buffer.push("\n"); }
}
let textInThePage = buffer.join("");
/** search the text in the page */
}
from pdfjs-viewer.
I guess knowing if text is on a page is one thing (to be able to bring up a page on which the text appears), showing it highlighted on-screen is another. Early versions of pdfjs (which I have been using) had an overlayed text layer that sat on top of the canvas, perhaps V3.x that I am using doesn't do that any more, as I cannot click and select anything on the screen (it is just a canvas without anything overlaid). Not a critical function perhaps.
One other question for you: Right now the text displayed is pretty fuzzy, just not great resolution, and not as good as the pdfjs 1.x I have been using. This might be out of the basic context of your viewer, but is there a quick tweak I can make to the _renderPage function in the viewer JS to make the text sharper, even if it adds to memory usage? I am using the CDN-based pdfjs code, so I can't just tweak that code. Is it the renderContext object that can be changed to be similar to what is in the pdfjs viewer file?
from pdfjs-viewer.
Hi, you are right. The resolution was poor and now I have included a parameter renderingScale
for the viewer. It defaults to 1.5 so that it gets a better resolution.
Please try the latest version in the CDN, as it should include the updates.
(*) requesting version 1.1 does not work for me now... maybe the cache of the CDN will update soon. In the meanwhile you can try the specific version 1.1.2: https://cdn.jsdelivr.net/gh/dealfonso/[email protected]/pdfjs-viewer.js
from pdfjs-viewer.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfjs-viewer.