首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不显示所有标头

不显示所有标头
EN

Stack Overflow用户
提问于 2019-04-09 13:55:34
回答 1查看 65关注 0票数 0

我正在使用html-pdf库将html表保存到pdf文件中,文件正在保存,但我没有在file.If中获得所有的标题更多的标题在表行中,而所有列都没有显示。

这是我的后端代码

代码语言:javascript
运行
复制
var fs = require('fs');
var pdf = require('html-pdf');
var options = { format: 'Letter' };
 var htmldata = ' <div class="uk-grid" data-uk-grid-margin style="margin-top: 12px;"><div class="uk-width-medium-1-1" style="overflow-x: scroll;"><table class="uk-table uk-table-striped uk-table-hover" id="table1">'+
                            '<thead style="display: table-row-group;">'+
                                '<tr style="background:#3399ff;">'+
                                    '<th>Customer </th>'+
                                    '<th>Site ID1</th>'+
                                    '<th>Site Name1</th>'+
                                    '<th>Customer2</th>'+
                                     '<th>Site ID2</th>'+
                                    '<th>Site Name2</th>'+
                                     '<th>Site ID3</th>'+
                                    '<th>Site Name3</th>'+
                                     '<th>Site ID4</th>'+
                                    '<th>Site Name4</th>'+
                                     '<th>Site ID5</th>'+
                                    '<th>Site Name5</th>'+
                                     '<th>Site ID6</th>'+
                                    '<th>Site Name6</th>'+
                                     '<th>Site ID7</th>'+
                                    '<th>Site Name7</th>'+
                                     '<th>Site ID8</th>'+
                                    '<th>Site Name8</th>'+
                                     '<th>Site ID9</th>'+
                                    '<th>Site Name9</th>'+
                                    '<th>Site Name10</th>'+
                                    '<th>Site Name10</th>'+
                                    '<th>Site Name11</th>'+
                                    '<th>Site Name11</th>'+
                                '</tr>'+
                            '</thead><tbody ></tbody></table></div></div>';
                           pdf.create(htmldata, options).toFile('./businesscard.pdf', function(err, res) {
                           if (err) return console.log(err);
                                console.log(res); // { filename: '/app/businesscard.pdf' }
                          });
EN

回答 1

Stack Overflow用户

发布于 2019-04-09 14:20:52

您要添加的纸张类型和列数存在问题。

正在添加列,但您的纸张选项不允许它们以PDF格式呈现。

尝试在您的选项变量中设置一些与纸张相关的选项。

代码语言:javascript
运行
复制
  // Papersize Options: http://phantomjs.org/api/webpage/property/paper-size.html
  "height": "10.5in",        // allowed units: mm, cm, in, px
  "width": "8in",            // allowed units: mm, cm, in, px
  - or -
  "format": "Letter",        // allowed units: A3, A4, A5, Legal, Letter, Tabloid
  "orientation": "portrait", // portrait or landscape

  // Page options
  "border": "0",             // default is 0, units: mm, cm, in, px
  - or -
  "border": {
    "top": "2in",            // default is 0, units: mm, cm, in, px
    "right": "1in",
    "bottom": "2in",
    "left": "1.5in"
  },

更多选项是here

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55585977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档