使用 <SELECT> 生成 PDFHTML 中的表单字段始终显示多行下拉列表 [英] generating PDF with &lt;SELECT&gt; form field from HTML displays always multiline dropdown

查看:89
本文介绍了使用 <SELECT> 生成 PDFHTML 中的表单字段始终显示多行下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 mPDF 7.x 版,我需要生成带有可填写表单的 PDF.一切正常,除了一件事 - 下拉列表 (SELECT) 总是显示为多"行 - 我无法使用如下所示的下拉列表创建文档:

mpdf 由最新版本的 composer 加载.代码取自随 mpdf 分发的样本.缺少"HTML,HEADER 标签对结果没有影响.

我的输出 PDF 不反映任何 CSS 格式、大小"属性、样式,什么都没有.

以前有人遇到过这个问题吗?(并找到解决方案?)

任何建议将不胜感激.

解决方案

明白了 :) 似乎我不是第一个,也是唯一一个遇到同样问题的人.这是帮助我的解决方案(解决方法):https://github.com/mpdf/mpdf/issues/852#issuecomment-546851163

I'm using mPDF version 7.x and i need to generate PDF with fillable forms. Everything works fine except one thing - the dropdown (SELECT) always shows as with 'multiple' lines - i'm not able to create document with dropdown looking like this: https://osuch.com/formtools/exp/mpdfexp/project_mpdf/pdfb04_basic_active_form.php

my code:

<?php

require_once 'vendor/autoload.php';

        $mpdf= new \Mpdf\Mpdf();

        //==============================================================

        $html = '
        <style>
        body
        {
            padding-bottom:0px;
            margin-bottom:0px;
            margin-top:0px;
            padding-top:0px;
        }
        h2
        {

            padding-bottom:0px;
            margin-bottom:0px;
            margin-top:5px;
            padding-top:0px;
            font-family: Arial;
            font-size:200%;
            color:green;
        }
        p
        {

            padding-bottom:0px;
            margin-bottom:5px;
            margin-top:10px;
            padding-top:5px;
            font-family: Arial;
            font-size:100%;
            font-weight:normal;

        }
        .inp
        {

            padding-bottom:0px;
            margin-bottom:0px;
            margin-top:5px;
            padding-top:0px;
            font-family: Arial;
            font-size:100%;
            width:100%;
            border-bottom:1px solid #000000;
            background-color:#dedede;
        }
        fieldset
        {

            padding-bottom:0px;
            margin-bottom:0px;
            margin-top:5px;
            padding-top:0px;
            border: 1px solid #000000;
            padding:10px;
            font-family: Arial;
            font-size:150%;
            font-weight:bold;
            margin-top:10px;
        }

        textarea
        {
            font-family: Arial;
            font-size:100%;
            border:2px solid #000000;
            background-color: #dadada;
            background-color:#dedede;
        }

        </style>

        <body>
        <h2>Basic PDF Active Form</h2>
        <form action="#" method="post">
        <fieldset>Personal Information
        <p>Name:</p>
        <div class="inp"><input type="text" size="200" name="inputname" value="" title="Enter your name"/> </div>
        <p>Company:</p>
        <div class="inp"><input type="text" size="200" name="inputco" value="" title="Company name"/> </div>
        <p>Email:</p>
        <div class="inp"><input type="text" size="200" name="inputemail" value="" title="Email address"/> </div>
        <p>Mobile:</p>
        <div class="inp"><input type="text" size="200" name="inputmobile" value="" title="Mobile telephone number"/> </div>
        </fieldset>

        <fieldset>Additional Information

        <p>How many languages do you speak?</p> 

        <input type="radio" name="num_languages" value="1" checked="checked" > One      
        <input type="radio" name="num_languages" value="2" > Two      
        <input type="radio" name="num_languages" value="3" > Three      
        <input type="radio" name="num_languages" value="4" > Four      
        <input type="radio" name="num_languages" value="5" > Five +      

        <br /><br />


        <input type="checkbox" name="email" value="email_subscrbe" checked="checked" /> Please send me regular information by e-mail<br>
        <input type="checkbox" name="subscribe" value="newsletter_subscribe" /> Please subscribe me to the Newsletter

           <p>Seminar Information</p> 
          <label for="reg_seminar">Seminar</label>
          <select size="1" name="reg_seminar" id="reg_seminar">
            <option value="Guitar for Beginners" >Guitar for Beginners</option>
            <option value="JavaScript Today" >JavaScript Today</option>
            <option value="Time is on our side" >Time is on our side</option>
          </select>

          <label for="reg_location">Location</label>
          <select size="0" name="reg_location" id="reg_location">
            <option value="New York" >New York</option>
            <option value="Paris" >Paris</option>
            <option value="Munich" >Munich</option>
            <option value="Gartmorn" >Gartmorn</option>
          </select>

          <p>Payment Type</p>
           <label><input type="radio" name="regpay" id="reg_payment01" value="Voucher" >
        Voucher</label>

           <label><input type="radio" name="regpay" id="reg_payment02" value="Cash" >
         Cash</label>

           <label><input type="radio" name="regpay" id="reg_payment03" value="CreditCard" >
         Credit Card</label>

           <label><input type="radio" name="regpay" id="reg_payment04" value="BitCoin" >
         BitCoin</label>

          <p>Comments:</p>
        <textarea name="textareafield"  rows="4" cols="80" wrap="virtual"></textarea>
          </fieldset>

        </form>
        ';
        //==============================================================
    $mpdf->useActiveForms = true;
    /*
        $mpdf->formUseZapD = false;
        $mpdf->form_border_color = '0.6 0.6 0.72';
        $mpdf->form_button_border_width = '2';
        $mpdf->form_button_border_style = 'S';
        $mpdf->form_radio_color = '0.0 0.0 0.4';    // radio and checkbox
    $mpdf->form_radio_background_color = '0.9 0.9 0.9';
     */
        $mpdf->WriteHTML($html);
        // OUTPUT
        $mpdf->Output('test.pdf'); exit;

        //==============================================================
?>

my output:

mpdf is loaded by composer, latest version. the code is taken from samples distributed with mpdf. "missing" HTML, HEADER tags has no effect to the result.

my output PDF does not reflect any CSS formatting, "size" attribute, styling, nothing.

has anyone previously encountered this problem? (and found a solution?)

any advice would be appreciated.

解决方案

got it :) seems like i'm not first and the only one who's got the same issue. this is solution (workaround) that helped me out: https://github.com/mpdf/mpdf/issues/852#issuecomment-546851163

这篇关于使用 <SELECT> 生成 PDFHTML 中的表单字段始终显示多行下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆