fs.readFileSync错误

时间:2016-10-06 09:19:42

标签: javascript node.js cloud9-ide fs

我正在尝试使用html-pdf节点模块从html生成pdf。我目前正在使用cloud9 IDE运行它。

我的代码是:

Sub CurrencyFormat_UK()
'
' Currency formating
'

Dim oCl As Word.Cell
Dim oRng As Range
'
' Condition to check the selected data
'
  If Selection.Type = wdSelectionIP Or _
      Not Selection.Information(wdWithInTable) Then
    MsgBox "Select a cell or range of cells before running" _
      & " this macro.", , "Nothing Selected"
    Exit Sub
  End If
  For Each oCl In Selection.Cells
    Set oRng = oCl.Range
    '
    'Drop of the end of cell mark
    '
    oRng.End = oRng.End - 1
    With oRng
      If IsNumeric(oRng) Then
        .Text = FormatCurrency(Expression:=.Text, NumDigitsAfterDecimal:=2, _
                IncludeLeadingDigit:=vbTrue, UseParensForNegativeNumbers:=vbTrue)
      End If
      If oRng.Characters.count = 1 Then GoTo Skip
      On Error GoTo Skip
      'Catch errors here
      If InStr(oRng.Text, "€") = False Then
        oRng.Font.Color = wdColorRed
        oRng.Select
        MsgBox "Cell content is not numerical.", , "Error"
        Selection.Collapse wdCollapseEnd
      End If
Skip:
    End With
  Next oCl
lbl_Exit:
Exit Sub
End Sub

我收到以下错误:

var fs = require("fs");
var pdf = require('html-pdf');
var html = fs.readFileSync('./test.html', {encoding: 'utf8'});
var options = { format: 'Letter' };

app.post('/pdf',function(req, res) {

   pdf.create(html, options).toFile('./businesscard.pdf', function(err, res) {
     if (err) return console.log(err);
       console.log(res); // { filename: '/app/businesscard.pdf' }
     });
});

有谁知道我如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

  

这是由locale -a中的错误造成的。您可以看到here

打开终端并执行fonts,您会看到LC_ALL=C的列表。然后选择estimator.set_params(n_estimators=100)

可能会有所帮助