question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Render whole textLayer without scrolling

See original GitHub issue

Hello!

How do I configure the pdf,js standard viewer to render all pages without waiting for the user to scroll down to the different pages so that pdf.js renders the pages? I know about the possibility to extract the text from the pdf, but I really need the textLayer.

My use case: I need the whole ‘textLayer’ for all pages, because I analyze the words given in the layer and highlight some of them (the ones which satisfy my defined rules) by putting them in a span: <span class="highlight selected">word</span>.

Thank you in advance!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
yurydelendikcommented, Jun 19, 2017

I need the whole ‘textLayer’ for all pages,

See e.g. https://stackoverflow.com/a/40662025/1765767

by putting them in a span: <span class="highlight selected">word</span>.

It’s a small project by itself – you need to modify viewer to modify text layer out to add these spans. There is no easy answer here and you need start looking at the https://github.com/mozilla/pdf.js/blob/master/src/display/text_layer.js and/or https://github.com/mozilla/pdf.js/blob/master/web/text_layer_builder.js to modify that. Good luck.

Closing as answered.

0reactions
mikebeatoncommented, Nov 10, 2017

Thanks @stefanos113. Here’s some working simple example code:

  document.addEventListener('textlayerrendered', function (event) {
    // This generates an event for each text layer once when it is added.
    // You can highlight directly here, e.g. using jquery-highlight library:
    $(event.target).highlight("information");
  });

Perhaps worth pointing out that the approach you and I are both using ignores the highlighting which pdf.js already provides for searches, so there might be a way within the library to ask it to do the highlighting itself, but again I’m not sure how, if at all, at this stage!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent body scrolling but allow overlay scrolling
Problem with this solution is that it only works if overlay is scrollable. If you have a modal and it all fit on...
Read more >
text-rendering - CSS: Cascading Style Sheets - MDN Web Docs
The text-rendering CSS property provides information to the rendering engine about what to optimize for when rendering text.
Read more >
Creating and editing text layers in After Effects - Adobe Support
You can animate the properties of entire text layers or the properties of ... When animating text to move vertically—for scrolling credits, ...
Read more >
Seamless, infinitely scrolling text in After Effects - YouTube
Join me, and experience the joy of seamlessly scrolling text of any duration by using a nested composition and the simple loopOut() ...
Read more >
Scrolling-Aware Rendering to Reduce Frame Rates on ... - MDPI
Frame display process of SurfaceFlinger: (a) layers; (b) frame display flow. ... The pre-rendering is applicable to all the types of views (e.g.,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found