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

error in validating Telephone number entry in pdf text field #1146

Closed
joelvargheseg opened this issue Jan 26, 2022 · 19 comments
Closed

error in validating Telephone number entry in pdf text field #1146

joelvargheseg opened this issue Jan 26, 2022 · 19 comments
Assignees
Labels
bug of the base viewer (Mozilla's pdf.js) Please open the ticket at https://github.com/mozilla/pdf.js/issues bug Something isn't working Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. Original topic solved - ticket contains followup The original problem has been solved. However, as discussions go, a new issue has been raised. Solved

Comments

@joelvargheseg
Copy link

joelvargheseg commented Jan 26, 2022

while editing a phone number text field in my pdf, I couldn't enter the number because the popup will always appear when I type in the number as provided in the screenshot. if I try to enter in the format (123) 456-7890, I cannot enter both closing brackets")" or "-".
so the user cannot even enter a 10 digit number in any way. I tried it in pdf.js and I can enter the number if I provide the number exactly in the format provided by them. I'm using version 10.1.0 of your viewer in bleeding edge, also I tried to do the latest version in pdfviewer.net. Nothing works
20220126_114056
.

you can try to fill-up the form attached to see yourself. thanks
PdfValidationTest.pdf

@stephanrauh stephanrauh self-assigned this Jan 26, 2022
@stephanrauh stephanrauh added the bug Something isn't working label Jan 26, 2022
@stephanrauh
Copy link
Owner

Sounds nasty! I'll have a look at it. Please give me a couple of day - currently I'm very busy, so I can't promise a fast response. At first glance, you've provided the test PDF, so I'm positive I can reproduce the issue. Awesome!

Best regards,
Stephan

@joelvargheseg
Copy link
Author

hello @stephanrauh , do you have any update for this bug?

@stephanrauh
Copy link
Owner

Oops, sorry. At the moment, new bugs and support question come in faster than I can solve them. It's high time I find volunteers helping me!

@stephanrauh
Copy link
Owner

I've just opened your PDF in Chrome, and it shows the same behavior. Which rules does the PDF file check, exactly? I suspect ngx-extended-pdf-viewer is doing everything correctly, it's just a faulty validation rule in the PDF. So let's check this first!

image

@joelvargheseg
Copy link
Author

this is the format I'm using created from PDF pro.
image

the issue is if we add any 10 digit number like
1234567890 in chrome it will convert to the format (123) 556-7890
so basically it will convert
try entering 1234567890 in the pdf-extended viewer.
you cannot enter all digits
and also try to enter in the format (123) 556-7890
you cannot enter ")" , " " and "-"

thanks. hope this helps.

@stephanrauh
Copy link
Owner

@timvandermeij Joel reports that it's impossible to enter a phone number in pdf.js if it's defined as a phone number field.

@joelvargheseg I've managed to reproduce your bug, and I've also managed to reproduce it on https://mozilla.github.io/pdf.js/web/viewer.html. So I suppose it's a pdf.js bug.

I've found a constant defining regular expressions for phone number. It looks promising:

 RE_PHONE_ENTRY: [
    // 555-1234 or 408 555-1234
    "\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
    // (408
    "\\(\\d{0,3}",
    // (408) 555-1234
    // (allow the addition of parens as an afterthought)
    "\\(\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
    // (408 555-1234
    "\\(\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
    // 408) 555-1234
    "\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
    // international
    "011(\\.|[- \\d])*",
  ]

A few lines after that, there's a stricter rule validating the phone number when you're leaving the field. So I guess the validation entered the "commit" mode too early.

@stephanrauh stephanrauh added bug of the base viewer (Mozilla's pdf.js) Please open the ticket at https://github.com/mozilla/pdf.js/issues Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. labels Feb 11, 2022
@timvandermeij
Copy link

timvandermeij commented Feb 13, 2022

Hm, it looks very closely related to mozilla/pdf.js#14306 which was fixed by mozilla/pdf.js#14429 and mozilla/pdf.js#14430 not too long ago, but if it still happens on the master version apparently there's another issue here. I'd recommend opening an issue for this in the PDF.js repository.

@joelvargheseg
Copy link
Author

So there is no fix in ngx-extended-pdf-viewer? this is kinda serious bug that I'm facing right now. will you follow up in PDF.js repo? thanks

@stephanrauh
Copy link
Owner

At the moment, there's no fix in ngx-extended-pdf-viewer, unless Tim is right and they've already fixed this bug. But I don't think so, because my "bleeding edge" branch is sort of a nightly build, and I've merged the source this Friday.

However, I intend to do some debugging. Maybe it's easy to solve. If it is, I can fix the bug in my branch of pdf.js and kindly ask the Mozilla team to fix it, too. However, I almost always had bad luck when I reported bugs to the pdf.js team in the past, so I can't promise much (apart from trying to fix the bug myself).

@stephanrauh
Copy link
Owner

@joelvargheseg In the meantime, I've updated to pdf.js 2.13 as default branch and 2.14 as "bleeding edge" branch. Can you check if the current version of ngx-extended-pdf-viewer solves the issue?

@joelvargheseg
Copy link
Author

hello. I checked the new version but now its strictly following the format "(111) 111-1111" which is not an ideal situation.
the users will get annoyed if he/she didn't enter exactly as provided. can we implement like a loosely editable field such as when we enter 1111111111 and the field will automatically convert it to (111) 111-1111 as provided by all the browser pdf viewer? can we implement that in this viewer?

@stephanrauh
Copy link
Owner

@calixteman You're the expert here. Joel has a Acroform with a telephone number. The format of the field is (111) 111-1111. However, as a user, I want to be able to enter just the digits and let the computer add the special character. Does this make sense to implement such a feature in pdf.js? If it does, would you (or your team) like to do that?

Thanks in advance,
Stephan

@stephanrauh stephanrauh added Original topic solved - ticket contains followup The original problem has been solved. However, as discussions go, a new issue has been raised. Solved labels Apr 4, 2022
@calixteman
Copy link

What are doing Acrobat, Chrome, ... with such a phone number ?
Could you attach a pdf here ?

@stephanrauh
Copy link
Owner

@joelvargheseg Did you check that?

@joelvargheseg
Copy link
Author

joelvargheseg commented Apr 4, 2022

PdfValidationTest.pdf
yes I did. if you try to open the pdf I attached with google or acrobat. in the phone number field you can enter just numbers and it will be converted to the correct format.
example,
if you enter 1234567890
it will convert to (123) 456-7890

@calixteman
Copy link

Ok this is a bug in the implementation. Would you mind to file a bug upstream please ?

@stephanrauh
Copy link
Owner

@stephanrauh
Copy link
Owner

I'm closing the ticket now because it has to be solved in pdf.js.

@joelvargheseg
Copy link
Author

joelvargheseg commented Apr 16, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug of the base viewer (Mozilla's pdf.js) Please open the ticket at https://github.com/mozilla/pdf.js/issues bug Something isn't working Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. Original topic solved - ticket contains followup The original problem has been solved. However, as discussions go, a new issue has been raised. Solved
Projects
None yet
Development

No branches or pull requests

4 participants