phantomjs插件从HTML/URL生成PDF示例

PhantomJ快速上手

1、源文件(待转换的html,内容较多)

<html>
<head>
    <meta charset="UTF-8">
    <title>XXX报告</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        .el-table, .el-table td, .el-table th {
            box-sizing: border-box;
            position: relative
        }

        .el-table th, .el-table th > div {
            white-space: nowrap;
            overflow: hidden
        }

        .el-table {
            overflow: hidden;
            width: 100%;
            max-width: 100%;
            background-color: #fff;
            border: 1px solid #dfe6ec;
            font-size: 14px;
            color: #1f2d3d
        }

        .el-table .el-tooltip.cell {
            white-space: nowrap;
            min-width: 50px
        }

        .el-table td, .el-table th {
            height: 40px;
            min-width: 0;
            text-overflow: ellipsis;
            vertical-align: middle
        }

        .el-table::after, .el-table::before {
            content: '';
            position: absolute;
            background-color: #dfe6ec;
            z-index: 1
        }

        .el-table td.is-right, .el-table th.is-right {
            text-align: right
        }

        .el-table td.is-left, .el-table th.is-left {
            text-align: left
        }

        .el-table td.is-center, .el-table th.is-center {
            text-align: center
        }

        .el-table td, .el-table th.is-leaf {
            border-bottom: 1px solid #dfe6ec
        }

        .el-table td.gutter, .el-table th.gutter {
            width: 15px;
            border-right-width: 0;
            border-bottom-width: 0;
            padding: 0
        }

        .el-table .cell, .el-table th > div {
            padding-left: 10px;
            padding-right: 10px;
            box-sizing: border-box;
            text-overflow: ellipsis
        }

        .el-table::before {
            left: 0;
            bottom: 0;
            width: 100%;
            height: 1px
        }

        .el-table::after {
            top: 0;
            right: 0;
            width: 1px;
            height: 100%
        }

        .el-table .caret-wrapper, .el-table th > .cell {
            position: relative;
            display: inline-block;
            vertical-align: middle
        }

        .el-table th {
            background-color: #eef1f6;
            text-align: left
        }

        .el-table th.is-sortable {
            cursor: pointer
        }

        .el-table th > div {
            display: inline-block;
            line-height: 40px
        }

        .el-table td > div {
            box-sizing: border-box
        }

        .el-table th.required > div::before {
            display: inline-block;
            content: "";
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #ff4d51;
            margin-right: 5px;
            vertical-align: middle
        }

        .el-table th > .cell {
            word-wrap: normal;
            text-overflow: ellipsis;
            line-height: 30px;
            width: 100%;
            box-sizing: border-box
        }

        .el-table th > .cell.highlight {
            color: #20a0ff
        }

        .el-table .caret-wrapper {
            cursor: pointer;
            margin-left: 5px;
            margin-top: -2px;
            width: 16px;
            height: 30px;
            overflow: visible;
            overflow: initial
        }

        .el-table .cell, .el-table__footer-wrapper, .el-table__header-wrapper {
            overflow: hidden;
        }

        .el-table .sort-caret {
            display: inline-block;
            width: 0;
            height: 0;
            border: 0;
            content: "";
            position: absolute;
            left: 3px;
            z-index: 2
        }

        .el-table .sort-caret.ascending, .el-table .sort-caret.descending {
            border-right: 5px solid transparent;
            border-left: 5px solid transparent
        }

        .el-table .sort-caret.ascending {
            top: 9px;
            border-top: 0;
            border-bottom: 5px solid #97a8be
        }

        .el-table .sort-caret.descending {
            bottom: 9px;
            border-top: 5px solid #97a8be;
            border-bottom: 0
        }

        .el-table .ascending .sort-caret.ascending {
            border-bottom-color: #48576a
        }

        .el-table .descending .sort-caret.descending {
            border-top-color: #48576a
        }

        .el-table td.gutter {
            width: 0
        }

        .el-table .cell {
            white-space: normal;
            word-break: break-all;
            line-height: 24px;
        }

        .el-badge__content, .el-message__group p, .el-progress-bar__inner, .el-steps.is-horizontal, .el-tabs__nav, .el-tag, .el-time-spinner, .el-tree-node, .el-upload-list__item-name {
            white-space: nowrap
        }

        .el-table tr input[type=checkbox] {
            margin: 0
        }

        .el-table tr {
            background-color: #fff
        }

        .el-table .hidden-columns {
            position: absolute;
            z-index: -1
        }

        .el-table__expand-column .cell {
            padding: 0;
            text-align: center
        }

        .el-table__expand-icon > .el-icon {
            position: absolute;
            left: 50%;
            top: 50%;
            margin-left: -5px;
            margin-top: -5px
        }

        .el-table--fit {
            border-right: 0;
            border-bottom: 0
        }

        .el-table--border th, .el-table__fixed-right-patch {
            border-bottom: 1px solid #dfe6ec
        }

        .el-table--fit td.gutter, .el-table--fit th.gutter {
            border-right-width: 1px
        }

        .el-table--border td, .el-table--border th {
            border-right: 1px solid #dfe6ec
        }

        .el-table__fixed-right .el-table__fixed-body-wrapper, .el-table__fixed-right .el-table__fixed-footer-wrapper, .el-table__fixed-right .el-table__fixed-header-wrapper {
            left: auto;
            right: 0
        }

        .el-table__fixed-header-wrapper thead div {
            background-color: #ee
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值