-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Wrong value when loading field values from annotationStorage #17046
Comments
That version is no longer supported, please find the latest releases at https://mozilla.github.io/pdf.js/getting_started/#download |
Note that in the example After checking customValues[id] = annotationStorage.getValue(id, {})
customValues[id].formattedValue = customValues[id].value; And works just fine PS: I will try in the latest version soon |
A text field has 2 values: the one entered by the user, e.g. 123 (userValue or value), and the one displayed when the field is unfocused, e.g. 123,00€ (formattedValue). |
Shouldn't then If no, setting |
Yes maybe... |
Then I would say pdf.js/src/display/annotation_layer.js Lines 1201 to 1202 in 3072efa
let fieldFormattedValues =
storedData.formattedValue || storedData.value || this.data.textContent?.join("\n") || null; And these both pdf.js/src/display/annotation_layer.js Line 1217 in 3072efa
pdf.js/src/display/annotation_layer.js Line 1224 in 3072efa
fieldFormattedValues
I don't think this could be reproduced in Firefox PDF Viewer. If you don't think this has to be changed I think I can go with setting |
|
I believe that default values (formatted or not) shouldn't take precedence over For example, on user input: pdf.js/src/display/annotation_layer.js Lines 1245 to 1254 in 3072efa
elementData.formattedValue is set to null to prevent exactly this (in case formattedValue is not updated by the PDF)
Anyway, I will go with setting |
Attach (recommended) or Link to PDF file here:
test_form.pdf
Configuration:
Steps to reproduce the problem:
viewer.html
and add the following code to set values inannotationStorage
before rendering.What is the expected behavior? (add screenshot)
![image](https://private-user-images.githubusercontent.com/16489902/271313721-ab87f081-303c-4dd4-a5c9-a66404b835b8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTY4NDgsIm5iZiI6MTczODk5NjU0OCwicGF0aCI6Ii8xNjQ4OTkwMi8yNzEzMTM3MjEtYWI4N2YwODEtMzAzYy00ZGQ0LWE1YzktYTY2NDA0YjgzNWI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA2MzU0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQxMGU5MDNjMTdjOTAxMzEyY2MxYWEzMTA5M2RjNjE2YmU0ZGI1MGIzMzQ0MjkxNDhkNTYyZDQzNzhkNjQ0NWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.eFEqfpPA9J4sTAnafhsm2iLlvhYiaTO32Jq0t47K0EY)
(Ignore field background colors, that was set for testing)
Set the value from annotationStorage
What went wrong? (add screenshot)
![image](https://private-user-images.githubusercontent.com/16489902/271312857-c8ecd0c5-655c-4891-972d-b4d6a2c08b16.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTY4NDgsIm5iZiI6MTczODk5NjU0OCwicGF0aCI6Ii8xNjQ4OTkwMi8yNzEzMTI4NTctYzhlY2QwYzUtNjU1Yy00ODkxLTk3MmQtYjRkNmEyYzA4YjE2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA2MzU0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM1OTlhY2ViZDk1YmQxYzhhMWJmNmQ1YmI0MzYxNTc0OTZiMzVlZTljZDFlMGRkN2UzZWE0MjBlYWI4NjllNTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.eVtDz7yZVtvsTFMwZQT31LRcleWiToLoBdBATyaTuFA)
![image](https://private-user-images.githubusercontent.com/16489902/271313554-875965a2-75a0-43ce-b6ac-0b82f795cb22.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTY4NDgsIm5iZiI6MTczODk5NjU0OCwicGF0aCI6Ii8xNjQ4OTkwMi8yNzEzMTM1NTQtODc1OTY1YTItNzVhMC00M2NlLWI2YWMtMGI4MmY3OTVjYjIyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA2MzU0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM3NTRlZWVjNmNjZDFhMWJmNDMyOWQzNGExYmM2OGQwNmI2NWY1ZWM4Mzg2OGZiYzZlYmZkN2Q5NDdjODU4OWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.xFmCrJmEqKCYS3ESJgGOoZNvfVERYbqSFOx7C6-JfiQ)
(Ignore field background colors, that was set for testing)
Text field does not load correctly annotationStorage value:
On
focus
it does set the correct value but if I do not change it, sets back the default value onblur
Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):
The text was updated successfully, but these errors were encountered: