iTextSharp.text.pdf.PdfContentByte.SetColorStroke C# (CSharp) Метод

SetColorStroke() публичный Метод

public SetColorStroke ( BaseColor value ) : void
value BaseColor
Результат void
        public virtual void SetColorStroke(BaseColor value)
        {
            PdfWriter.CheckPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_COLOR, value);
            int type = ExtendedColor.GetType(value);
            switch (type) {
                case ExtendedColor.TYPE_GRAY: {
                    SetGrayStroke(((GrayColor)value).Gray);
                    break;
                }
                case ExtendedColor.TYPE_CMYK: {
                    CMYKColor cmyk = (CMYKColor)value;
                    SetCMYKColorStrokeF(cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black);
                    break;
                }
                case ExtendedColor.TYPE_SEPARATION: {
                    SpotColor spot = (SpotColor)value;
                    SetColorStroke(spot.PdfSpotColor, spot.Tint);
                    break;
                }
                case ExtendedColor.TYPE_PATTERN: {
                    PatternColor pat = (PatternColor)value;
                    SetPatternStroke(pat.Painter);
                    break;
                }
                case ExtendedColor.TYPE_SHADING: {
                    ShadingColor shading = (ShadingColor)value;
                    SetShadingStroke(shading.PdfShadingPattern);
                    break;
                }
                default:
                    SetRGBColorStroke(value.R, value.G, value.B);
                    break;
            }
        }

Same methods

PdfContentByte::SetColorStroke ( PdfSpotColor sp, float tint ) : void

Usage Example

Пример #1
0
        /// <summary>
        /// Renders the object in a document using a <see cref="PdfContentByte"/> by invoking the <see cref="Render(ContentWriter, Vector2D)"/> method.
        /// This method can be overridden in derived classes to specify rendering.
        /// </summary>
        /// <param name="cb">The <see cref="PdfContentByte"/> used for rendering.</param>
        /// <param name="offset">The calculated offset for the rendered item.</param>
        protected internal virtual void Render(PdfContentByte cb, Vector2D offset)
        {
            using (var writer = new ContentWriter(cb))
            {
                var stroke = this as StrokeObject;
                var fill = this as FillObject;

                bool hasstroke = stroke?.BorderColor.HasValue ?? false;
                bool hasfill = fill?.FillColor.HasValue ?? false;

                if (hasstroke)
                {
                    cb.SetLineWidth((float)stroke.BorderWidth.Value(UnitsOfMeasure.Points));
                    cb.SetColorStroke(new Color(stroke.BorderColor.Value));
                }
                if (hasfill)
                    cb.SetColorFill(new Color(fill.FillColor.Value));

                Render(writer, offset);

                if (hasstroke && hasfill)
                {
                    if (writer.CloseShape)
                        cb.ClosePathFillStroke();
                    else
                        cb.FillStroke();
                }
                else if (hasstroke)
                {
                    if (writer.CloseShape)
                        cb.ClosePathStroke();
                    else
                        cb.Stroke();
                }
                else if (hasfill)
                    cb.Fill();
            }
        }
All Usage Examples Of iTextSharp.text.pdf.PdfContentByte::SetColorStroke
PdfContentByte