/** * <summary>Gets the object equivalent to the given value.</summary> */ public static PdfDirectObject Get( object value ) { if (value == null) { return(null); } if (value is int) { return(PdfInteger.Get((int)value)); } if (value is double || value is float) { return(PdfReal.Get(value)); } if (value is string) { return(PdfTextString.Get((string)value)); } if (value is DateTime) { return(PdfDate.Get((DateTime)value)); } if (value is bool) { return(PdfBoolean.Get((bool)value)); } throw new NotImplementedException(); }
/** * <summary>Gets the color corresponding to the specified table index resolved according to * the <see cref="BaseSpace">base space</see>.<summary> */ public Color GetBaseColor(IndexedColor color) { int colorIndex = color.Index; if (!baseColors.TryGetValue(colorIndex, out var baseColor)) { ColorSpace baseSpace = BaseSpace; IList <PdfDirectObject> components = new List <PdfDirectObject>(); { int componentCount = baseSpace.ComponentCount; int componentValueIndex = colorIndex * componentCount; byte[] baseComponentValues = BaseComponentValues; for (int componentIndex = 0; componentIndex < componentCount; componentIndex++) { var byteValue = componentValueIndex < baseComponentValues.Length ? baseComponentValues[componentValueIndex] : 0; var value = ((int)byteValue & 0xff) / 255d; components.Add(PdfReal.Get(value)); componentValueIndex++; } } baseColor = baseColors[colorIndex] = baseSpace.GetColor(components, null); } return(baseColor); }
public DeviceRGBColor(double r, double g, double b) : this(new PdfArray( PdfReal.Get(NormalizeComponent(r)), PdfReal.Get(NormalizeComponent(g)), PdfReal.Get(NormalizeComponent(b)))) { }
/** * <summary>Creates a new destination within the given document context.</summary> * <param name="context">Document context.</param> * <param name="pageObject">Page reference. It may be either an actual page reference (PdfReference) * or a page index (PdfInteger).</param> * <param name="mode">Destination mode.</param> * <param name="viewParams">View parameters. Their actual composition depends on the <code>mode</code> value * (see ModeEnum for more info).</param> */ protected Destination( Document context, PdfDirectObject pageObject, ModeEnum mode, float?[] viewParams ) : base( context.File, new PdfArray() ) { PdfArray destinationObject = BaseDataObject; destinationObject.Add(pageObject); switch (mode) { case ModeEnum.Fit: destinationObject.Add(PdfName.Fit); break; case ModeEnum.FitBoundingBox: destinationObject.Add(PdfName.FitB); break; case ModeEnum.FitBoundingBoxHorizontal: destinationObject.Add(PdfName.FitBH); destinationObject.Add(PdfReal.Get(viewParams[0])); break; case ModeEnum.FitBoundingBoxVertical: destinationObject.Add(PdfName.FitBV); destinationObject.Add(PdfReal.Get(viewParams[0])); break; case ModeEnum.FitHorizontal: destinationObject.Add(PdfName.FitH); destinationObject.Add(PdfReal.Get(viewParams[0])); break; case ModeEnum.FitRectangle: destinationObject.Add(PdfName.FitR); destinationObject.Add(PdfReal.Get(viewParams[0])); destinationObject.Add(PdfReal.Get(viewParams[1])); destinationObject.Add(PdfReal.Get(viewParams[2])); destinationObject.Add(PdfReal.Get(viewParams[3])); break; case ModeEnum.FitVertical: destinationObject.Add(PdfName.FitV); destinationObject.Add(PdfReal.Get(viewParams[0])); break; case ModeEnum.XYZ: destinationObject.Add(PdfName.XYZ); destinationObject.Add(PdfReal.Get(viewParams[0])); destinationObject.Add(PdfReal.Get(viewParams[1])); destinationObject.Add(PdfReal.Get(viewParams[2])); break; } }
protected void SetComponentValue( int index, double value ) { Components[index] = PdfReal.Get(NormalizeComponent(value)); }
/** * <summary>Gets the color corresponding to the specified table index resolved according to * the <see cref="BaseSpace">base space</see>.<summary> */ public Color GetBaseColor( IndexedColor color ) { int colorIndex = color.Index; Color baseColor = baseColors[colorIndex]; if (baseColor == null) { ColorSpace baseSpace = BaseSpace; IList <PdfDirectObject> components = new List <PdfDirectObject>(); { int componentCount = baseSpace.ComponentCount; int componentValueIndex = colorIndex * componentCount; byte[] baseComponentValues = BaseComponentValues; for ( int componentIndex = 0; componentIndex < componentCount; componentIndex++ ) { components.Add( PdfReal.Get(((int)baseComponentValues[componentValueIndex++] & 0xff) / 255d) ); } } baseColor = baseSpace.GetColor(components, null); } return(baseColor); }
/** * <summary>Gets the result of the calculation applied by this function * to the specified input values.</summary> * <param name="inputs">Input values.</param> */ public IList <PdfDirectObject> Calculate( IList <PdfDirectObject> inputs ) { IList <PdfDirectObject> outputs = new List <PdfDirectObject>(); { double[] inputValues = new double[inputs.Count]; for ( int index = 0, length = inputValues.Length; index < length; index++ ) { inputValues[index] = ((IPdfNumber)inputs[index]).RawValue; } double[] outputValues = Calculate(inputValues); for ( int index = 0, length = outputValues.Length; index < length; index++ ) { outputs.Add(PdfReal.Get(outputValues[index])); } } return(outputs); }
public Line(Page page, SKPoint startPoint, SKPoint endPoint, string text, DeviceRGBColor color) : base(page, PdfName.Line, SKRect.Create(startPoint.X, startPoint.Y, endPoint.X - startPoint.X, endPoint.Y - startPoint.Y), text) { BaseDataObject[PdfName.L] = new PdfArray(new PdfDirectObject[] { PdfReal.Get(0), PdfReal.Get(0), PdfReal.Get(0), PdfReal.Get(0) }); StartPoint = startPoint; EndPoint = endPoint; Color = color; }
public DeviceCMYKColor(double c, double m, double y, double k) : this( new PdfArray( PdfReal.Get(NormalizeComponent(c)), PdfReal.Get(NormalizeComponent(m)), PdfReal.Get(NormalizeComponent(y)), PdfReal.Get(NormalizeComponent(k)))) { }
public DeviceRGBColor(double r, double g, double b) : this(new PdfDirectObject[] { PdfReal.Get(NormalizeComponent(r)), PdfReal.Get(NormalizeComponent(g)), PdfReal.Get(NormalizeComponent(b)) }) { }
/* * TODO:colors MUST be instantiated only indirectly by the ColorSpace.getColor method! * This method MUST be made internal and its color space MUST be passed as argument! */ public LabColor(double l, double a, double b) : this( new PdfArray( PdfReal.Get(NormalizeComponent(l)),//TODO:normalize using the actual color space ranges!!! PdfReal.Get(NormalizeComponent(a)), PdfReal.Get(NormalizeComponent(b)) ) ) { }
public CalGrayColor( double g ) : this( new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(NormalizeComponent(g)) } ) ) { }
public SetCharSpace(double value) : base( OperatorKeyword, new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(value) } ) ) { }
/** * <param name="pointX">Current point X.</param> * <param name="pointY">Current point Y.</param> */ public BeginSubpath(double pointX, double pointY) : base(OperatorKeyword, new List <PdfDirectObject>(new PdfDirectObject[] { PdfReal.Get(pointX), PdfReal.Get(pointY) } ) ) { }
private void EnsureSpaceOperation( ) { if (@operator.Equals(SimpleOperatorKeyword)) { @operator = SpaceOperatorKeyword; operands.Insert(0, PdfReal.Get(0)); operands.Insert(1, PdfReal.Get(0)); } }
private static IList <PdfDirectObject> GetComponentValues(params double[] components) {// TODO:normalize parameters! IList <PdfDirectObject> componentValues = new List <PdfDirectObject>(); foreach (double component in components) { componentValues.Add(PdfReal.Get((component))); } return(componentValues); }
public TranslateTextRelative( double offsetX, double offsetY, bool leadSet ) : base( leadSet ? LeadOperatorKeyword : SimpleOperatorKeyword, PdfReal.Get(offsetX), PdfReal.Get(offsetY) ) { }
public SetTextMatrix(double a, double b, double c, double d, double e, double f) : base(OperatorKeyword, PdfReal.Get(a), PdfReal.Get(b), PdfReal.Get(c), PdfReal.Get(d), PdfReal.Get(e), PdfReal.Get(f) ) { }
/** * <param name="text">Text encoded using current font's encoding.</param> * <param name="wordSpace">Word spacing.</param> * <param name="charSpace">Character spacing.</param> */ public ShowTextToNextLine( byte[] text, double wordSpace, double charSpace ) : base( SpaceOperatorKeyword, PdfReal.Get(wordSpace), PdfReal.Get(charSpace), new PdfByteString(text) ) { }
public SeparationColor( double intensity ) : this( new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(intensity) //TODO:normalize value (see devicecolor)! } ) ) { }
public DeviceCMYKColor(double c, double m, double y, double k) : this( new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(NormalizeComponent(c)), PdfReal.Get(NormalizeComponent(m)), PdfReal.Get(NormalizeComponent(y)), PdfReal.Get(NormalizeComponent(k)) } ) ) { }
/** * <summary>Creates a fully-explicit curve.</summary> */ public DrawCurve(double pointX, double pointY, double control1X, double control1Y, double control2X, double control2Y) : base(FullOperatorKeyword, new List <PdfDirectObject>(new PdfDirectObject[] { PdfReal.Get(control1X), PdfReal.Get(control1Y), PdfReal.Get(control2X), PdfReal.Get(control2Y), PdfReal.Get(pointX), PdfReal.Get(pointY) } ) ) { }
/** * <summary>Creates a partially-explicit curve.</summary> * <param name="point">Final endpoint.</param> * <param name="control">Explicit control point.</param> * <param name="operator">Operator (either <code>InitialOperator</code> or <code>FinalOperator</code>). * It defines how to interpret the <code>control</code> parameter.</param> */ public DrawCurve(SKPoint point, SKPoint control, string @operator) : base(@operator.Equals(InitialOperatorKeyword, StringComparison.Ordinal) ? InitialOperatorKeyword : FinalOperatorKeyword, new List <PdfDirectObject>(new PdfDirectObject[] { PdfReal.Get(control.X), PdfReal.Get(control.Y), PdfReal.Get(point.X), PdfReal.Get(point.Y) } ) ) { }
public CalRGBColor( double r, double g, double b ) : this( new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(NormalizeComponent(r)), PdfReal.Get(NormalizeComponent(g)), PdfReal.Get(NormalizeComponent(b)) } ) ) { }
/* * TODO:colors MUST be instantiated only indirectly by the ColorSpace.getColor method! * This method MUST be made internal and its color space MUST be passed as argument! */ public LabColor( double l, double a, double b ) : this( new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(NormalizeComponent(l)),//TODO:normalize using the actual color space ranges!!! PdfReal.Get(NormalizeComponent(a)), PdfReal.Get(NormalizeComponent(b)) } ) ) { }
public ModifyCTM(double a, double b, double c, double d, double e, double f) : base(OperatorKeyword, new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(a), PdfReal.Get(b), PdfReal.Get(c), PdfReal.Get(d), PdfReal.Get(e), PdfReal.Get(f) } ) ) { }
/** * <summary>Creates a partially-explicit curve.</summary> * <param name="point">Final endpoint.</param> * <param name="control">Explicit control point.</param> * <param name="operator">Operator (either <code>InitialOperator</code> or <code>FinalOperator</code>). * It defines how to interpret the <code>control</code> parameter.</param> */ public DrawCurve( PointF point, PointF control, string @operator ) : base( @operator.Equals(InitialOperatorKeyword) ? InitialOperatorKeyword : FinalOperatorKeyword, new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(control.X), PdfReal.Get(control.Y), PdfReal.Get(point.X), PdfReal.Get(point.Y) } ) ) { }
public DrawRectangle( double x, double y, double width, double height ) : base( OperatorKeyword, new List <PdfDirectObject>( new PdfDirectObject[] { PdfReal.Get(x), PdfReal.Get(y), PdfReal.Get(width), PdfReal.Get(height) } ) ) { }
public CalloutLine(Page page, SKPoint start, SKPoint?knee, SKPoint end) : base(new PdfArray()) { SKMatrix matrix = page.InRotateMatrix; PdfArray baseDataObject = BaseDataObject; { start = matrix.MapPoint(start); baseDataObject.Add(PdfReal.Get(start.X)); baseDataObject.Add(PdfReal.Get(start.Y)); if (knee.HasValue) { knee = matrix.MapPoint(knee.Value); baseDataObject.Add(PdfReal.Get(knee.Value.X)); baseDataObject.Add(PdfReal.Get(knee.Value.Y)); } end = matrix.MapPoint(end); baseDataObject.Add(PdfReal.Get(end.X)); baseDataObject.Add(PdfReal.Get(end.Y)); } }
public Line( Page page, PointF startPoint, PointF endPoint, string text ) : base( page, PdfName.Line, new RectangleF( startPoint.X, startPoint.Y, endPoint.X - startPoint.X, endPoint.Y - startPoint.Y ), text ) { BaseDataObject[PdfName.L] = new PdfArray(new PdfDirectObject[] { PdfReal.Get(0), PdfReal.Get(0), PdfReal.Get(0), PdfReal.Get(0) }); StartPoint = startPoint; EndPoint = endPoint; }