當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfContentByte.SetColorStroke方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfContentByte.SetColorStroke方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfContentByte.SetColorStroke方法的具體用法?C# PdfContentByte.SetColorStroke怎麽用?C# PdfContentByte.SetColorStroke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.PdfContentByte的用法示例。


在下文中一共展示了PdfContentByte.SetColorStroke方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Render

        /// <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();
            }
        }
開發者ID:deaddog,項目名稱:DeadDog.PDF,代碼行數:44,代碼來源:LeafObject.cs

示例2: CreateSquares

// ---------------------------------------------------------------------------    
    /**
     * Draws a row of squares.
     * @param canvas the canvas to which the squares have to be drawn
     * @param x      X coordinate to position the row
     * @param y      Y coordinate to position the row
     * @param side   the side of the square
     * @param gutter the space between the squares
     */
    public void CreateSquares(PdfContentByte canvas,
      float x, float y, float side, float gutter) {
      canvas.SaveState();
      canvas.SetColorStroke(new GrayColor(0.2f));
      canvas.SetColorFill(new GrayColor(0.9f));
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.Stroke();
      x = x + side + gutter;
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.ClosePathStroke();
      x = x + side + gutter;
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.Fill();
      x = x + side + gutter;
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.FillStroke();
      x = x + side + gutter;
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.ClosePathFillStroke();
      canvas.RestoreState();
    }
開發者ID:,項目名稱:,代碼行數:45,代碼來源:

示例3: WriteLineToContent


//.........這裏部分代碼省略.........
                                subtract += hangingCorrection;
                            Object[] bgr = (Object[])chunk.GetAttribute(Chunk.BACKGROUND);
                            graphics.SetColorFill((BaseColor)bgr[0]);
                            float[] extra = (float[])bgr[1];
                            graphics.Rectangle(xMarker - extra[0],
                                yMarker + descender - extra[1] + chunk.TextRise,
                                width - subtract + extra[0] + extra[2],
                                ascender - descender + extra[1] + extra[3]);
                            graphics.Fill();
                            graphics.SetGrayFill(0);
                            if (inText && IsTagged(writer)) {
                                graphics.BeginText(true);
                            }
                        }
                        if (chunk.IsAttribute(Chunk.UNDERLINE) && !chunk.IsNewlineSplit()) {
                            bool inText = graphics.InText;
                            if (inText && IsTagged(writer)) {
                                graphics.EndText();
                            }
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.UNDERLINE))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            Object[][] unders = (Object[][])chunk.GetAttribute(Chunk.UNDERLINE);
                            BaseColor scolor = null;
                            for (int k = 0; k < unders.Length; ++k) {
                                Object[] obj = unders[k];
                                scolor = (BaseColor)obj[0];
                                float[] ps = (float[])obj[1];
                                if (scolor == null)
                                    scolor = color;
                                if (scolor != null)
                                    graphics.SetColorStroke(scolor);
                                graphics.SetLineWidth(ps[0] + fontSize * ps[1]);
                                float shift = ps[2] + fontSize * ps[3];
                                int cap2 = (int)ps[4];
                                if (cap2 != 0)
                                    graphics.SetLineCap(cap2);
                                graphics.MoveTo(xMarker, yMarker + shift);
                                graphics.LineTo(xMarker + width - subtract, yMarker + shift);
                                graphics.Stroke();
                                if (scolor != null)
                                    graphics.ResetGrayStroke();
                                if (cap2 != 0)
                                    graphics.SetLineCap(0);
                            }
                            graphics.SetLineWidth(1);
                            if (inText && IsTagged(writer)) {
                                graphics.BeginText(true);
                            }
                        }
                        if (chunk.IsAttribute(Chunk.ACTION))
                        {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.ACTION))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            PdfAnnotation annot = null;
                            if (chunk.IsImage()) {
                                annot = new PdfAnnotation(writer, xMarker, yMarker + chunk.ImageOffsetY, xMarker + width - subtract, yMarker + chunk.ImageHeight + chunk.ImageOffsetY, (PdfAction)chunk.GetAttribute(Chunk.ACTION));
                            }
                            else {
                        	    annot = new PdfAnnotation(writer, xMarker, yMarker + descender + chunk.TextRise, xMarker + width - subtract, yMarker + ascender + chunk.TextRise, (PdfAction)chunk.GetAttribute(Chunk.ACTION));
                            }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:67,代碼來源:PdfDocument.cs

示例4: SetupShape

		protected static void SetupShape (PdfContentByte cb,IBaseStyleDecorator style)
		{
			cb.SetColorStroke(style.PdfFrameColor);
			cb.SetColorFill(style.PdfBackColor);
		}
開發者ID:Bombadil77,項目名稱:SharpDevelop,代碼行數:5,代碼來源:BaseShape.cs

示例5: PictureBackdrop

// ---------------------------------------------------------------------------
    /**
     * Prints a square and fills half of it with a gray rectangle.
     * 
     * @param x
     * @param y
     * @param cb
     * @throws Exception
     */
    public static void PictureBackdrop(float x, float y, PdfContentByte cb) {
      cb.SetColorStroke(GrayColor.GRAYBLACK);
      cb.SetColorFill(new GrayColor(0.8f));
      cb.Rectangle(x, y, 100, 200);
      cb.Fill();
      cb.SetLineWidth(2);
      cb.Rectangle(x, y, 200, 200);
      cb.Stroke();
    }
開發者ID:,項目名稱:,代碼行數:18,代碼來源:

示例6: PictureBackdrop

 /**
  * Prints a square and fills half of it with a gray rectangle.
  *
  * @param x
  * @param y
  * @param cb
  * @throws Exception
  */
 private void PictureBackdrop(float x, float y, PdfContentByte cb,
     PdfWriter writer) {
     PdfShading axial = PdfShading.SimpleAxial(writer, x, y, x + 200, y,
         BaseColor.YELLOW, BaseColor.RED);
     PdfShadingPattern axialPattern = new PdfShadingPattern(axial);
     cb.SetShadingFill(axialPattern);
     cb.SetColorStroke(BaseColor.BLACK);
     cb.SetLineWidth(2);
     cb.Rectangle(x, y, 200, 200);
     cb.FillStroke();
 }
開發者ID:smartleos,項目名稱:itextsharp,代碼行數:19,代碼來源:PdfA2CheckerTest.cs

示例7: DrawLine

 /**
 * Draws a horizontal line.
 * @param canvas the canvas to draw on
 * @param leftX      the left x coordinate
 * @param rightX the right x coordindate
 * @param y          the y coordinate
 */
 public void DrawLine(PdfContentByte canvas, float leftX, float rightX, float y)
 {
     float w;
     if (Percentage < 0)
         w = -Percentage;
     else
         w = (rightX - leftX) * Percentage / 100.0f;
     float s;
     switch (Alignment) {
         case Element.ALIGN_LEFT:
             s = 0;
             break;
         case Element.ALIGN_RIGHT:
             s = rightX - leftX - w;
             break;
         default:
             s = (rightX - leftX - w) / 2;
             break;
     }
     canvas.SetLineWidth(LineWidth);
     if (LineColor != null)
         canvas.SetColorStroke(LineColor);
     canvas.MoveTo(s + leftX, y + offset);
     canvas.LineTo(s + w + leftX, y + offset);
     canvas.Stroke();
 }
開發者ID:jomamorales,項目名稱:createPDF,代碼行數:33,代碼來源:LineSeparator.cs

示例8: DrawBoxForCover

        /// <summary>
        /// Draws the box on the cover page that contains the date
        /// </summary>
        /// <param name="cb"></param>
        /// <param name="doc"></param>
        /// <param name="project"></param>
        private void DrawBoxForCover(PdfContentByte cb, Document doc)
        {
            // set the colors
            cb.SetColorStroke(_baseColor);
            cb.SetColorFill(_baseColor);

            // calculate the top left corner of the box
            var x = doc.LeftMargin;
            var y = doc.BottomMargin + 678;

            var height = 60;

            // move the cursor to starting position
            cb.MoveTo(x, y);

            // draw the top line
            cb.LineTo(x + _pageWidth, y);

            // draw the right line
            cb.LineTo(x + _pageWidth, y - height);

            // draw the bottom line
            cb.LineTo(x, y - height);

            // draw the left line
            cb.LineTo(x, y);

            cb.ClosePathFillStroke();
            cb.Stroke();

            // add the text inside the box
            cb.BeginText();
            cb.SetFontAndSize(_dateBaseFont, 26f);
            cb.SetColorStroke(BaseColor.WHITE);
            cb.SetColorFill(BaseColor.WHITE);
            cb.SetTextMatrix(x + 10, y - 40);
            cb.ShowText(string.Format("{0:MMMM dd, yyyy}", DateTime.Now));
            cb.EndText();
        }
開發者ID:ucdavis,項目名稱:Dogbert,代碼行數:45,代碼來源:PdfService.cs

示例9: WriteLine

        internal void WriteLine(PdfLine line, PdfContentByte text, PdfContentByte graphics)
        {
            PdfFont currentFont = null;
            foreach(PdfChunk chunk in line) {
                if (chunk.Font.CompareTo(currentFont) != 0) {
                    currentFont = chunk.Font;
                    text.SetFontAndSize(currentFont.Font, currentFont.Size);
                }
                Object[] textRender = (Object[])chunk.GetAttribute(Chunk.TEXTRENDERMODE);
                int tr = 0;
                float strokeWidth = 1;
                BaseColor color = chunk.Color;
                BaseColor strokeColor = null;
                if (textRender != null) {
                    tr = (int)textRender[0] & 3;
                    if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL)
                        text.SetTextRenderingMode(tr);
                    if (tr == PdfContentByte.TEXT_RENDER_MODE_STROKE || tr == PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE) {
                        strokeWidth = (float)textRender[1];
                        if (strokeWidth != 1)
                            text.SetLineWidth(strokeWidth);
                        strokeColor = (BaseColor)textRender[2];
                        if (strokeColor == null)
                            strokeColor = color;
                        if (strokeColor != null)
                            text.SetColorStroke(strokeColor);
                    }
                }

                object charSpace = chunk.GetAttribute(Chunk.CHAR_SPACING);
                // no char space setting means "leave it as is".
                if (charSpace != null && !curCharSpace.Equals(charSpace)) {
                    curCharSpace = (float)charSpace;
                    text.SetCharacterSpacing(curCharSpace);
                }
                if (color != null)
                    text.SetColorFill(color);
                text.ShowText(chunk.ToString());
                if (color != null)
                    text.ResetRGBColorFill();
                if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL)
                    text.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
                if (strokeColor != null)
                    text.ResetRGBColorStroke();
                if (strokeWidth != 1)
                    text.SetLineWidth(1);
            }
        }
開發者ID:mapo80,項目名稱:iTextSharp-Monotouch,代碼行數:48,代碼來源:VerticalText.cs

示例10: DrawTimeSlots

// ---------------------------------------------------------------------------    
    /**
     * Draws the time slots for a day at the film festival.
     * @param directcontent the canvas to which the time table has to be drawn.
     */
    protected void DrawTimeSlots(PdfContentByte directcontent) {
      directcontent.SaveState();
      float x;
      for (int i = 1; i < TIMESLOTS; i++) {
        x = OFFSET_LEFT + (i * WIDTH_TIMESLOT);
        directcontent.MoveTo(x, OFFSET_BOTTOM);
        directcontent.LineTo(x, OFFSET_BOTTOM + HEIGHT);
      }
      directcontent.SetLineWidth(0.3f);
      directcontent.SetColorStroke(BaseColor.GRAY);
      directcontent.SetLineDash(3, 1);
      directcontent.Stroke();
      directcontent.RestoreState();
    }    
開發者ID:,項目名稱:,代碼行數:19,代碼來源:

示例11: CreateStarsAndCircles

// ---------------------------------------------------------------------------    
    /**
     * Draws a row of stars and circles.
     * @param canvas the canvas to which the shapes have to be drawn
     * @param x      X coordinate to position the row
     * @param y      Y coordinate to position the row
     * @param radius the radius of the circles
     * @param gutter the space between the shapes
     */
    public static void CreateStarsAndCircles(PdfContentByte canvas,
        float x, float y, float radius, float gutter) 
    {
      canvas.SaveState();
      canvas.SetColorStroke(new GrayColor(0.2f));
      canvas.SetColorFill(new GrayColor(0.9f));
      CreateStar(canvas, x, y);
      CreateCircle(canvas, x + radius, y - 70, radius, true);
      CreateCircle(canvas, x + radius, y - 70, radius / 2, true);
      canvas.Fill();
      x += 2 * radius + gutter;
      CreateStar(canvas, x, y);
      CreateCircle(canvas, x + radius, y - 70, radius, true);
      CreateCircle(canvas, x + radius, y - 70, radius / 2, true);
      canvas.EoFill();
      x += 2 * radius + gutter;
      CreateStar(canvas, x, y);
      canvas.NewPath();
      CreateCircle(canvas, x + radius, y - 70, radius, true);
      CreateCircle(canvas, x + radius, y - 70, radius / 2, true);
      x += 2 * radius + gutter;
      CreateStar(canvas, x, y);
      CreateCircle(canvas, x + radius, y - 70, radius, true);
      CreateCircle(canvas, x + radius, y - 70, radius / 2, false);
      canvas.FillStroke();
      x += 2 * radius + gutter;
      CreateStar(canvas, x, y);
      CreateCircle(canvas, x + radius, y - 70, radius, true);
      CreateCircle(canvas, x + radius, y - 70, radius / 2, true);
      canvas.EoFillStroke();
      canvas.RestoreState();
    }
開發者ID:,項目名稱:,代碼行數:41,代碼來源:

示例12: SetStrokeAndFillColor

        void SetStrokeAndFillColor(PdfContentByte cb, IDictionary<String, String> css)
        {
            BaseColor fillColor = BaseColor.BLACK;
            String colorValue;
            if (css.TryGetValue(SVGAttributes.FILL, out colorValue)) {
                fillColor = GetColor(colorValue);
                if (fillColor == null) {
                    fillColor = BaseColor.BLACK;
                }
            }
            cb.SetColorFill(fillColor);

            BaseColor strokeColor = fillColor;
            if (css.TryGetValue(SVGAttributes.STROKE, out colorValue)) {
                strokeColor = GetColor(colorValue);
                if (strokeColor == null) {
                    strokeColor = fillColor;
                }
            }
            cb.SetColorStroke(strokeColor);
        }
開發者ID:,項目名稱:,代碼行數:21,代碼來源:

示例13: PlaceBarcode

        public override Rectangle PlaceBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
        {
            const float distanceBetweenBars = MmToPoints;
            const float wideBarPoints = MmToPoints;
            const float narrowBarPoints = HalfMmToPoints;
            const float barWidth = DefaultBarWidthInPoints;
            const float fullHeight = DefaultBarHeightInPoints;

            var barStartX = IsisPoint.X - _mmFromPageBorder;
            var barStartY = IsisPoint.Y - _mmFromDrawningBar;
            var bars = GetBarsCode39("123456789012345678901234567890123456789");
            var print = true;
            if (barColor != null)
            {
                cb.SetColorFill(barColor);
                cb.SetColorStroke(barColor);
            }

            const int elementBars = 20;
            var elemBarCount = 1;
            foreach (var vbarHeight in bars.Select(t => (t == 0 ? narrowBarPoints : wideBarPoints)))
            {
                if (print)
                {
                    cb.Rectangle(barStartX, barStartY, barWidth, vbarHeight);
                }
                print = !print;
                barStartY += vbarHeight;

                if (elemBarCount++ != elementBars) continue; // start a new element
                elemBarCount = 1;
                barStartY = IsisPoint.Y - _mmFromDrawningBar;
                barStartX += barWidth + distanceBetweenBars;
            }
            cb.Fill();
            var fullWidth = barStartX + barWidth;
            return new Rectangle(fullWidth, fullHeight);
        }
開發者ID:rodrigodealer,項目名稱:external_source,代碼行數:38,代碼來源:IsisBarcode.cs

示例14: WriteLineToContent


//.........這裏部分代碼省略.........
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.BACKGROUND))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            float fontSize = chunk.Font.Size;
                            float ascender = chunk.Font.Font.GetFontDescriptor(BaseFont.ASCENT, fontSize);
                            float descender = chunk.Font.Font.GetFontDescriptor(BaseFont.DESCENT, fontSize);
                            Object[] bgr = (Object[])chunk.GetAttribute(Chunk.BACKGROUND);
                            graphics.SetColorFill((Color)bgr[0]);
                            float[] extra = (float[])bgr[1];
                            graphics.Rectangle(xMarker - extra[0],
                                yMarker + descender - extra[1] + chunk.TextRise,
                                width - subtract + extra[0] + extra[2],
                                ascender - descender + extra[1] + extra[3]);
                            graphics.Fill();
                            graphics.SetGrayFill(0);
                        }
                        if (chunk.IsAttribute(Chunk.UNDERLINE)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.UNDERLINE))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            Object[][] unders = (Object[][])chunk.GetAttribute(Chunk.UNDERLINE);
                            Color scolor = null;
                            for (int k = 0; k < unders.Length; ++k) {
                                Object[] obj = unders[k];
                                scolor = (Color)obj[0];
                                float[] ps = (float[])obj[1];
                                if (scolor == null)
                                    scolor = color;
                                if (scolor != null)
                                    graphics.SetColorStroke(scolor);
                                float fsize = chunk.Font.Size;
                                graphics.SetLineWidth(ps[0] + fsize * ps[1]);
                                float shift = ps[2] + fsize * ps[3];
                                int cap2 = (int)ps[4];
                                if (cap2 != 0)
                                    graphics.SetLineCap(cap2);
                                graphics.MoveTo(xMarker, yMarker + shift);
                                graphics.LineTo(xMarker + width - subtract, yMarker + shift);
                                graphics.Stroke();
                                if (scolor != null)
                                    graphics.ResetGrayStroke();
                                if (cap2 != 0)
                                    graphics.SetLineCap(0);
                            }
                            graphics.SetLineWidth(1);
                        }
                        if (chunk.IsAttribute(Chunk.ACTION)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.ACTION))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            text.AddAnnotation(new PdfAnnotation(writer, xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.Font.Size, (PdfAction)chunk.GetAttribute(Chunk.ACTION)));
                        }
                        if (chunk.IsAttribute(Chunk.REMOTEGOTO)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.REMOTEGOTO))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            Object[] obj = (Object[])chunk.GetAttribute(Chunk.REMOTEGOTO);
                            String filename = (String)obj[0];
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:67,代碼來源:PdfDocument.cs


注:本文中的iTextSharp.text.pdf.PdfContentByte.SetColorStroke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。