aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/pdf/PDFResourceContext.java
blob: 77039ab88439709e73f935ff64f96422162fdd32 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * $Id$
 * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
 * For details on use and redistribution please refer to the
 * LICENSE file included with these sources.
 */

package org.apache.fop.pdf;

/**
 * class representing a /Page object.
 *
 * There is one of these for every page in a PDF document. The object
 * specifies the dimensions of the page and references a /Resources
 * object, a contents stream and the page's parent in the page
 * hierarchy.
 * 
 * Modified by Mark Lillywhite, mark-fop@inomial.com. The Parent
 * object was being referred to by reference, but all that we
 * ever used from the Parent was it's PDF object ID, and according
 * to the memory profile this was causing OOM issues. So, we store
 * only the object ID of the parent, rather than the parent itself.
 */
public class PDFResourceContext extends PDFObject {

    /**
     * the page's /Resource object
     */
    protected PDFResources resources;

    /**
     * the list of annotation objects for this page
     */
    protected PDFAnnotList annotList;
    protected PDFDocument document;

    /**
     *
     * @param number the object's number
     * @param resources the /Resources object
     * @param contents the content stream
     * @param pagewidth the page's width in points
     * @param pageheight the page's height in points
     */
    public PDFResourceContext(int number, PDFDocument doc, PDFResources resources) {

        /* generic creation of object */
        super(number);

        /* set fields using parameters */
        this.document = doc;
        this.resources = resources;
        this.annotList = null;
    }

    public PDFResources getPDFResources() {
        return this.resources;
    }

    /**
     * set this page's annotation list
     *
     * @param annotList a PDFAnnotList list of annotations
     */
    public void addAnnotation(PDFObject annot) {
        if(this.annotList == null) {
            this.annotList = document.makeAnnotList();
        }
        this.annotList.addAnnot(annot);
    }

    public void addGState(PDFGState gstate) {
        this.resources.addGState(gstate);
    }

    public void addShading(PDFShading shading) {
        this.resources.addShading(shading);
    }

    public byte[] toPDF() {
        return null;
    }
}