如何在每个打印页面上打印页脚? [英] How to print footer on each printed page?

查看:257
本文介绍了如何在每个打印页面上打印页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Open Cart为我的公司开发订购系统.
一切都在用PHP和HTML完成.

I am working on an ordering system for my company utilizing Open Cart.
Everything is being done in PHP and HTML.

我正在尝试修改发票页面,以在打印的发票底部包括一个签名行.根据行/项目的数量,发票可以延伸到多页,也可以将它们分批处理,以使一个要打印的文档具有多个发票(使用循环).我不是网络开发人员,并且尽我所能来完成项目的这一部分.请给我指针或伪代码示例.

I am trying to modify the invoice page to include a signature line at the bottom of the printed invoice. Invoices can stretch to multiple pages depending on the number of lines/items, and they can also be batched so that one document to be printed has multiple invoices (using a loop). I am not a web developer, and have hit the end of my abilities to get this part of the project done. Please give me pointers or pseudo code samples.

脚码:

<style type="text/css">
    .picklistCheck{
        width:15px;
        height:15px;
        border:1px solid #c7c7c7;
        margin:0 auto;
        border-radius:2px;
        box-shadow:inset 0px 0px 2px rgba(0,0,0,0.1);
        font-size:14pt;
    }
    .signature{
        border-bottom-style:solid;
        font-size:14pt;
        page-break-after:always;
    }
    td{
        font-size:14pt;
    }
</style>

<?php
    foreach ($orders as $order) {
        ?>
        //<div>orders go here </div>
        <?php
    }
    include ("footer.php");
?>

推荐答案

每当您的逻辑决定在发票中放置分页符时,还告诉它也插入以下代码:

Every time your logic decides to put a page break in the invoice, tell it to insert the following code also:

<?php include ("footer.php"); ?>

使用您想要放在页脚中的简单html创建一个footer.php文件.上面的代码假定your scriptfooter.php在同一目录中.

Create a footer.php file with the simple html you want to place in the footer. The above code assumes that your script and footer.php are in same directory.

编辑:要回答您的评论,

Include PHP.net 的行为与您实际复制的行为完全相同-直接粘贴所有代码,而不是将其包括在内.但是每个包含文件都应在需要的地方具有自己的<?php ?>标记.没有<?php ?>标签,Control只会输出在那里看到的内容.

The Include PHP.net will behave exactly like you actually copy-pasted all the code directly instead of including it. But every include file should have its own <?php ?> tags where-ever required. Without <?php ?> tags, Control will just output whatever it sees there.

Footer.php可以是一个简单的仅HTML文件:

Footer.php can be a simple HTML-only file:

<div id="footer">
    Company XYZ (c)2000-2012 All Copyrights Reserved
    Some other footer text.
</div>

您也可以将其命名为footer. html ,但是如果以后在以后决定将一些动态数据放入footer中,将.html更改为.php将会非常困难.全部包括写在各种文件中的行.

You could also name it footer.html, but if later, in future, you decide to put some dynamic data in footer, it will be very difficult to change .html to .php in all include lines written in various files.

动态页脚示例:

<div id="footer">
    Company XYZ (c)2000-2012 All Copyrights Reserved
    <?php echo $who_printed." ".$who_authorized; ?>
</div>

当然,这只是一个简单的例子.

Of course it is just a simple example.

在html页面中,您可以通过在外部链接的.css文件中使用以下CSS代码来强制div:

In a html page, you could force a div by using the following CSS code in an external linked .css file:

#footer{
text-align: right;
height: 20px;
position:fixed;
margin:0px;
bottom:0px;
}

position:fixed;& bottom:0px;在这里完成技巧.即使页面滚动或其他操作,此"footer" div也会始终保持在底部.就像Facebook将其标题菜单置于顶部和顶部的方式一样聊天栏到底部.您还可以定义左右属性

position:fixed; & bottom:0px; is here doing the trick. It is forcing this "footer" div to stick to bottom always, even if page is scrolled or something. Like the way Facebook sticks its header menu to top & chat bar to bottom. You can also define left, right properties

更新:好的,根据您的评论,下面是示例代码:

Update: Ok, based on your comments, here is the sample code:

在"CSS样式"部分中,使用:

In CSS Style section, use:

.signature{
    border-bottom-style:solid;
    font-size:14pt;
    page-break-after:always;

    text-align: center;
    height: 20px;
    width: 100%;
    margin:0px auto;
    position:fixed;
    bottom:0px;
}

所有属性都是不言自明的. Text-align使文本居中对齐. Width使此div .signature在页面上的宽度为100%.要求将div两侧留有相等的边距. Margin表示将0px边距放在顶部&底部和auto都在左侧&右边. Position使其固定在视口/页面上. Bottom说保持0px从底部开始.

All properties are self-explanatory. Text-align makes the text center-aligned. Width is making this div .signature 100% wide on page. It is required to put the div with equal margins on both sides. Margin is saying put 0px margin on top & bottom sides and auto on both left & right side. Position makes it fixed on viewport/page. Bottom says keep 0px from bottom.

在页面正文中,使用以下代码:

In body of page, use this code:

<?php
    foreach ($orders as $order) {
        ?>
        //<div class="order">order1 go here </div>
        //<div class="order">order2 go here </div>
        //<div class="order">order3 go here </div>
        //<div class="order">order4 go here </div>
        <?php
    } // for each ENDS
?>

<div class="signature">
      Authorized by <?php echo $who_authorized; ?> |
      Printed by <?php echo $who_printed; ?>
</div><!--//signature-->

它只是将您在CSS样式中定义的任何属性分配给signature div.显然,您需要将此代码段包装到逻辑中,该逻辑确定何时回显/引入signature div.另外,$ who_authorized& $ who_printed需要保留一些值.

It simply assigns whatever properties you defined in CSS Styling to signature div. Obviously you need to wrap this snippet into your logic, which decides when to echo/introduce the signature div. Also, $who_authorized & $who_printed needs to hold some value.

对于任何大于3行的块,我总是会出现(?>)PHP解析器/控件,并根据需要简单地编写HTML.然后,在需要时,我再次输入PHP(<?php)

For any block bigger than 3 lines, I always come out (?>) of PHP parser/control and simply write HTML as desired. Then, when required, I again enter PHP (<?php)

如果要使用include,则可以省略最后6行(从我的代码中以?>开始并以<!--//signature-->结尾,只需将这行放在那里.

If you want to go with include, you can omit the last 6 lines( starting from ?> & ending with <!--//signature--> from my code and simply put this line there.

include ("footer.php");
?>

此选项还要求您在同一目录中创建一个名为footer.php的文件,并在其中插入以下html代码.

This option also requires you to create a file named footer.php in the same directory and insert the following html code in it.

<div class="signature">
      Authorized by <?php echo $who_authorized; ?> |
      Printed by <?php echo $who_printed; ?>
</div><!--//signature-->

这篇关于如何在每个打印页面上打印页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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