草庐IT

nodejs-easy-pdf-parser

全部标签

javascript - 带有 ejs 模板的 html-pdf

在我的应用程序中,当用户通过测试时,会自动生成一个文凭(pdf)。这是我通过使用html-pdfnode-module来完成的,它检索html文件并将其转换为pdf。varfs=require('fs'),pdf=require('html-pdf'),path=require('path'),ejs=require('ejs');varhtml=fs.readFileSync('./phantomScripts/certificate.html','utf8');varoptions={filename:'businesscard.pdf',format:'A4',orientati

javascript - 当从客户端传递到 nodeJS 时,String 变成了 Object

我正在使用yeomanangular-fullstack来生成我的项目。所以客户端是angularJs(typeScript),后端是nodeJs。问题是我有一个变量,当我将它打印到控制台时,我得到一个很长的字符串(如果你需要知道它来自googleplacesapi的photo_reference)。当我通过http.get将其传递给nodeJSapi,并将其打印到日志时,我得到了响应对象对象。主Controllerfor(varphotoofresponse.data.result.photos){this.getImages(photo);console.log(photo.pho

javascript - NodeJS express 。 res.send() 在分配给另一个 var 时失败

我正在使用Expressv3.4.4。当我尝试这样做时:varcb=res.send;cb(result);我得到一个错误:...\node_modules\express\lib\response.js:84varHEAD='HEAD'==req.method;TypeError:Cannotreadproperty'method'ofundefined在代码中,工作一个:workflow.on('someEvent',function(){res.send({error:null,result:'Result'});});不工作:workflow.on('someEvent',fu

javascript - Safari 12 不会下载 PDF blob

此代码用于通过blob下载pdf。它在除适用于macOS和iOS的Safari12之外的所有浏览器上都能正常工作。即使是Safari11也能正常工作。当我第一次运行代码时,它工作正常,但之后每次它都会给我“WebKitBlobResourceerror1”functiondownloadFileFromBlob(fileBlob,fileName){if(/\bMSIE\b|\bTrident\b/.test($window.navigator.userAgent)){$window.navigator.msSaveOrOpenBlob(fileBlob,fileName);}else

javascript - Nodejs EventEmitter.once() 如何工作?

来自nodejssourcecode(LOC179),我们有以下内容:EventEmitter.prototype.once=function(type,listener){/**...**/functiong(){/**...**/}g.listener=listener;//=>???this.on(type,g);returnthis;};到目前为止,我的想法是这样的:EventEmitter.once()设置一个type事件,并在通过调用回调listener后立即将其删除g()。但是g.listener=listener;这行到底做了什么?它是否在构造函数g()调用时为构造函数

javascript - Nodejs Passport - 使用多个谷歌策略

我不确定这是否可行,但我想使用多种Google策略,以便根据链接/用户使用一组不同的范围。我创建了两个单独的Passport变量:passport=require('passport')passport2=require('passport')我对它们进行了如下设置:passport.use(newGoogleStrategy({clientID:GOOGLE_CLIENT_ID,clientSecret:GOOGLE_CLIENT_SECRET,callbackURL:"http://localhost:3000/auth/callback"},function(accessToke

javascript - NodeJS & Socket.IO : Emit a request event and get the response, 我应该何时/何地绑定(bind)监听器?

我目前想知道在这种情况下什么是最佳编程实践:假设我已将客户端连接到我的服务器。这个客户端要求服务器使用auth事件和他的用户名进行身份验证。socket=io();socket.emit('auth',"John");在这个简单的例子中,服务器响应一个带有用户ID的auth_succeed事件。io.on('connection',function(socket){socket.on('auth',function(username){socket.emit('auth_succeed',id);}}所以我的问题是,我应该在何时何地为客户端中的auth_succeed事件绑定(bind

javascript - 带有 Socket.IO 的 NodeJS 延迟发送数据

我使用的示例来自Socket.IO主页(http://socket.io/)。它可以正常工作,但在发送数据和另一端接收数据之间存在巨大的延迟。我正在使用XAMPP,我的目录中有socket.html,并在我的浏览器中使用“http://localhost/socket.html”导航到它,我让服务器监听端口8080。服务器:vario=require('socket.io').listen(8080);io.sockets.on('connection',function(socket){socket.emit('news',{hello:'world'});socket.on('my

javascript - 将 PHP hash_hmac(sha512) 转换为 NodeJS

我正在移植一个php脚本到node,我对加密不是很了解。php脚本使用了这个函数:hash_hmac('sha512',text,key);因此,我需要在Nodejs中实现一个函数,以使用hmac方法(SHA512)返回键控哈希。据我所知,Node通过加密模块(http://nodejs.org/docs/latest/api/crypto.html#crypto_crypto)内置了此功能——但我不清楚如何重现此功能。如有任何帮助,我们将不胜感激。谢谢, 最佳答案 是的,使用加密库。varhash=crypto.createHma

javascript - 如何在 selenium-webdriver nodejs land 中更改 selenium 用户代理?

我在javascript+mocha+node领域。我尝试将userAgent和'user-agent'设置为功能键:varwebdriver=require('selenium-webdriver');varua='Mozilla/5.0(iPhone;CPUiPhoneOS5_0likeMacOSX)';vardriver=newwebdriver.Builder()....withCapabilities({'browserName':'firefox',userAgent:ua,'user-agent':ua,}).build();有thisanswer其中说要使用firefo