Automatic profile image preview
https://plan.tugraz.at/project/567/task/31179
Currently the frontend hardcodes specific images for a signature profile and the width/height as configured in pdf-as. Ideally the activity would just get a profile ID to use, or figure out which profiles are available for the current user and everything else would be auto-magic.
pdf-as provides a visblock
endpoint which provides a preview and allows selecting the profile and a resolution:
http://127.0.0.1:8080/pdf-as-web/visblock?r=100&p=BASE_NORMAL
esign could provide a "profiles" API which contains the profile name, size (can be derived from the vizblock)
profile:
id: "my-profile"
name: "My Profile"
width: 123 (in points)
height: 45 (in points)
previewimage: "data:image/png;base64,..."
supportsUserText: true
width/height could be derived from the image:
profile width/height: round((pixel / resolution) * 72)
-> points
To do:
- add a profiles resource
- add a bundle config setting for a user visible profile name
- cache the profile image
- derive the width/height from it
- make visblock accessible in the firewall config
- expose if user text is configured
Open questions:
- name translation? -> leave up to the bundle config I guess?
- previewimage resolution? -> a multiple for 72 works nicely because of rounding, e.g. 360, or 504, use to calc width/height, and scale down.
- If we allow to extend the signature block the preview wont show that -> but that's already a problem
- We currently allow setting a different width when signing via the API, there is no way to get a preview for that though, unless we patch pdf-as. The frontend uses the default width though, so that's not a problem there.
All in all this would mean the following
<dbp-official-signature-pdf-upload
signature-width="162"
signature-height="28"
signature-placeholder-image-src="official-signature-placeholder.png">
</dbp-official-signature-pdf-upload>
could be reduced to:
<dbp-official-signature-pdf-upload
profile-id="official">
</dbp-official-signature-pdf-upload>