forked from jonathanverner/comment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpodofo.patch
117 lines (113 loc) · 4.09 KB
/
podofo.patch
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Index: PdfAnnotation.h
===================================================================
--- PdfAnnotation.h (revision 967)
+++ PdfAnnotation.h (working copy)
@@ -294,6 +294,62 @@
*/
void SetQuadPoints( const PdfArray & rQuadPoints );
+ /** Get the color key of the Annotation dictionary
+ * which defines the color of the annotation,
+ * as per 8.4 of the pdf spec. The PdfArray contains
+ * 0 to four numbers, depending on the colorspace in
+ * which the color is specified
+ * 0 numbers means the annotation is transparent
+ * 1 number specifies the intensity of the color in grayscale
+ * 3 numbers specifie the color in the RGB colorspace and
+ * 4 numbers specify the color in the CMYK colorspace
+ *
+ * \returns a PdfArray of either 0, 1, 3 or 4 numbers
+ * depending on the colorspace in which the color
+ * is specified
+ */
+
+ PdfArray GetColor() const;
+
+ /** Set the C key of the Annotation dictionary, which defines the
+ * color of the annotation, as per 8.4 of the pdf spec. Parameters
+ * give the color in rgb colorspace coordinates
+ *
+ * \param r number from 0 to 1, the intensity of the red channel
+ * \param g number from 0 to 1, the intensity of the green channel
+ * \param b number from 0 to 1, the intensity of the blue channel
+ */
+
+ void SetColor( double r, double g, double b );
+
+ /** Set the C key of the Annotation dictionary, which defines the
+ * color of the annotation, as per 8.4 of the pdf spec. Parameters
+ * give the color in cmyk colorspace coordinates
+ *
+ * \param c number from 0 to 1, the intensity of the cyan channel
+ * \param m number from 0 to 1, the intensity of the magneta channel
+ * \param y number from 0 to 1, the intensity of the yellow channel
+ * \param k number from 0 to 1, the intensity of the black channel
+ */
+
+ void SetColor( double c, double m, double y, double k );
+
+ /** Set the C key of the Annotation dictionary, which defines the
+ * color of the annotation, as per 8.4 of the pdf spec. Parameters
+ * give the color in grayscale colorspace coordinates
+ *
+ * \param gray number from 0 to 1, the intensity of the black
+ */
+
+ void SetColor( double gray );
+
+ /** Set the C key of the Annotation dictionary to an empty array, which,
+ * as per 8.4 of the pdf spec., makes the annotation transparent
+ *
+ */
+
+ void SetColor();
+
/** Get the type of this annotation
* \returns the annotation type
*/
Index: PdfAnnotation.cpp
===================================================================
--- PdfAnnotation.cpp (revision 967)
+++ PdfAnnotation.cpp (working copy)
@@ -272,10 +272,44 @@
void PdfAnnotation::SetQuadPoints( const PdfArray & rQuadPoints )
{
- if ( m_eAnnotation == ePdfAnnotation_Highlight )
+ if ( m_eAnnotation != ePdfAnnotation_Highlight )
PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Must be a highlight annotation to set quad points" );
m_pObject->GetDictionary().AddKey( "QuadPoints", rQuadPoints );
}
+PdfArray PdfAnnotation::GetColor() const
+{
+ if( m_pObject->GetDictionary().HasKey( "C" ) )
+ return PdfArray( m_pObject->GetDictionary().GetKey( "C" )->GetArray() );
+ return PdfArray();
+}
+
+void PdfAnnotation::SetColor( double r, double g, double b ) {
+ PdfArray c;
+ c.push_back( PdfVariant( r ) );
+ c.push_back( PdfVariant( g ) );
+ c.push_back( PdfVariant( b ) );
+ m_pObject->GetDictionary().AddKey( "C", c );
+}
+void PdfAnnotation::SetColor( double C, double M, double Y, double K ) {
+ PdfArray c;
+ c.push_back( PdfVariant( C ) );
+ c.push_back( PdfVariant( M ) );
+ c.push_back( PdfVariant( Y ) );
+ c.push_back( PdfVariant( K ) );
+ m_pObject->GetDictionary().AddKey( "C", c );
+}
+
+void PdfAnnotation::SetColor( double gray ) {
+ PdfArray c;
+ c.push_back( PdfVariant( gray ) );
+ m_pObject->GetDictionary().AddKey( "C", c );
+}
+
+void PdfAnnotation::SetColor() {
+ PdfArray c;
+ m_pObject->GetDictionary().AddKey( "C", c );
+}
+
};