Все заголовки не отображаются - PullRequest
0 голосов
/ 09 апреля 2019

Я использую html-pdf библиотеку для сохранения html-таблицы в pdf-файл, файл сохраняется, но я не получаю все заголовки в файле. Если в строке таблицы больше заголовков, чем во всех столбцах, не отображается

Вот мой код бэкэнда

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' }
                          });

1 Ответ

0 голосов
/ 09 апреля 2019

Проблема связана с типом бумаги и количеством добавляемых столбцов.

Добавляются столбцы, но параметры бумаги не позволяют отображать их в PDF.

Попробуйте установить несколько параметров, связанных с бумагой, в своей переменной.

  // 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"
  },

Дополнительные параметры здесь

...