I am using PDFKit
in NodeJS to add some images to a PDF document. One of the examples is this:
我在NodeJS中使用PDFKit将一些图像添加到PDF文档中。其中一个例子是:
# Fit the image within the dimensions
doc.image('images/test.jpeg', 320, 15, fit: [100, 100])
.rect(320, 15, 100, 100)
.stroke()
.text('Fit', 320, 0)
I am using pure JS instead of coffeescript and I do not understand how the first line works. How's a key-value pair being passed in as the argument and what'd be the JS equivalent?
我使用纯JS而不是coffeescript,我不明白第一行是如何工作的。如何将键值对作为参数传递,JS等同于什么?
Docs here: http://pdfkit.org/docs/images.html
文档:http://pdfkit.org/docs/images.html
1 个解决方案
#1
2
Here's the javascript equivalent
这是javascript等价物
doc.image('images/test.jpeg', 320, 15, {
fit: [100, 100]
}).rect(320, 15, 100, 100).stroke().text('Fit', 320, 0);
coffee objects don't need curly brackets in many cases. check out http://js2.coffee/ to convert back and forth between coffee and vanilla javascript
在许多情况下,咖啡对象不需要花括号。看看http://js2.coffee/在咖啡和香草javascript之间来回转换
#1
2
Here's the javascript equivalent
这是javascript等价物
doc.image('images/test.jpeg', 320, 15, {
fit: [100, 100]
}).rect(320, 15, 100, 100).stroke().text('Fit', 320, 0);
coffee objects don't need curly brackets in many cases. check out http://js2.coffee/ to convert back and forth between coffee and vanilla javascript
在许多情况下,咖啡对象不需要花括号。看看http://js2.coffee/在咖啡和香草javascript之间来回转换