1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>{$info.order_no}</title>
- <style>
- html, body, div, span, applet, object, iframe,
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
- a, abbr, acronym, address, big, cite, code,
- del, dfn, em, img, ins, kbd, q, s, samp,
- small, strike, sub, sup, tt, var,
- u, i, center,
- dl, dt, dd, ol, ul, li,
- fieldset, form, label, legend,
- table, caption, tbody, tfoot, thead, tr, th, td,
- article, aside, canvas, details, embed,
- figure, figcaption, footer, header, hgroup,
- menu, nav, output, ruby, section, summary,
- time, mark, audio, video {
- margin: 0;
- padding: 0;
- border: 0;
- font-size: 100%;
- font: inherit;
- vertical-align: baseline;
- box-sizing: border-box;
- font-family: Source Han Sans CN;
- }
- .page{
- padding: 15px;
- font-size: 14px;
- line-height: 16px;
- color:#333;
- }
- .hide-on-print {
- display: block;
- text-align: right;
- padding: 15px;
- }
- .realname {
- display: block;
- text-align: right;
- padding: 15px;
- }
- /* 打印时隐藏 */
- @media print {
- .hide-on-print {
- display: none;
- }
- }
- </style>
- </head>
- <body style="width: 760px;margin: 0 auto">
- <div class="hide-on-print">
- <button type="button" onclick="printPage()" class="btn btn-primary dropdown-toggle">导出PDF</button>
- </div>
- <div class="page">
- {$content}
- </div>
- <div class="realname">
- 姓名:{$info.realname}
- </div>
- </body>
- </html>
- <script src="/assets/js/jquery-3.1.1.min.js"></script>
- <script>
- //打印ctrl+P
- function printPage() {
- window.print();
- }
- function replaceDetail(){
- var details = $('.page').html();
- //newContent仅是details替换后内容;
- let newContent = details.replace(/<img[^>]*>/gi, function (match, capture) { //去除三标签
- match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
- match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
- match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
- return match;
- });
- newContent = newContent.replace(/<br[^>]*\/>/gi, '');
- newContent = newContent.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"');
- $('.page').html('');
- $('.page').html(newContent);
- }
- replaceDetail();
- </script>
|