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


C# PdfContentByte.RestoreState方法代碼示例

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


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

示例1: ShowTextAligned

 /** Shows a line of text. Only the first line is written.
  * @param canvas where the text is to be written to
  * @param alignment the alignment. It is not influenced by the run direction
  * @param phrase the <CODE>Phrase</CODE> with the text
  * @param x the x reference position
  * @param y the y reference position
  * @param rotation the rotation to be applied in degrees counterclockwise
  * @param runDirection the run direction
  * @param arabicOptions the options for the arabic shaping
  */    
 public static void ShowTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation, int runDirection, int arabicOptions) {
     if (alignment != Element.ALIGN_LEFT && alignment != Element.ALIGN_CENTER
         && alignment != Element.ALIGN_RIGHT)
         alignment = Element.ALIGN_LEFT;
     canvas.SaveState();
     ColumnText ct = new ColumnText(canvas);
     float lly = -1;
     float ury = 2;
     float llx;
     float urx;
     switch (alignment) {
         case Element.ALIGN_LEFT:
             llx = 0;
             urx = 20000;
             break;
         case Element.ALIGN_RIGHT:
             llx = -20000;
             urx = 0;
             break;
         default:
             llx = -20000;
             urx = 20000;
             break;
     }
     if (rotation == 0) {
         llx += x;
         lly += y;
         urx += x;
         ury += y;
     }
     else {
         double alpha = rotation * Math.PI / 180.0;
         float cos = (float)Math.Cos(alpha);
         float sin = (float)Math.Sin(alpha);
         canvas.ConcatCTM(cos, sin, -sin, cos, x, y);
     }
     ct.SetSimpleColumn(phrase, llx, lly, urx, ury, 2, alignment);
     if (runDirection == PdfWriter.RUN_DIRECTION_RTL) {
         if (alignment == Element.ALIGN_LEFT)
             alignment = Element.ALIGN_RIGHT;
         else if (alignment == Element.ALIGN_RIGHT)
             alignment = Element.ALIGN_LEFT;
     }
     ct.Alignment = alignment;
     ct.ArabicOptions = arabicOptions;
     ct.RunDirection = runDirection;
     ct.Go();
     canvas.RestoreState();
 }
開發者ID:medvedttn,項目名稱:itextsharp_mod-src,代碼行數:59,代碼來源:ColumnText.cs

示例2: Draw

 /**
 * @see com.lowagie.text.pdf.draw.DrawInterface#draw(com.lowagie.text.pdf.PdfContentByte, float, float, float, float, float)
 */
 public override void Draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) {
     canvas.SaveState();
     canvas.SetLineWidth(lineWidth);
     canvas.SetLineCap(PdfContentByte.LINE_CAP_ROUND);
     canvas.SetLineDash(0, gap, gap / 2);
     DrawLine(canvas, llx, urx, y);
     canvas.RestoreState();
 }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:11,代碼來源:DottedLineSeparator.cs

示例3: Ellipse

 public void Ellipse(PdfContentByte content, Rectangle rect) {
   content.SaveState();
   content.SetRGBColorFill(0x00, 0x00, 0xFF);
   content.Ellipse(
     rect.Left - 3f, rect.Bottom - 5f,
     rect.Right + 3f, rect.Top + 3f
   );
   content.Fill();
   content.RestoreState();
 }
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例4: AddWaterMarkText

        private static void AddWaterMarkText(PdfContentByte directContent, string textWatermark, BaseFont font, float fontSize, float angle, BaseColor color, Rectangle realPageSize)
        {
            var gstate = new PdfGState { FillOpacity = 0.2f, StrokeOpacity = 0.2f };

            directContent.SaveState();
            directContent.SetGState(gstate);
            directContent.SetColorFill(color);
            directContent.BeginText();
            directContent.SetFontAndSize(font, fontSize);

            var x = (realPageSize.Right + realPageSize.Left) / 2;
            var y = (realPageSize.Bottom + realPageSize.Top) / 2;

            directContent.ShowTextAligned(Element.ALIGN_CENTER, textWatermark, x, y, angle);
            directContent.EndText();
            directContent.RestoreState();
        }
開發者ID:fabiohvp,項目名稱:DocumentSigner,代碼行數:17,代碼來源:PdfHelper.cs

示例5: Render_FrontBase

        private static void Render_FrontBase(PdfContentByte under, DateTime expiration)
        {
            float BORDER_WIDTH = 1.5f;

            // Draw background stripes and bars
            under.SaveState();
            under.SetRGBColorFill(0xff, 0x45, 0x00);
            under.Rectangle(0, CARD_HEIGHT - (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT + LOWER_BAR_HEIGHT), CARD_WIDTH, (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT + LOWER_BAR_HEIGHT));
            under.Fill();
            under.SetRGBColorFill(0x0, 0x0, 0x0);
            under.Rectangle(0, CARD_HEIGHT - (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT) - BORDER_WIDTH, CARD_WIDTH, PHOTO_BAR_HEIGHT + 2 * BORDER_WIDTH);
            under.Fill();
            under.SetRGBColorFill(0xff, 0xff, 0xff);
            under.Rectangle(0, CARD_HEIGHT - (UPPER_BAR_HEIGHT + PHOTO_BAR_HEIGHT), CARD_WIDTH, PHOTO_BAR_HEIGHT);
            under.Fill();
            under.RestoreState();

            var img = Image.GetInstance(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content", "images", "sheriff.png"));
            img.ScaleToFit(CARD_WIDTH - PHOTO_WIDTH - 8, PHOTO_BAR_HEIGHT);
            img.SetAbsolutePosition(
                ((CARD_WIDTH - PHOTO_WIDTH) - img.ScaledWidth) / 2,
                CARD_HEIGHT - (UPPER_BAR_HEIGHT + img.ScaledHeight) - 4);

            under.AddImage(img);

            Font f = new Font(baseFont, 8) { Color = BaseColor.WHITE };

            Phrase p = new Phrase("Expiration:", f);
            ColumnText.ShowTextAligned(under, Element.ALIGN_LEFT, p, 4, CARD_HEIGHT - 10, 0);
            p = new Phrase(expiration.ToString("MM/dd/yyyy"), f);
            ColumnText.ShowTextAligned(under, Element.ALIGN_RIGHT, p, CARD_WIDTH - 4, CARD_HEIGHT - 10, 0);

            f = new Font(baseFont, 11) { Color = BaseColor.WHITE };
            p = new Phrase("King County", f);
            ColumnText.ShowTextAligned(under, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, CARD_HEIGHT - 34, 0);

            f = new Font(baseFont, 14, Font.BOLD) { Color = BaseColor.WHITE };

            p = new Phrase("Search & Rescue", f);
            ColumnText.ShowTextAligned(under, Element.ALIGN_CENTER, p, CARD_WIDTH / 2, CARD_HEIGHT - 49, 0);
        }
開發者ID:mattkur,項目名稱:KCSARA-Database,代碼行數:41,代碼來源:BadgeService.cs

示例6: DirectDrawReport

        private void DirectDrawReport(PdfContentByte canvas)
        {
            //畫線
            canvas.SaveState();
            canvas.SetLineWidth(2f);
            canvas.MoveTo(100, 100);
            canvas.LineTo(200, 200);
            canvas.Stroke();
            canvas.RestoreState();

            //文本
            ColumnText.ShowTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("JulyLuo測試", new Font(BF_Light, 10)), 100, 20, 0);
        }
開發者ID:GitForShadow,項目名稱:PersonalProfile,代碼行數:13,代碼來源:ReportDemo.cs

示例7: DrawBlock

// ---------------------------------------------------------------------------        
    /**
     * Draws a colored block on the time table, corresponding with
     * the screening of a specific movie.
     * @param    screening    a screening POJO, contains a movie and a category
     * @param    under    the canvas to which the block is drawn
     */
    protected void DrawBlock(
      Screening screening, PdfContentByte under, PdfContentByte over
    ) {
      under.SaveState();
      BaseColor color = WebColors.GetRGBColor(
        "#" + screening.movie.entry.category.color
      );
      under.SetColorFill(color);
      Rectangle rect = GetPosition(screening);
      under.Rectangle(
        rect.Left, rect.Bottom, rect.Width, rect.Height
      );
      under.Fill();
      over.Rectangle(
        rect.Left, rect.Bottom, rect.Width, rect.Height
      );
      over.Stroke();
      under.RestoreState();
    }
開發者ID:,項目名稱:,代碼行數:26,代碼來源:

示例8: DrawDiamont

        /// <summary>
        /// Draws the diamont.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        public static void DrawDiamont(PdfContentByte content, float x, float y)
        {
            content.SaveState();
            var state = new PdfGState();
            content.SetGState(state);
            content.SetColorFill(BaseColor.BLACK);
            content.MoveTo(x, y);
            var sPoint = new Point(x, y);
            var uMPoint = new Point(x + WPosMarkerMid, y + HPosMarkerMid);
            var rPoint = new Point(uMPoint.X + WPosMarkerMid, uMPoint.Y - HPosMarkerMid);
            var mPoint = new Point(rPoint.X - WPosMarkerMid, rPoint.Y - HPosMarkerMid);

            DrawLines(content, uMPoint, rPoint, mPoint, sPoint);

            content.ClosePathFillStroke();
            content.RestoreState();
        }
開發者ID:rodrigodealer,項目名稱:external_source,代碼行數:23,代碼來源:Program.cs

示例9: DrawSquare

        public static void DrawSquare(PdfContentByte content, Point point, System.Data.IDataReader reader)
        {
            content.SaveState();
            var state = new PdfGState {FillOpacity = FillOpacity};
            content.SetGState(state);
            var color = new CMYKColor(reader.GetFloat(1), reader.GetFloat(2), reader.GetFloat(3), reader.GetFloat(4));
            content.SetColorFill(color);

            content.SetLineWidth(0);
            content.Rectangle(point.X, point.Y, PatchSize, PatchSize);
            content.Fill();
            content.RestoreState();
        }
開發者ID:rodrigodealer,項目名稱:external_source,代碼行數:13,代碼來源:Program.cs

示例10: ShowText

        private void ShowText(PdfContentByte cb, float x, float y, float xPrevious, float yPrevious, double xmidden, double ymidden, String character)
        {
            double corner = CalculateCorner(x, y, xPrevious, yPrevious);
            cb.SaveState();
            PdfTemplate template2 = cb.CreateTemplate(1000, 1000);

            template2.BeginText();
            template2.SetColorFill(BaseColor.BLACK);
            BaseFont bf = BaseFont.CreateFont();
            template2.SetFontAndSize(bf, fontsize);
            //template2.SetTextRise(10);
            //double halfWidthOfCharacter = cb.GetEffectiveStringWidth(character+"", true) / 2.0;  
            template2.SetTextMatrix(0, 0);
            template2.ShowText(character + "");
            template2.EndText();
            Matrix translation = new Matrix();
            translation.Translate((float)xmidden, (float)ymidden);
            cb.ConcatCTM(translation);
            Matrix rotation = new Matrix();
            rotation.Rotate((float)corner);
            cb.ConcatCTM(rotation);
            cb.ConcatCTM(1, 0, 0, -1, 0, 0);
            cb.AddTemplate(template2, 0, 0);
            cb.RestoreState();
        }
開發者ID:,項目名稱:,代碼行數:25,代碼來源:

示例11: Render_BackBase

        private static void Render_BackBase(PdfContentByte under)
        {
            // Y relative to card top, line width, <repeat>
            float[] measures = new[] { 37, 3f, 144, 1.5f };

            under.SaveState();
            for (int i = 0; i < measures.Length / 2; i++)
            {
                under.SetLineWidth(measures[i * 2 + 1]);
                under.MoveTo(0, CARD_HEIGHT - measures[i * 2]);
                under.LineTo(CARD_WIDTH, CARD_HEIGHT - measures[i * 2]);
                under.Stroke();
            }

            under.SetFontAndSize(baseFont, 7);
            under.ShowTextAlignedKerned(Element.ALIGN_CENTER, "If found, please call KCSAR at (206) 205-8226", CARD_WIDTH / 2, 7, 0);

            under.RestoreState();
        }
開發者ID:mattkur,項目名稱:KCSARA-Database,代碼行數:19,代碼來源:BadgeService.cs

示例12: Layout


//.........這裏部分代碼省略.........
                if (height < maxY - minY)
                {
                    contentCutByFixedHeight = true;
                    minY = maxY - (float) height;
                }
                else if (height > maxY - minY)
                {
                    return ColumnText.NO_MORE_COLUMN;
                }
            }
            else if (percentageHeight != null)
            {
                if (percentageHeight < 1.0)
                    contentCutByFixedHeight = true;
                contentHeight = (maxY - minY)*(float) percentageHeight;
                minY = maxY - contentHeight;
            }

            if (!simulate && position == PdfDiv.PositionType.RELATIVE)
            {
                float? translationX = null;
                if (left != null)
                    translationX = left;
                else if (right != null)
                    translationX = -right;
                else
                    translationX = 0f;

                float? translationY = null;
                if (top != null)
                    translationY = -top;
                else if (bottom != null)
                    translationY = bottom;
                else
                    translationY = 0f;
                canvas.SaveState();
                canvas.Transform(new AffineTransform(1f, 0, 0, 1f, translationX.Value, translationY.Value));
            }

            if (!simulate)
            {
                if (backgroundColor != null && getActualWidth() > 0 && getActualHeight() > 0)
                {
                    float backgroundWidth = getActualWidth();
                    float backgroundHeight = getActualHeight();
                    if (width != null)
                        backgroundWidth = width > 0 ? (float) width : 0;
                    if (height != null)
                        backgroundHeight = height > 0 ? (float) height : 0;
                    if (backgroundWidth > 0 && backgroundHeight > 0)
                    {
                        Rectangle background = new Rectangle(leftX, maxY - backgroundHeight, leftX + backgroundWidth, maxY);
                        background.BackgroundColor = backgroundColor;
                        PdfArtifact artifact = new PdfArtifact();
                        canvas.OpenMCBlock(artifact);
                        canvas.Rectangle(background);
                        canvas.CloseMCBlock(artifact);
                    }
                }
            }

            if (percentageWidth == null)
                contentWidth = 0;
            if (percentageHeight == null)
                contentHeight = 0;

            minY += paddingBottom;
            leftX += paddingLeft;
            rightX -= paddingRight;

            yLine -= paddingTop;

            int status = ColumnText.NO_MORE_TEXT;

            if (content.Count > 0) {
                if (floatLayout == null) {
                    List<IElement> floatingElements = new List<IElement>(content);
                    floatLayout = new FloatLayout(floatingElements, useAscender);
                }

                floatLayout.SetSimpleColumn(leftX, minY, rightX, yLine);
                status = floatLayout.Layout(canvas, simulate);
                yLine = floatLayout.YLine;
                if (percentageWidth == null && contentWidth < floatLayout.FilledWidth)
                    contentWidth = floatLayout.FilledWidth;
            }


            if (!simulate && position == PdfDiv.PositionType.RELATIVE)
                canvas.RestoreState();

            yLine -= paddingBottom;
            if (percentageHeight == null)
                contentHeight = maxY - yLine;

            if (percentageWidth == null)
                contentWidth += paddingLeft + paddingRight;

            return contentCutByFixedHeight ? ColumnText.NO_MORE_TEXT : status;
        }
開發者ID:,項目名稱:,代碼行數:101,代碼來源:

示例13: 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,代碼來源:

示例14: PlaceBarcode

 /** Places the barcode in a <CODE>PdfContentByte</CODE>. The
  * barcode is always placed at coodinates (0, 0). Use the
  * translation matrix to move it elsewhere.<p>
  * The bars and text are written in the following colors:<p>
  * <P><TABLE BORDER=1>
  * <TR>
  *   <TH><P><CODE>barColor</CODE></TH>
  *   <TH><P><CODE>textColor</CODE></TH>
  *   <TH><P>Result</TH>
  *   </TR>
  * <TR>
  *   <TD><P><CODE>null</CODE></TD>
  *   <TD><P><CODE>null</CODE></TD>
  *   <TD><P>bars and text painted with current fill color</TD>
  *   </TR>
  * <TR>
  *   <TD><P><CODE>barColor</CODE></TD>
  *   <TD><P><CODE>null</CODE></TD>
  *   <TD><P>bars and text painted with <CODE>barColor</CODE></TD>
  *   </TR>
  * <TR>
  *   <TD><P><CODE>null</CODE></TD>
  *   <TD><P><CODE>textColor</CODE></TD>
  *   <TD><P>bars painted with current color<br>text painted with <CODE>textColor</CODE></TD>
  *   </TR>
  * <TR>
  *   <TD><P><CODE>barColor</CODE></TD>
  *   <TD><P><CODE>textColor</CODE></TD>
  *   <TD><P>bars painted with <CODE>barColor</CODE><br>text painted with <CODE>textColor</CODE></TD>
  *   </TR>
  * </TABLE>
  * @param cb the <CODE>PdfContentByte</CODE> where the barcode will be placed
  * @param barColor the color of the bars. It can be <CODE>null</CODE>
  * @param textColor the color of the text. It can be <CODE>null</CODE>
  * @return the dimensions the barcode occupies
  */
 public override Rectangle PlaceBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) {
     if (supp.Font != null)
         supp.BarHeight = ean.BarHeight + supp.Baseline - supp.Font.GetFontDescriptor(BaseFont.CAPHEIGHT, supp.Size);
     else
         supp.BarHeight = ean.BarHeight;
     Rectangle eanR = ean.BarcodeSize;
     cb.SaveState();
     ean.PlaceBarcode(cb, barColor, textColor);
     cb.RestoreState();
     cb.SaveState();
     cb.ConcatCTM(1, 0, 0, 1, eanR.Width + n, eanR.Height - ean.BarHeight);
     supp.PlaceBarcode(cb, barColor, textColor);
     cb.RestoreState();
     return this.BarcodeSize;
 }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:51,代碼來源:BarcodeEANSUPP.cs

示例15: ColorRectangle

 public virtual void ColorRectangle(PdfContentByte canvas,
     BaseColor color, float x, float y, float width, float height) {
     canvas.SaveState();
     canvas.SetColorFill(color);
     canvas.Rectangle(x, y, width, height);
     canvas.FillStroke();
     canvas.RestoreState();
 }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:8,代碼來源:LabColorSpaceTest.cs


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