pdf.js
Version:
A PDF generation library for Node.js
29 lines (21 loc) • 633 B
text/coffeescript
###
PDFImage - embeds images in PDF documents
By Devon Govett
###
fs = require 'fs'
Data = require './data'
JPEG = require './image/jpeg'
class PDFImage
: (filename) ->
= fs.readFileSync filename
return unless
= new Data
= null
# load info
data =
firstByte = data.byteAt(0)
if firstByte is 0xFF and data.byteAt(1) is 0xD8
return new JPEG(data)
else
throw new Error 'Unknown image format.'
module.exports = PDFImage