Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make text selectable ? #29

Closed
Vi-dot opened this issue Nov 22, 2016 · 17 comments
Closed

Make text selectable ? #29

Vi-dot opened this issue Nov 22, 2016 · 17 comments

Comments

@Vi-dot
Copy link

Vi-dot commented Nov 22, 2016

Hello,

I don't know if it's because ng2-pdf-viewer use a canvas, but we can't select text in the pdf viewer.
Someone has an idea to make it available ?

Thanks

@VadimDez
Copy link
Owner

Similar to #18

@mmaclach
Copy link
Contributor

i've implemented this in a project, can add as a pr

@Vi-dot
Copy link
Author

Vi-dot commented Nov 24, 2016

Yes please :) Could you do that ? Or push it on your fork

@VadimDez
Copy link
Owner

@mmaclach, sure, that would be great!

@mmaclach
Copy link
Contributor

hey guys, i've added a pr with a solution - I'm not certain it will work for every case

VadimDez added a commit that referenced this issue Dec 1, 2016
@VadimDez VadimDez added this to the 0.1.3 milestone Dec 1, 2016
@Vi-dot
Copy link
Author

Vi-dot commented Dec 2, 2016

Hello !
Thanks for your help mmaclach.
But there is a bug. Selected text doesn't fit well the rendered layer.
screenshot

Can we use the text inside the rendered layer ?
In this demo of pdf.js, you can select text.

@Vi-dot
Copy link
Author

Vi-dot commented Dec 2, 2016

I succeed using pdf_viewer part of pdfjs.
Here is a screenshot
I'm going to clean my fork and make a pull request.

Using this pdf_viewer part is going to help for others issues (like hyperlinks, dynamic zoom..).
We also have to make our fork of @types/pdf.

@mmaclach
Copy link
Contributor

mmaclach commented Dec 2, 2016

hey @Vi-dot - I am using a slightly different configuration in my project so the styling may be slightly off. I think @VadimDez is fixing it in master

@Vi-dot
Copy link
Author

Vi-dot commented Dec 2, 2016

Ok mmaclach,
I guess you took time to achieve that,
But, do you don't think that ? > it's better to use what it's already in pdfjs

It's also better for element accessing in debug mode, because I don't have canvas any more.

@mmaclach
Copy link
Contributor

mmaclach commented Dec 2, 2016

Maybe you're misunderstanding me, this is from pdfjs, using the textContent() from the page and creating svg:text objects. If you wanted to you could create html instead. However I think for some pdf documents the text content may not exist

VadimDez added a commit that referenced this issue Dec 2, 2016
@Vi-dot
Copy link
Author

Vi-dot commented Dec 5, 2016

Hello,
@mmaclach I understood clearly your way. But it's still not perfect, in the example, selection fits not well text.
In fact, from pdfjs you only get raw text. Integration and style are not from pdfjs.

@VadimDez Using PDFPageView solves this and may solve other issues (dynamic update viewport - usefull for big pdf, hyperlinks)
I made a try on this branch. If you like I can make a pull request.

@Vi-dot
Copy link
Author

Vi-dot commented Dec 6, 2016

@mmaclach @VadimDez
I put a demo online to show you : https://vi-dot.github.io/ng2-pdf-viewer/

@VadimDez
Copy link
Owner

VadimDez commented Dec 6, 2016

@Vi-dot Looks great! Is there any way to get it work with fake worker? Would simplify integration.
Thanks a lot, make a PR, so that i can merge it.

@Vi-dot
Copy link
Author

Vi-dot commented Dec 6, 2016

What do you mean by fake worker ?
You may talk about this
PDFJS.workerSrc = 'lib/pdfjs-dist/build/pdf.worker.js';
If it's not defined, it can't work, I tried.

But the PDFPageView way may be not perfect. Now I'm trying to have a dynamic zoom (without reloading pdf), it works, but textLayer disapear with this method.
I opened an issue on pdfjs, PDFJS.PDFViewer may be better. I didn't try yet.

@mmaclach
Copy link
Contributor

mmaclach commented Dec 6, 2016

looks good, I wasn't aware of PDFPageView

@VadimDez
Copy link
Owner

VadimDez commented Dec 6, 2016

@Vi-dot right now it's working with fake worker. I think with PDFJS.disableWorker = true you can enable fake worker, otherwise you have to specify worker, like you did, by providing path for pdf.worker.js.

@dean9812
Copy link

dean9812 commented Feb 17, 2023

  • How to select and copy a text after converted into canvas?. Already tried this '[render-text]="true"'
  • How to avoid right side and bottom gets trim?

Help me out of this. Thanks in advance. @VadimDez @mmaclach @Vi-dot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants