zoukankan      html  css  js  c++  java
  • wkhtmltopdf的目录样式自定义

    百度了一下,这方面资料确实不多,没有给出具体的xsl文件怎么写,终于在下面的链接找到了参考:
    https://stackoverflow.com/questions/48016246/wkhtmltopdf-style-table-of-conte

    然后点到这个https://github.com/jsreport/jsreport-wkhtmltopdf/blob/master/lib/default-toc.xsl,
    找到了一个样例,于是进行简单的改写,进行测试。
    注意这里是样例的xsl,实际的不是这个

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:outline="http://wkhtmltopdf.org/outline"
                    xmlns="http://www.w3.org/1999/xhtml">
        <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
                    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona
    l.dtd"
                    indent="yes" />
        <xsl:template match="outline:outline">
            <html>
                <head>
                    <title>Table of Contents</title>
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    <style>
                        h1 {
                        text-align: center;
                        font-size: 20px;
                        font-family: arial;
                        }
                        div {border-bottom: 1px dashed rgb(200,200,200);}
                        span {float: right;}
                        li {list-style: none;}
                        ul {
                        font-size: 20px;
                        font-family: arial;
                        }
                        ul ul {font-size: 80%; }
                        ul {padding-left: 0em;}
                        ul ul {padding-left: 1em;}
                        a {text-decoration:none; color: black;}
                    </style>
                </head>
                <body>
                    <h1>Table of Contents</h1>
                    <ul><xsl:apply-templates select="outline:item/outline:item"/></ul>
                </body>
            </html>
        </xsl:template>
        <xsl:template match="outline:item">
            <li>
                <xsl:if test="@title!=''">
                    <div>
                        <a>
                            <xsl:if test="@link">
                                <xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
                            </xsl:if>
                            <xsl:if test="@backLink">
                                <xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
                            </xsl:if>
                            <xsl:value-of select="@title" />
                        </a>
                        <span> <xsl:value-of select="@page" /> </span>
                    </div>
                </xsl:if>
                <ul>
                    <xsl:comment>added to prevent self-closing tags in QtXmlPatterns</xsl:comment>
                    <xsl:apply-templates select="outline:item"/>
                </ul>
            </li>
        </xsl:template>
    </xsl:stylesheet>
    

  • 相关阅读:
    检测Linux硬盘IO数据
    获取OrangePI板子CPU温度
    ASP.Net开发WebAPI跨域访问(CORS)的精简流程
    一些常用复合命令
    关于Linux的虚拟内存管理
    Linux中组 与 用户的管理
    linux加载与使用ko驱动
    7z命令行 极限压缩指令
    nodejs的POST请求
    案例:用ajax 方法 解析xml
  • 原文地址:https://www.cnblogs.com/dalianpai/p/13600793.html
Copyright © 2011-2022 走看看