Repository navigation
Description
With useActiveForms off, a list box (a <select> with size of 2 or more, or multiple) is drawn as a drop-down. The box is size rows tall, but it shows one option with a ▼ button beside it. Browsers draw a list box as rows of options, with the selected ones highlighted and no arrow.
$mpdf = new \Mpdf\Mpdf(['useActiveForms' => false]);
$mpdf->WriteHTML('<form><select name="fruit" size="4" multiple>
<option>Apple</option>
<option selected>Banana</option>
<option>Cherry</option>
<option selected>Damson</option>
<option>Elder</option>
</select></form>');On gravitypdf the page shows a four-row-tall box. It holds "Damson", centred vertically, beside a four-row-tall ▼ button. "Banana" is not shown at all.
Cause.
Form::print_ob_select()'s static branch has one drawing for every select: aCell()with the selected text, then the arrow cell. It never looks atsizeormultiple.Tag\Select::close()passes only one string,selectoption['SELECTED'].Tag\Option::open()resets it for eachselectedoption, so the last selected option wins, or the first option when none is selected.- The static width is measured from that one string (
GetStringWidth($texto)). Active forms measure the widest option (MAXWIDTH), so a list box is also narrower than its longest option.
Expected. When a static select is a list box (the same test the active path uses since #419: multiple, or size of 2 or more):
- Draw
sizerows of options, starting with the first option. If a selected option would fall below the last row, scroll so the first selected option is visible, as Give every active form widget its own appearance, and ask the viewer to redraw only text it cannot shape (#348, #59) #387's active appearance does. - Highlight every selected option, and draw no arrow.
- Size the width from the widest option, as active forms do.
- Keep today's drawing for a combo box.
The items array is already in $objattr in both modes, so the static branch has what it needs. Its rows and clip should follow the fix for #426, so the two modes agree.
Why it matters more now.
- A static select with multiple and no size is drawn one row tall instead of four #425 (PR Lay out a multiple select with no size four rows tall #437) makes a bare
multipleselect four rows tall, so more selects are affected. - Flatten active form fields under PDFXauto instead of removing them #400 (PR Draw an active form on the page under PDFXauto rather than removing its fields #439) flattens active forms under
PDFXautothrough this same static path, so a PDF/X form shows its list boxes this way too.
This changes how existing documents look and may change their layout (the width), so the PR needs an upgrade note. mpdf/mpdf development has the same code.
Activity
Draw a static list box as rows of options, with the selected ones hig…
Draw a static list box as rows of options, with the selected ones hig…