首页 > 解决方案 > 水印 - 背景图片 - php

问题描述

首先,我想向你们中的任何人问好,

前段时间我改变了我的会计事务所,但我的发票有问题。我想在我的发票主题中设置水印(作为背景图像),但我的 php 技能等于 0。

这是代码示例:

<style>
    page {
        padding: 20 15 20 15;
        font-size: 8;
        font-family: LiberationSans;
    }

    td, th {
        padding: 0.5 1 0 1;
    }

    translation {
    <? if ($invoice['Invoice']['translation_language_id']): ?> font-size: 6;
        font-style: italic;
        display: inline;
    <? else: //?> display: none;
    <? endif ?>
    }
</style>

<? foreach ((array)$parameters['pages'] as $page): ?>
    <page>
        <header height="85">
            <? if (isset($invoice['footerCreator'])): ?>
                <div position="absolute" x="12" y="267" font-size="6" text-align="center">
                    <?= $invoice['footerCreator']; ?>
                </div>
            <? endif; ?>

            <style>
                .invoice-header {
                    position: absolute;
                    y: -10;
                    text-align: center;
                }

                /* logo */
                .invoice-logo {
                    width: 45%;
                    height: 40;
                    float: left;
                }

                /* main info - start */
                .invoice-main-info {
                    width: 48%;
                    float: right;
                }

                .invoice-main-info tr th {
                    padding: 1.5 0 1.5 0;
                }

                .invoice-main-info tr td {
                    padding: 1 0 1 1;
                }

                .invoice-main-info tr:child(0) {
                    font-size: 9;
                    text-align: center;
                    background-gradient-type: linear;
                    background-gradient-color1: white;
                    background-gradient-color2: lightgrey;
                }

                .invoice-main-info tr td div:child(0) {
                    width: 49%;
                    float: left;
                }

                .invoice-main-info tr td div:child(1) {
                    width: 49%;
                    float: right;
                }

                .invoice-main-info tr td div div:child(0) {
                    width: 57%;
                    float: left;
                }

                .invoice-main-info tr td div div:child(1) {
                    width: 42%;
                    float: right;
                }

                /* main info - stop */

                /* transaction sides - start */
                <? if ($invoice['ContractorDetailReceiver']['id']): ?>
                .invoice-transaction-side:child(0) {
                    width: 38%;
                    float: left;
                }

                .invoice-transaction-side:child(1) {
                    width: 31%;
                    float: left;
                }

                .invoice-transaction-side:child(2) {
                    width: 30%;
                    float: right;
                }

                <? else: ?>
                .invoice-transaction-side:child(0) {
                    width: 48%;
                    float: left;
                }

                .invoice-transaction-side:child(1) {
                    width: 48%;
                    float: right;
                }

                <? endif ?>
                /* transaction sides - stop */

                .invoice-bar {
                    position: absolute;
                    y: 71;
                    font-size: 10;
                    text-align: right;
                    padding: 0 1 -0.5 0;
                    margin-top: 4;
                    border-bottom: 1px;
                    background-gradient-type: linear;
                    background-gradient-color1: white;
                    background-gradient-color2: lightgrey;
                    background-gradient-coordinates: 0 0 1 0;
                }
            </style>

            <? if ($invoice['Invoice']['header']): ?>
                <p class="invoice-header"><?= $xml->sanitize($invoice['Invoice']['header']); ?></p>
            <? endif ?>

            <div class="invoice-logo">
                <? if ($parameters['logo_path']): ?>
                    <img width="80" src="<?= $parameters['logo_path'] ?>"/>
                <? endif ?>
            </div>

            <div class="invoice-main-info">
                <table>
                    <tr>
                        <th>Faktura<?= $xml->sanitize($parameters['document_name_suffix']) ?>
                            nr <?= $xml->sanitize($invoice['Invoice']['fullnumber']) ?></th>
                    </tr>
                    <tr>
                        <td>
                            <div>
                                <div>Data wystawienia:<br/>
                                    <translation><?= $translation->get('Invoice:Data wystawienia') ?></translation>
                                </div>
                                <div><?= $xml->sanitize($invoice['Invoice']['date']) ?></div>
                                <div clear="both"/>
                            </div>

                            <div>
                                <? if (!$invoice['Invoice']['disposaldate_empty']): ?>
                                    <div>Data sprzedaży:<br/>
                                        <translation><?= $translation->get('Invoice:Data sprzedaży') ?></translation>
                                    </div>
                                    <div><?= $invoice['Invoice']['disposaldate'] ?></div>
                                <? endif ?>
                                <div clear="both"/>
                            </div>

                            <div clear="both"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div>
                                <div>Termin płatności:<br/>
                                    <translation><?= $translation->get('Invoice:Termin płatności') ?></translation>
                                </div>
                                <div><?= $xml->sanitize($invoice['Invoice']['paymentdate']) ?></div>
                                <div clear="both"/>
                            </div>

                            <div>
                                <div>Metoda płatności:<br/>
                                    <translation><?= $translation->get('Invoice:Metoda płatności') ?></translation>
                                </div>
                                <div>
                                    <?= $xml->sanitize($invoice['Invoice']['paymentmethod']) ?><br/>
                                    <translation><?= $xml->sanitize($translation->get('Invoice:' . $invoice['Invoice']['paymentmethod'])) ?></translation>
                                </div>
                                <div clear="both"/>
                            </div>

                            <div clear="both"/>
                        </td>
                    </tr>
                </table>
            </div>
    </page>
    <? endif ?>

我尝试将背景图像和不透明度属性添加到,我尝试更改 css,但所有这些似乎都不起作用。

我知道这是一个非常新手的问题,但我放弃了。谁能帮我处理那个水印?

标签: phpcssxml

解决方案


我在您的代码中看不到水印,但为了您的信息,您可以在 css 中创建一个“水印”,如下所示:

.watermark{
    opacity: 0.5; /* Firefox, Chrome, Safari, Opera, IE >= 9 (preview) */
    filter:alpha(opacity=50); /* for <= IE 8 */
}
.rotate45{
    transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);    /* Safari */
    -moz-transform: rotate(-45deg);       /* Firefox */
    -ms-transform: rotate(-45deg);        /* IE */
    -o-transform: rotate(-90deg);         /* Opera */
}

<div class="rotate45 watermark"> Watermark text </div>

推荐阅读