我想使用 Google Cloud Print API 发送要打印的 PDF 文件。下面的代码会给我一个积极的消息,告诉我生成了一个页面。当我去检查结果时,我打开了一个空白页面。
如果我将打印件保存在 Google Drive 上,也会出现同样的结果。
编码
unirest.post('https://www.google.com/cloudprint/submit')
.header('Authorization', 'Bearer ' + token)
.header("Accept-Charset", "utf-8")
.field('xsrf', xsrf_token)
.field('printerid', printerId)
.field('ticket', '{"version": "1.0", "print": {}}')
.field('title', 'Test from Simpe.li')
.field('contentType', 'application/pdf')
.attach('content', buffer)
.end(function (res) {
console.log(res);
});
我知道我发送的是 PDF,因为当我更改
.field('contentType', 'application/pdf')
至
.field('contentType', 'text/plain')
我将获得 53 页文本,这是 PDF 文件的原始内容。
问题
我做错了什么?
技术规格
- NodeJS v4.1.1
- 统一 v0.4.2