mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Add ability to add base64 URI images
This commit is contained in:
parent
16e8b0316f
commit
2b34173dec
@ -13,8 +13,13 @@ class PDFImage
|
||||
if Buffer.isBuffer(src)
|
||||
data = src
|
||||
else
|
||||
data = fs.readFileSync src
|
||||
return unless data
|
||||
if src[0..4] is 'data:' and src.indexOf(';base64,') > -1
|
||||
base64String = src.split(';base64,')[1]
|
||||
data = new Buffer(base64String, 'base64')
|
||||
|
||||
else
|
||||
data = fs.readFileSync src
|
||||
return unless data
|
||||
|
||||
if data[0] is 0xff and data[1] is 0xd8
|
||||
return new JPEG(data, label)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user