- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我实际上是在尝试在服务器端包含 jspdf,然后将其用于简单的 pdf 生成(只是文本“Hello world!”)(转到 url - 获取 pdf localhost:8080)。现在我面临的第一个问题是
npm install node-jspdf
安装它时出现以下错误-> G:\test\myproj>npm install node-jspdf
node-jspdf@0.0.3 install G:\test\myproj\node_modules\node-jspdf
sh install.sh
'sh' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-jspdf"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code ELIFECYCLE
npm ERR! node-jspdf@0.0.3 install: `sh install.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-jspdf@0.0.3 install script 'sh install.sh'.
npm ERR! This is most likely a problem with the node-jspdf package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! sh install.sh
npm ERR! You can get their info via:
npm ERR! npm owner ls node-jspdf
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! G:\test\myproj\npm-debug.log
任何人都可以帮助我如何将它包含在 Node 中吗?并给出一个4-5行的demo。
最佳答案
您实际上可以直接使用 jspdf(npm install jspdf
而不是 npm install node-jspdf
)。 Jspdf 当前 (v1.3.2) 构建时并未考虑 Node 支持,但您可以像下面这样模拟全局变量并使其以这种方式工作。这是一个基本示例,jspdf 的所有功能将不可用。
global.window = {document: {createElementNS: () => {return {}} }};
global.navigator = {};
global.html2pdf = {};
global.btoa = () => {};
var fs = require('fs');
var jsPDF = require('jspdf');
var doc = new jsPDF();
doc.text("Hello", 10, 10);
var data = doc.output();
fs.writeFileSync('./document.pdf', data, 'binary');
delete global.window;
delete global.html2pdf;
delete global.navigator;
delete global.btoa;
关于javascript - jsPDF 服务器端 (node.js) 使用 node-jspdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30694428/
我正在使用带有插件 jspdf-autotable 的 jspdf 来为一个非常宽的表格创建一个 pdf,有没有办法让表格/列数据自动适应任何页面大小? 我尝试了下面的代码溢出:'linebreak'
我的表有 13 列。如何为每列获得不同的宽度?我可以像这样给每个列宽吗? 样式:{溢出:'换行符',列宽:[100,80,80,70,80,80,70,70,70,70,60,80,100]}, 我的
如何使用jspdf和jspadf-autotable在PDF中实现嵌套表格?类似于下图的内容: 最佳答案 jspdf-autotable 中不支持嵌套表格,但您可以使用 didDrawCell Hoo
在 jsPDF 中使用 .cell 时如何删除填充? 我到处都看了,文档很模糊 this.pdf = new jsPDF(); this.pdf.cell(0, 0, 10, 10, "cell ce
表格插件 JsPDF-AutoTable: https://github.com/simonbengtsson/jsPDF-AutoTable 如何使页面横向与纵向相反?在文档中,它只是说“仅支持 p
是否可以添加 HyperLink在 jsPDF ? 这是我用于相同的代码。 var doc = new jsPDF('p', 'pt'); doc.fromHTML( 'Cl
我对 jsPDF autotable 有疑问。 我的代码: $('#printBtn').on('click', function() { var pdf = new jsPDF('p
我有自动表的问题。我的表由 thead、tbody 和 tfoot 组成。我的脚是我在每一列上的总值(value)。我能够生成 pdf,但 tfoot 或总页脚不断打印在每一页上。我在检查文档时使用
有人可以帮忙举一个为 jspdf-autotable 设置自定义字体的例子吗? 我尝试了以下 var doc = new jsPDF('p', 'pt'); doc.setFont("rotobo")
我有一个带图像的 html 表。当我尝试转换为 PDF 时,只有数据来了。图像未以 PDF 格式显示。 如何获取pdf格式的表格td图片? 契约(Contract)标题包含复选框图像。但不是以 pdf
我正在做的是使用 jsPDF 创建我生成的图形的 PDF。但是,我不确定如何包装标题(使用 text() 函数添加)。标题的长度因图形而异。目前,我的标题正在页面外运行。任何帮助,将不胜感激! 这是我
我正在使用img jsPDF AutoTable库从我的HTML表创建PDF文件,Everythink工作正常,PDF总是创建,但我对我的国家/地区典型的一些特殊字符有疑问。在我的 PDF 文件中,包
JsPdf-autoTable是一款非常棒的软件,并且非常简单就能让基础功能发挥作用。 现在我想在每个页面的顶部添加一个 Logo 和一些文本,并在每个页面上添加一个 page X of Y 页脚,但
我有一个用于保存 html 页面的按钮。当用户单击按钮时,我想触发 jsPDF 函数,但它返回“jspdf PubSub 错误”并且生成的 pdf 文件为空白。 var doc = new jsPD
我是使用 jsPDF 的新手,能够很好地生成普通 PDF,但是当我尝试应用外部 CSS 或普通样式背景颜色时,它没有任何效果。 我的 JSP 包括: 我正在使用下
我正在尝试将“页码 x of y”添加到使用 jspdf 和 jspdf-autotable 生成的 PDF 中。我使用了 jspdf-autotable 示例网站上的 Examples.js 文件中
我正在使用jspdf和jspdf-autotable将基于数据的表格导出为PDF。 有时,我的数据可能包含 DOM 元素,这些元素不由 jspdf-autotable 插件处理。在大多数情况下,DOM
我刚刚开始使用 jsPDF 和 AutoTable 插件,它几乎完美地满足了我们的使用需求。一个问题... 是否可以将列定义中的 dataKey 分配给映射到表的 JSON 中的嵌套属性? 我们有一个
我刚刚开始使用 jsPDF 和 AutoTable 插件,它几乎完美地满足了我们的使用需求。一个问题... 是否可以将列定义中的 dataKey 分配给映射到表的 JSON 中的嵌套属性? 我们有一个
我使用 Array.prototype.push() 创建了一个包含来自动态表的值的数组.然后像这样把它转换成pdf doc.autoTable(vHeader, vData, opt); doc.s
我是一名优秀的程序员,十分优秀!