-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.go
39 lines (31 loc) · 891 Bytes
/
page.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package davepdf
import "fmt"
type PdfPage struct {
id int
parent *PdfPageTree
instructions *PdfInstructions // to be compiled into contents below
contents *PdfContents
}
func (pdf *Pdf) newPage() *PdfPage {
page := &PdfPage{}
pdf.newObjId()
page.id = pdf.n
page.parent = pdf.pageTree
page.contents = pdf.newContents()
page.instructions = pdf.newInstructions()
pdf.pageTree.pages = append(pdf.pageTree.pages, page)
return page
}
func (pdf *Pdf) writePage() {
for _, page := range pdf.pageTree.pages {
pdf.newObj(page.id)
pdf.outln("<<")
pdf.outln(" /Type /Page")
pdf.outln(" /MediaBox [0 0 612 792]")
pdf.outln(fmt.Sprintf(" /Parent %d 0 R", pdf.pageTree.id))
pdf.outln(fmt.Sprintf(" /Contents %d 0 R", page.contents.id))
pdf.outln(fmt.Sprintf(" /Resources %d 0 R", pdf.resources.id))
pdf.outln(">>")
pdf.outln("endobj\n")
}
}