Replies: 1 comment
-
Hi! Nice I found the right discussion, the new version is perfect and no react-pdf/src/Page/TextLayer.jsx Line 198 in df990a7 with something like this, append my on controlled DOM // child.innerHTML = content;
// Still allow update of e.g. an empty string (if wanted),
// but if you just return, no update of innerHTML is needed (if the item.str is empty)
if(typeof content !== 'undefined' && content !== null){
if(typeof content === 'string'){
child.textContent = content;
} else if(content instanceof Element){ // && !child.contains(content)) {
// New way
if(child.replaceChildren){ child.replaceChildren(content); }
else {
// Old way
while (child.firstChild) { child.removeChild(child.lastChild); }
child.appendChild(content);
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
In #944, I'm replacing our custom TextLayer implementation with PDF.js's one. This has a number of benefits outlined in the PR description.
However, one thing appears to be particularly challenging, and that is keeping
customTextRenderer
ability to render React elements. Here are the possibilities:customTextRenderer
altogether, and implementing something else as a replacement (e.g. an easy way to mark search results)customTextRenderer
without the ability to render React elementscustomTextRenderer
with ability to render React elements, but at a cost of usingReactDOMServer.renderToStaticMarkup
, which would add roughly 37 KB to your bundleWhat would be the best approach?
Beta Was this translation helpful? Give feedback.
All reactions