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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
|
#region PDFsharp - A .NET library for processing PDF
//
// Authors:
// Stefan Lange (mailto:Stefan.Lange@pdfsharp.com)
//
// Copyright (c) 2005-2008 empira Software GmbH, Cologne (Germany)
//
// http://www.pdfsharp.com
// http://sourceforge.net/projects/pdfsharp
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#endregion
using System;
using System.Diagnostics;
using System.Collections;
using System.Text;
using System.IO;
#if GDI
using System.Drawing;
using System.Drawing.Imaging;
#endif
#if WPF
using System.Windows.Media;
#endif
using PdfSharp.Drawing;
using PdfSharp.Fonts.TrueType;
using PdfSharp.Internal;
namespace PdfSharp.Pdf.Advanced
{
/// <summary>
/// Represents an extended graphics state object.
/// </summary>
public sealed class PdfExtGState : PdfDictionary
{
/// <summary>
/// Initializes a new instance of the <see cref="PdfExtGState"/> class.
/// </summary>
/// <param name="document">The document.</param>
public PdfExtGState(PdfDocument document)
: base(document)
{
Elements.SetName(Keys.Type, "/ExtGState");
#if true_
//AIS false
//BM /Normal
//ca 1
//CA 1
//op false
//OP false
//OPM 1
//SA true
//SMask /None
//Type /ExtGState
Elements.SetValue(Keys.AIS, new PdfBoolean(false)); // The alpha source
Elements.SetName("/BM", "Normal");
Elements.SetValue(Keys.op, new PdfBoolean(false));
Elements.SetValue(Keys.OP, new PdfBoolean(false));
Elements.SetValue(Keys.OPM, new PdfInteger(1));
Elements.SetValue("/SA", new PdfBoolean(true));
Elements.SetName("/SMask", "None");
#endif
}
internal void SetDefault1()
{
//<<
// /AIS false
// /BM /Normal
// /ca 1
// /CA 1
// /op false
// /OP false
// /OPM 1
// /SA true
// /SMask /None
// /Type /ExtGState
//>>
Elements.SetBoolean(PdfExtGState.Keys.AIS, false);
Elements.SetName(PdfExtGState.Keys.BM, "/Normal");
StrokeAlpha = 1;
NonStrokeAlpha = 1;
Elements.SetBoolean(PdfExtGState.Keys.op, false);
Elements.SetBoolean(PdfExtGState.Keys.OP, false);
Elements.SetBoolean(PdfExtGState.Keys.SA, true);
Elements.SetName(PdfExtGState.Keys.SMask, "/None");
}
/// <summary>
/// ...for shading patterns
/// </summary>
internal void SetDefault2()
{
//<<
// /AIS false
// /BM /Normal
// /ca 1
// /CA 1
// /op true
// /OP true
// /OPM 1
// /SA true
// /SMask /None
// /Type /ExtGState
//>>
Elements.SetBoolean(PdfExtGState.Keys.AIS, false);
Elements.SetName(PdfExtGState.Keys.BM, "/Normal");
StrokeAlpha = 1;
NonStrokeAlpha = 1;
Elements.SetBoolean(PdfExtGState.Keys.op, true);
Elements.SetBoolean(PdfExtGState.Keys.OP, true);
Elements.SetInteger(PdfExtGState.Keys.OPM, 1);
Elements.SetBoolean(PdfExtGState.Keys.SA, true);
Elements.SetName(PdfExtGState.Keys.SMask, "/None");
}
/// <summary>
/// Sets the alpha value for stroking operations.
/// </summary>
public double StrokeAlpha
{
set { Elements.SetReal(Keys.CA, value); }
}
/// <summary>
/// Sets the alpha value for nonstroking operations.
/// </summary>
public double NonStrokeAlpha
{
set { Elements.SetReal(Keys.ca, value); }
}
/// <summary>
/// Sets a soft mask object.
/// </summary>
public PdfSoftMask SoftMask
{
set { Elements.SetReference(Keys.SMask, value); }
}
/// <summary>
/// Common keys for all streams.
/// </summary>
internal sealed class Keys : KeysBase
{
/// <summary>
/// (Optional) The type of PDF object that this dictionary describes;
/// must be ExtGState for a graphics state parameter dictionary.
/// </summary>
[KeyInfo(KeyType.Name | KeyType.Optional)]
public const string Type = "/Type";
/// <summary>
/// (Optional; PDF 1.3) The line width (see Line Width on page 185).
/// </summary>
[KeyInfo(KeyType.Real | KeyType.Optional)]
public const string LW = "/LW";
/// <summary>
/// (Optional; PDF 1.3) The line cap style.
/// </summary>
[KeyInfo(KeyType.Integer | KeyType.Optional)]
public const string LC = "/LC";
/// <summary>
/// (Optional; PDF 1.3) The line join style.
/// </summary>
[KeyInfo(KeyType.Integer | KeyType.Optional)]
public const string LJ = "/LJ";
/// <summary>
/// (Optional; PDF 1.3) The miter limit.
/// </summary>
[KeyInfo(KeyType.Real | KeyType.Optional)]
public const string ML = "/ML";
/// <summary>
/// (Optional; PDF 1.3) The line dash pattern, expressed as an array of the form
/// [dashArray dashPhase], where dashArray is itself an array and dashPhase is an integer.
/// </summary>
[KeyInfo(KeyType.Array | KeyType.Optional)]
public const string D = "/D";
/// <summary>
/// (Optional; PDF 1.3) The name of the rendering intent.
/// </summary>
[KeyInfo(KeyType.Name | KeyType.Optional)]
public const string RI = "/RI";
/// <summary>
/// (Optional) A flag specifying whether to apply overprint. In PDF 1.2 and earlier,
/// there is a single overprint parameter that applies to all painting operations.
/// Beginning with PDF 1.3, there are two separate overprint parameters: one for stroking
/// and one for all other painting operations. Specifying an OP entry sets both parameters
/// unless there is also an op entry in the same graphics state parameter dictionary, in
/// which case the OP entry sets only the overprint parameter for stroking.
/// </summary>
[KeyInfo(KeyType.Boolean | KeyType.Optional)]
public const string OP = "/OP";
/// <summary>
/// (Optional; PDF 1.3) A flag specifying whether to apply overprint for painting operations
/// other than stroking. If this entry is absent, the OP entry, if any, sets this parameter.
/// </summary>
[KeyInfo(KeyType.Boolean | KeyType.Optional)]
public const string op = "/op";
/// <summary>
/// (Optional; PDF 1.3) The overprint mode.
/// </summary>
[KeyInfo(KeyType.Integer | KeyType.Optional)]
public const string OPM = "/OPM";
/// <summary>
/// (Optional; PDF 1.3) An array of the form [font size], where font is an indirect
/// reference to a font dictionary and size is a number expressed in text space units.
/// These two objects correspond to the operands of the Tf operator; however,
/// the first operand is an indirect object reference instead of a resource name.
/// </summary>
[KeyInfo(KeyType.Array | KeyType.Optional)]
public const string Font = "/Font";
/// <summary>
/// (Optional) The black-generation function, which maps the interval [0.0 1.0]
/// to the interval [0.0 1.0].
/// </summary>
[KeyInfo(KeyType.Function | KeyType.Optional)]
public const string BG = "/BG";
/// <summary>
/// (Optional; PDF 1.3) Same as BG except that the value may also be the name Default,
/// denoting the black-generation function that was in effect at the start of the page.
/// If both BG and BG2 are present in the same graphics state parameter dictionary,
/// BG2 takes precedence.
/// </summary>
[KeyInfo(KeyType.FunctionOrName | KeyType.Optional)]
public const string BG2 = "/BG2";
/// <summary>
/// (Optional) The undercolor-removal function, which maps the interval
/// [0.0 1.0] to the interval [-1.0 1.0].
/// </summary>
[KeyInfo(KeyType.Function | KeyType.Optional)]
public const string UCR = "/UCR";
/// <summary>
/// (Optional; PDF 1.3) Same as UCR except that the value may also be the name Default,
/// denoting the undercolor-removal function that was in effect at the start of the page.
/// If both UCR and UCR2 are present in the same graphics state parameter dictionary,
/// UCR2 takes precedence.
/// </summary>
[KeyInfo(KeyType.FunctionOrName | KeyType.Optional)]
public const string UCR2 = "/UCR2";
//TR function, array, or name
//TR2 function, array, or name
//HT dictionary, stream, or name
//FL number
//SM number
/// <summary>
/// (Optional) A flag specifying whether to apply automatic stroke adjustment.
/// </summary>
[KeyInfo(KeyType.Boolean | KeyType.Optional)]
public const string SA = "/SA";
/// <summary>
/// (Optional; PDF 1.4) The current blend mode to be used in the transparent imaging model.
/// </summary>
[KeyInfo(KeyType.NameOrArray | KeyType.Optional)]
public const string BM = "/BM";
/// <summary>
/// (Optional; PDF 1.4) The current soft mask, specifying the mask shape or
/// mask opacity values to be used in the transparent imaging model.
/// </summary>
[KeyInfo(KeyType.NameOrDictionary | KeyType.Optional)]
public const string SMask = "/SMask";
/// <summary>
/// (Optional; PDF 1.4) The current stroking alpha constant, specifying the constant
/// shape or constant opacity value to be used for stroking operations in the transparent
/// imaging model.
/// </summary>
[KeyInfo(KeyType.Real | KeyType.Optional)]
public const string CA = "/CA";
/// <summary>
/// (Optional; PDF 1.4) Same as CA, but for nonstroking operations.
/// </summary>
[KeyInfo(KeyType.Real | KeyType.Optional)]
public const string ca = "/ca";
/// <summary>
/// (Optional; PDF 1.4) The alpha source flag (alpha is shape), specifying whether
/// the current soft mask and alpha constant are to be interpreted as shape values (true)
/// or opacity values (false).
/// </summary>
[KeyInfo(KeyType.Boolean | KeyType.Optional)]
public const string AIS = "/AIS";
/// <summary>
/// (Optional; PDF 1.4) The text knockout flag, which determines the behavior of
/// overlapping glyphs within a text object in the transparent imaging model.
/// </summary>
[KeyInfo(KeyType.Boolean | KeyType.Optional)]
public const string TK = "/TK";
/// <summary>
/// Gets the KeysMeta for these keys.
/// </summary>
internal static DictionaryMeta Meta
{
get
{
if (Keys.meta == null)
Keys.meta = CreateMeta(typeof(Keys));
return Keys.meta;
}
}
static DictionaryMeta meta;
}
/// <summary>
/// Gets the KeysMeta of this dictionary type.
/// </summary>
internal override DictionaryMeta Meta
{
get { return Keys.Meta; }
}
}
}
|