mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
34 lines
771 B
CoffeeScript
34 lines
771 B
CoffeeScript
###
|
|
PDFObjectStore - stores the object heirarchy for the PDF document
|
|
By Devon Govett
|
|
###
|
|
|
|
PDFReference = require './reference'
|
|
|
|
class PDFObjectStore
|
|
constructor: ->
|
|
@objects = {}
|
|
@length = 0
|
|
|
|
@root = @ref
|
|
Type: 'Catalog'
|
|
Pages: @ref
|
|
Type: 'Pages'
|
|
Count: 0
|
|
Kids: []
|
|
|
|
@pages = @root.data['Pages']
|
|
|
|
ref: (data) ->
|
|
@push ++@length, data
|
|
|
|
push: (id, data) ->
|
|
ref = new PDFReference(id, data)
|
|
@objects[id] = ref
|
|
return ref
|
|
|
|
addPage: (page) ->
|
|
@pages.data['Kids'].push(page.dictionary)
|
|
@pages.data['Count']++
|
|
|
|
module.exports = PDFObjectStore |