dpylt7626401 2014-04-01 11:01
浏览 28

字母预览PHP / JQuery

I have a set of fields such as title, body, header, footer, signature and so on. When i fill these fields which are sections of a letter, a preview of what is being filled should show as the link given here: http://www.cvplaza.com/wp-content/uploads/2012/09/cover-letter-example.png

I will be developing this using codeigniter and want to know libraries or any other technologies to achieve this. I will also need to set predefined templates for the letter so once i loads them, i can then fill-in details and the preview fill format and show the final draft.

  • 写回答

1条回答 默认 最新

  • dongsechuan0535 2014-04-01 11:11
    关注

    Something like this?

    Guess some normal html would suffice, just create a html mockup, including some <address> tags etc (or whatever you want), and use some css to make it look like you want. Nothing special about it...

    EDIT

    reply on the comment: yes and no, ofcourse you can limit the number of characters or even words, but note that calculating dimensions based on text is nearly impossible. Except for monospace fonts every letter has it's own width, which is based on several variables, amongst others the rendering engine, which depends on the os and even the browser, the font chosen, etc. etc.

    Except for if you have a lot of time and/or resources, I'd go with a practical solution. If you do have both, you can dynamically parse pdf files, using, eg. FPDF or TCPDF. Or you can look into dynamically parsing LaTeX, which gives you beautiful results with minimal effort in creating a page layout. But consider; is it worth the trouble?

    In case of html and latex, you can create templates the way you would create normal html templates. An example for the template I created in the fiddle would look like this in php:

    <div class="letter">
        <header>
            <div class="sender">
                <address>
                <?php echo $sender['name']; ?><br/>
                <?php echo $sender['address']; ?><br/>
                <?php echo $sender['city']; ?><br/>
                <?php echo $sender['zip']; ?><br/>
                </address>
            </div>
            <div class="date">
                <?php echo $date; ?>
            </div>
            <div class="recipient">
                <address>
                    <?php // recipient... ?>
                </address>
            </div>
        </header>
        <div class="body">
            Dear <?php echo $recipient['full_name']; ?><br/>
            <br/>
            <strong><?php echo $subject; ?></strong><br/><br/>
            <?php echo nl2br($message_body); ?>
        </div>
    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?