farling42 / fvtt-pdf-pager

PDF Pager for Foundry
MIT License
6 stars 4 forks source link

PDF forms / form fields are shown #22

Closed CePeU closed 1 year ago

CePeU commented 1 year ago

On most PDF readers form fields are highlighted, while this is great for input it is not so nice for reading. I found at least one PDF reader which does not highlight form fields. Could it be made optional that form fields are shown or ignored? Preferably with a toggle switch. That way input could be done assisted with highlighting and normal play could be made without. Idealy the form fields can be normally accessed even if not highlighted.

farling42 commented 1 year ago

That is a feature of the pdfjs library provided by Foundry, I don't think that I have any control of its presentation.

CePeU commented 1 year ago

Are you able to access the level of transparency?

farling42 commented 1 year ago

In the CSS, there is a variable called --annotation-unfocused-field-background which is used for the background of all editable fields. In viewer.css there scripts/pdfjs/web/viewer.css, there is a section

:root {
  --annotation-unfocused-field-background: url("data:image/svg+xml;charset=UTF-8,<svg width='1px' height='1px' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' style='fill:rgba(0, 54, 255, 0.13);'/></svg>");
}

.annotationLayer .textWidgetAnnotation input,
.annotationLayer .textWidgetAnnotation textarea,
.annotationLayer .choiceWidgetAnnotation select,
.annotationLayer .buttonWidgetAnnotation.checkBox input,
.annotationLayer .buttonWidgetAnnotation.radioButton input {
  background-image: var(--annotation-unfocused-field-background);
  border: 0px solid transparent;
  box-sizing: border-box;
  font-size: 9px;
  height: 100%;
  margin: 0;
  padding: 0 3px;
  vertical-align: top;
  width: 100%;
}

Replacing the top block with the following removes the fill effect on editable fields:

:root {
  --annotation-unfocused-field-background: ;
}
CePeU commented 1 year ago

The last parameter of rgb is transparency if I remember correctly from my studies while learning CSS for foundry. So maybe if you change: style='fill:rgba(0, 54, 255, 0.13) --> style='fill:rgba(0, 54, 255, 0.0) ? That way the change would be minimal. As allways ignore me if I talk rubish.

I checked and it should work. Maybe you can make it a CSS variable which you can adjust. You could then make it an input in module preferences. A toggle in addition would still be nice.

farling42 commented 1 year ago

I've made a simple update, so this will be available as a module option in version 0.18.0

CePeU commented 1 year ago

Thank you :) It drove me nut's that a professional viewer like Acrobat does not seem to allow to customize something like that :). It took some time but I found a reader which ignored it so it seemed optional. I will really like that option in PDF Pager!

farling42 commented 1 year ago

0.18.0 should be available now.