SetLineWidth() public method

public SetLineWidth ( float value ) : void
value float
return void
        // ---------------------------------------------------------------------------    
        /**
         * Draws the time table for a day at the film festival.
         * @param directcontent a canvas to which the time table has to be drawn.
         */
        protected void DrawTimeTable(PdfContentByte directcontent)
        {
            directcontent.SaveState();
            directcontent.SetLineWidth(1.2f);
            float llx, lly, urx, ury;

            llx = OFFSET_LEFT;
            lly = OFFSET_BOTTOM;
            urx = OFFSET_LEFT + WIDTH;
            ury = OFFSET_BOTTOM + HEIGHT;
            directcontent.MoveTo(llx, lly);
            directcontent.LineTo(urx, lly);
            directcontent.LineTo(urx, ury);
            directcontent.LineTo(llx, ury);
            directcontent.ClosePath();
            directcontent.Stroke();

            llx = OFFSET_LOCATION;
            lly = OFFSET_BOTTOM;
            urx = OFFSET_LOCATION + WIDTH_LOCATION;
            ury = OFFSET_BOTTOM + HEIGHT;
            directcontent.MoveTo(llx, lly);
            directcontent.LineTo(urx, lly);
            directcontent.LineTo(urx, ury);
            directcontent.LineTo(llx, ury);
            directcontent.ClosePathStroke();

            directcontent.SetLineWidth(1);
            directcontent.MoveTo(
              OFFSET_LOCATION + WIDTH_LOCATION / 2, OFFSET_BOTTOM
            );
            directcontent.LineTo(
              OFFSET_LOCATION + WIDTH_LOCATION / 2, OFFSET_BOTTOM + HEIGHT
            );
            float y;
            for (int i = 1; i < LOCATIONS; i++)
            {
                y = OFFSET_BOTTOM + (i * HEIGHT_LOCATION);
                if (i == 2 || i == 6)
                {
                    directcontent.MoveTo(OFFSET_LOCATION, y);
                    directcontent.LineTo(OFFSET_LOCATION + WIDTH_LOCATION, y);
                }
                else
                {
                    directcontent.MoveTo(OFFSET_LOCATION + WIDTH_LOCATION / 2, y);
                    directcontent.LineTo(OFFSET_LOCATION + WIDTH_LOCATION, y);
                }
                directcontent.MoveTo(OFFSET_LEFT, y);
                directcontent.LineTo(OFFSET_LEFT + WIDTH, y);
            }
            directcontent.Stroke();
            directcontent.RestoreState();
        }
 /**
 * @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();
 }
Beispiel #3
0
	private void CreatePdfBox(PdfContentByte content, Configuration.PrintTemplateContentRow row, bool allowFill)
	{
		if (row.IsFillColorNull() && row.IsOutlineWidthNull() && row.IsOutlineColorNull())
		{
			return;
		}

		bool hasFill = false;
		bool hasStroke = false;

		content.SetLineWidth((1 / PixelsPerInch) * PointsPerInch);

		if (!row.IsFillColorNull() && allowFill)
		{
			System.Drawing.Color c = System.Drawing.ColorTranslator.FromHtml(row.FillColor);
			content.SetRGBColorFill(c.R, c.G, c.B);
			hasFill = true;
		}

		if (!row.IsOutlineWidthNull())
		{
			content.SetLineWidth((Convert.ToSingle(row.OutlineWidth) / PixelsPerInch) * PointsPerInch);
			hasStroke = true;
		}

		if (!row.IsOutlineColorNull())
		{
			System.Drawing.Color c = System.Drawing.ColorTranslator.FromHtml(row.OutlineColor);
			content.SetRGBColorStroke(c.R, c.G, c.B);
			hasStroke = true;
		}

		float originX = Convert.ToSingle(row.OriginX) * PointsPerInch;
		float originY = Convert.ToSingle(row.OriginY) * PointsPerInch;
		float width = Convert.ToSingle(row.Width) * PointsPerInch;
		float height = Convert.ToSingle(row.Height) * PointsPerInch;

		if (hasFill)
		{
			content.Rectangle(originX, originY, width, height);
			content.Fill();
		}

		if (hasStroke)
		{
			content.Rectangle(originX, originY, width, height);
			content.Stroke();
		}
	}
Beispiel #4
0
 private static PdfTemplate PdfFooter(PdfContentByte cb)
 {
     // Create the template and assign height
     PdfTemplate tmpFooter = cb.CreateTemplate(580, 70);
     // Move to the bottom left corner of the template
     tmpFooter.MoveTo(1, 1);
     // Place the footer content
     tmpFooter.Stroke();
     // Begin writing the footer
     tmpFooter.BeginText();
     // Set the font and size
     tmpFooter.SetFontAndSize(_baseFont, 8);
     // Write out details from the payee table
     tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "De facturen zijn contant betaalbaar te Tielt of op rekeningnummer", cb.PdfWriter.PageSize.Width / 2, 45, 0);
     tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "733-0318587-69 bij KBC of 001-6090654-03 bij BNP Paribas Fortis", cb.PdfWriter.PageSize.Width / 2, 35, 0);
     tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Alle klachten dienen binnen de 24 uren, na de uitgevoerde werken schriftelijk medegedeeld te worden.", cb.PdfWriter.PageSize.Width / 2, 25, 0);
     tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Bij geschillen is enkel de rechtbank van Brugge bevoegd.", cb.PdfWriter.PageSize.Width / 2, 15, 0);
     // End text
     tmpFooter.EndText();
     // Stamp a line above the page footer
     cb.SetLineWidth(0f);
     cb.MoveTo(30, 60);
     cb.LineTo(570, 60);
     cb.Stroke();
     // Return the footer template
     return tmpFooter;
 }
        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);
        }
        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();
        }
Beispiel #7
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();
            }
        }
        /// <summary>
        /// Draws the page border.
        /// </summary>
        /// <param name="writer"> </param>
        /// <param name="document"> </param>
        /// <param name="canvas"> </param>
        /// <returns></returns>
        protected void DrawPageBorder(PdfWriter writer, Document document, PdfContentByte canvas)
        {
            var pageBorderRect = new Rectangle(document.PageSize);
            var content = writer.DirectContent;

            pageBorderRect.Left += document.LeftMargin - BorderDifference;
            pageBorderRect.Right -= document.RightMargin - BorderDifference;
            pageBorderRect.Top -= document.TopMargin - BorderDifference;
            pageBorderRect.Bottom += document.BottomMargin - BorderDifference;
            content.SetColorStroke(BaseColor.BLACK);
            canvas.SetLineWidth(FillOpacity);
            canvas.SetRGBColorStroke(0, 0, 0);
            canvas.SetLineDash(6f, 6f, 0f);
            content.Rectangle(pageBorderRect.Left, pageBorderRect.Bottom, pageBorderRect.Width, pageBorderRect.Height);
            content.Stroke();
        }
        public static Point DrawUpperRectangle(PdfContentByte content, Rectangle pageRect, float barSize)
        {
            content.SaveState();
            var state = new PdfGState {FillOpacity = FillOpacity};
            content.SetGState(state);
            content.SetColorFill(BaseColor.BLACK);

            content.SetLineWidth(0);
            var result = new Point(SideBorder + BorderPage,
                                   pageRect.Height - (BorderPage + LeaderEdge + BarHeight + 1));
            content.Rectangle(result.X, result.Y, barSize, BarHeight);
            content.ClosePathFillStroke();
            content.RestoreState();
            return result;
        }
        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();
        }
Beispiel #11
0
// ---------------------------------------------------------------------------
    /**
     * 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();
    }
Beispiel #12
0
        /// <summary>
        /// 处理单个页面。
        /// </summary>
        /// <param name="pgs"></param>
        /// <param name="items"></param>
        private void ProcessPage(Pages pgs, IEnumerable items)
        {
            foreach (PageItem pi in items)
            {
                //if (pi.SI.BackgroundImage != null)
                //{
                //    PageImage bgImg = pi.SI.BackgroundImage;
                //    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(bgImg.ImageData);
                //    document.Add(image);
                //}

                if (pi is PageTextHtml)
                {
                    PageTextHtml pth = pi as PageTextHtml;
                    pth.Build(pgs.G);
                    ProcessPage(pgs, pth);
                    continue;
                }

                if (pi is PageText)
                {
                    PageText pt = pi as PageText;

                    iTextSharp.text.pdf.PdfContentByte cb = this.pdfWriter.DirectContent;

                    float y = getYvalue(pi.Y, pt.H);

                    //边线

                    if (pi.SI.BStyleLeft != BorderStyleEnum.None)
                    {
                        cb.MoveTo(pt.X, y);
                        cb.SetLineWidth(pi.SI.BWidthLeft);
                        cb.SetRGBColorStrokeF(pi.SI.BColorLeft.R, pi.SI.BColorLeft.G, pi.SI.BColorLeft.B);

                        cb.LineTo(pt.X, y + pt.H);

                        cb.Stroke();
                    }

                    if (pi.SI.BStyleRight != BorderStyleEnum.None)
                    {
                        cb.MoveTo(pt.X + pt.W, y);
                        cb.SetLineWidth(pi.SI.BWidthRight);
                        cb.SetRGBColorStrokeF(pi.SI.BColorRight.R, pi.SI.BColorRight.G, pi.SI.BColorRight.B);

                        cb.LineTo(pt.X + pt.W, y + pt.H);

                        cb.Stroke();
                    }

                    if (pi.SI.BStyleTop != BorderStyleEnum.None)
                    {
                        cb.MoveTo(pt.X, y + pt.H);
                        cb.SetLineWidth(pi.SI.BWidthTop);
                        cb.SetRGBColorStrokeF(pi.SI.BColorTop.R, pi.SI.BColorTop.G, pi.SI.BColorTop.B);

                        cb.LineTo(pt.X + pt.W, y + pt.H);

                        cb.Stroke();
                    }

                    if (pi.SI.BStyleBottom != BorderStyleEnum.None)
                    {
                        cb.MoveTo(pt.X, y);
                        cb.SetLineWidth(pi.SI.BWidthTop);
                        cb.SetRGBColorStrokeF(pi.SI.BColorTop.R, pi.SI.BColorTop.G, pi.SI.BColorTop.B);

                        cb.LineTo(pt.X + pt.W, y);

                        cb.Stroke();
                    }

                    //绝对定义文字

                    iTextSharp.text.Font font = TextUtility.GetFont(pi.SI, pt.Text);

                    float[]  widih;
                    string[] sa = MeasureString(pt, pgs.G, out widih);

                    int rows = sa.Length;

                    //x标准固定

                    float x     = pt.X + pi.SI.PaddingLeft;
                    int   align = iTextSharp.text.pdf.PdfContentByte.ALIGN_LEFT;

                    if (pi.SI.TextAlign == TextAlignEnum.Right)
                    {
                        align = iTextSharp.text.pdf.PdfContentByte.ALIGN_RIGHT;
                        x     = pt.X + pt.W - pi.SI.PaddingRight - 1;
                    }
                    else if (pi.SI.TextAlign == TextAlignEnum.Center)
                    {
                        align = iTextSharp.text.pdf.PdfContentByte.ALIGN_CENTER;
                        x     = pt.X + pt.W / 2;
                    }

                    cb.BeginText();
                    cb.SetFontAndSize(font.BaseFont, font.Size);

                    for (int i = 0; i < rows; i++)
                    {
                        float Yt = y + i * font.Size + 1;

                        if (pi.SI.VerticalAlign == VerticalAlignEnum.Top)
                        {
                            Yt = y + pt.H - font.Size * (rows - (i + 1)) - 1;
                        }
                        else if (pi.SI.VerticalAlign == VerticalAlignEnum.Middle)
                        {
                            Yt = y + (pt.H - font.Size * rows) / 2 + i * font.Size + 1;
                        }

                        cb.ShowTextAligned(align, sa[rows - i - 1], x, Yt, 0);
                        cb.EndText();
                    }

                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;

                    iTextSharp.text.pdf.PdfContentByte cb = this.pdfWriter.DirectContent;

                    float y1 = getYvalue(pl.Y, 0);
                    float y2 = getYvalue(pl.Y2, 0);

                    cb.MoveTo(pl.X, y1);
                    cb.LineTo(pl.X2, y2);

                    cb.Stroke();

                    continue;
                }

                if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;

                    iTextSharp.text.pdf.PdfContentByte cb = this.pdfWriter.DirectContent;

                    float y = this.getYvalue(i.Y, i.H);

                    System.Drawing.RectangleF r2 = new System.Drawing.RectangleF(i.X + i.SI.PaddingLeft, y - i.SI.PaddingTop, i.W - i.SI.PaddingLeft - i.SI.PaddingRight, i.H - i.SI.PaddingTop - i.SI.PaddingBottom);

                    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(i.ImageData);

                    image.SetAbsolutePosition(i.X, y);
                    image.ScaleAbsoluteHeight(i.H);
                    image.ScaleAbsoluteWidth(i.W);

                    cb.AddImage(image);

                    cb.Stroke();

                    continue;
                }

                if (pi is PageRectangle)
                {
                    PageRectangle pr = pi as PageRectangle;

                    iTextSharp.text.Rectangle r2 = new iTextSharp.text.Rectangle(pr.X, pr.Y, pr.W, pr.H);
                    r2.Border = 1;
                    document.Add(r2);
                    continue;
                }
            }
        }
        private MemoryStream PrintTerms(IEnumerable<GlossaryItem> terms)
        {
            float ppi = 72.0F;
            float PageWidth = 8.5F;
            float PageHeight = 11.0F;
            float TopBottomMargin = 0.625F;
            float LeftRightMargin = 0.75F;
            float GutterWidth = 0.25F;
            float HeaderFooterHeight = 0.125F;
            float Column1Left = LeftRightMargin;
            float Column1Right = ((PageWidth - (LeftRightMargin * 2) - GutterWidth) / 2) + LeftRightMargin;
            float Column2Left = Column1Right + GutterWidth;
            float Column2Right = PageWidth - LeftRightMargin;

            bool HasMultipleDefinitions = (terms.Count() > 1);

            string version = DataAccess.GetKeyValue("glossaryversion").Value;

            Document doc = new Document(new Rectangle(0, 0, PageWidth * ppi, PageHeight * ppi));

            MemoryStream m = new MemoryStream();

            PdfWriter writer = PdfWriter.GetInstance(doc, m);
            writer.CloseStream = false;

            try {
                doc.AddTitle("The Glossary of Systematic Christian Theology");
                doc.AddSubject("A collection of technical terms and associated definitions as taught from the pulpit by Dr. Ron Killingsworth in classes at Rephidim Church.");
                doc.AddCreator("My program using iText#");
                doc.AddAuthor("Dr. Ron Killingsworth");
                doc.AddCreationDate();

                writer.SetEncryption(PdfWriter.STRENGTH128BITS, null, "xaris", PdfWriter.AllowCopy | PdfWriter.AllowPrinting | PdfWriter.AllowScreenReaders | PdfWriter.AllowDegradedPrinting);

                doc.Open();

                BaseFont bfArialBlack = BaseFont.CreateFont("C:\\windows\\fonts\\ariblk.ttf", BaseFont.WINANSI, false);
                BaseFont bfGaramond = BaseFont.CreateFont("C:\\windows\\fonts\\gara.ttf", BaseFont.WINANSI, false);
                Font fntTerm = new Font(bfArialBlack, 10, Font.BOLD, new BaseColor(57, 81, 145));
                Font fntDefinition = new Font(bfGaramond, 9, Font.NORMAL, new BaseColor(0, 0, 0));

                ///////////////////////////////////////////

                if (HasMultipleDefinitions) {
                    PdfContentByte cbCover = new PdfContentByte(writer);
                    cbCover = writer.DirectContent;

                    cbCover.BeginText();

                    cbCover.SetFontAndSize(bfGaramond, 42);
                    cbCover.SetRGBColorFill(57, 81, 145);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Glossary of", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(1.5)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Systematic Christian Theology", (PageWidth / 2) * ppi, ((PageHeight / 2) + 1) * ppi, 0);

                    cbCover.SetFontAndSize(bfGaramond, 16);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "A collection of technical terms and associated definitions", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(0.6)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "as taught by Dr. Ron Killingsworth, Rephidim Church, Wichita Falls, Texas", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(0.4)) * ppi, 0);

                    cbCover.SetFontAndSize(bfGaramond, 12);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Published by:", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(0.6)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Rephidim Doctrinal Bible Studies, Inc.", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(0.8)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "4430 Allendale Rd., Wichita Falls, Texas 76310", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(1.0)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "(940) 691-1166     rephidim.org     [email protected]", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(1.2)) * ppi, 0);

                    cbCover.SetFontAndSize(bfGaramond, 10);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Version: " + version + " / " + terms.Count() + " terms", (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                    cbCover.SetFontAndSize(bfGaramond, 10);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "© 1971-" + DateTime.Today.Year.ToString() + " Dr. Ron Killingsworth, Rephidim Doctrinal Bible Studies, Inc.", (PageWidth - LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                    cbCover.EndText();

                    doc.NewPage();

                    ///////////////////////////////////////////

                    PdfContentByte cbBlank = new PdfContentByte(writer);
                    cbBlank = writer.DirectContent;

                    cbBlank.BeginText();

                    cbCover.SetFontAndSize(bfGaramond, 10);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_LEFT, " ", (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                    cbBlank.EndText();

                    doc.NewPage();

                    ///////////////////////////////////////////

                }

                PdfContentByte cb = writer.DirectContent;
                ColumnText ct = new ColumnText(cb);

                int[] left = {
                    Convert.ToInt32(Column1Left * ppi),
                    Convert.ToInt32(Column2Left * ppi)
                };
                int[] right = {
                    Convert.ToInt32(Column1Right * ppi),
                    Convert.ToInt32(Column2Right * ppi)
                };

                foreach (var term in terms) {
                    ct.AddText(new Phrase(term.Term.Trim() + Environment.NewLine, fntTerm));
                    ct.AddText(new Phrase(Regex.Replace(term.Definition.Trim().Replace("<br/>", "\r"), @"<[^>]+>", "") + Environment.NewLine + Environment.NewLine, fntDefinition));
                }

                int status = 0;
                int column = 0;
                int PageNumber = 0;
                if (HasMultipleDefinitions) {
                    PageNumber = 3;
                } else {
                    PageNumber = 1;
                }
                while ((status & ColumnText.NO_MORE_TEXT) == 0) {
                    ///////////////////////////////////////////

                    PdfContentByte cbPage = new PdfContentByte(writer);
                    cbPage = writer.DirectContent;

                    cbPage.SetLineWidth(0.5f);
                    cbPage.SetRGBColorStroke(50, 50, 50);
                    cbPage.MoveTo(LeftRightMargin * ppi, (PageHeight - TopBottomMargin - (HeaderFooterHeight / 2)) * ppi);
                    cbPage.LineTo((PageWidth - LeftRightMargin) * ppi, (PageHeight - TopBottomMargin - (HeaderFooterHeight / 2)) * ppi);
                    cbPage.Stroke();

                    cbPage.SetLineWidth(0.5f);
                    cbPage.SetRGBColorStroke(50, 50, 50);
                    cbPage.MoveTo(LeftRightMargin * ppi, (TopBottomMargin + HeaderFooterHeight) * ppi);
                    cbPage.LineTo((PageWidth - LeftRightMargin) * ppi, (TopBottomMargin + HeaderFooterHeight) * ppi);
                    cbPage.Stroke();

                    cbPage.BeginText();

                    cbPage.SetFontAndSize(bfGaramond, 10);
                    cbPage.SetRGBColorFill(0, 0, 0);
                    cbPage.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "The Glossary of Systematic Christian Theology", (PageWidth / 2) * ppi, (PageHeight - TopBottomMargin) * ppi, 0);

                    if (PageNumber % 2 == 0) {
                        cbPage.SetFontAndSize(bfGaramond, 8);
                        cbPage.SetRGBColorFill(0, 0, 0);
                        cbPage.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "© 1971-" + DateTime.Today.Year.ToString() + " Dr. Ron Killingsworth, Rephidim Doctrinal Bible Studies, Inc.", (PageWidth - LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                        cbPage.SetFontAndSize(bfGaramond, 8);
                        cbPage.SetRGBColorFill(0, 0, 0);
                        cbPage.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Page " + PageNumber.ToString(), (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);
                    } else {
                        cbPage.SetFontAndSize(bfGaramond, 8);
                        cbPage.SetRGBColorFill(0, 0, 0);
                        cbPage.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "© 1971-" + DateTime.Today.Year.ToString() + " Dr. Ron Killingsworth, Rephidim Doctrinal Bible Studies, Inc.", (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                        cbPage.SetFontAndSize(bfGaramond, 8);
                        cbPage.SetRGBColorFill(0, 0, 0);
                        cbPage.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "Page " + PageNumber.ToString(), (PageWidth - LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                    }

                    cbPage.EndText();

                    ///////////////////////////////////////////

                    //If HasMultipleDefinitions Then
                    //    ct.setSimpleColumn(left(column), (TopBottomMargin + (HeaderFooterHeight * 3 / 2)) * ppi, right(column), (PageHeight - TopBottomMargin - HeaderFooterHeight) * ppi, 10, Element.ALIGN_LEFT)
                    //Else
                    //    ct.setSimpleColumn(LeftRightMargin * ppi, (TopBottomMargin + (HeaderFooterHeight * 3 / 2)) * ppi, (PageWidth - LeftRightMargin) * ppi, (PageHeight - TopBottomMargin - HeaderFooterHeight) * ppi, 10, Element.ALIGN_LEFT)
                    //End If
                    //status = ct.go()
                    //If (status And ColumnText.NO_MORE_COLUMN) <> 0 Then
                    //    column += 1
                    //    If column > 1 Then

                    //        doc.newPage()
                    //        PageNumber += 1
                    //        column = 0
                    //    End If
                    //End If

                    if (HasMultipleDefinitions) {
                        ct.SetSimpleColumn(left[column], (TopBottomMargin + (HeaderFooterHeight * 3 / 2)) * ppi, right[column], (PageHeight - TopBottomMargin - HeaderFooterHeight) * ppi, 10, Element.ALIGN_LEFT);

                        status = ct.Go();
                        if ((status & ColumnText.NO_MORE_COLUMN) != 0) {
                            column += 1;

                            if (column > 1) {
                                doc.NewPage();
                                PageNumber += 1;
                                column = 0;
                            }
                        }
                    } else {
                        ct.SetSimpleColumn(LeftRightMargin * ppi, (TopBottomMargin + (HeaderFooterHeight * 3 / 2)) * ppi, (PageWidth - LeftRightMargin) * ppi, (PageHeight - TopBottomMargin - HeaderFooterHeight) * ppi, 10, Element.ALIGN_LEFT);

                        status = ct.Go();
                        if ((status) != 0) {
                            doc.NewPage();
                            PageNumber += 1;
                        }
                    }

                }

                doc.Close();
                m.Flush();
                m.Position = 0;
                return m;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #14
0
// ---------------------------------------------------------------------------    
    /**
     * 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();
    }    
        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);
            }
        }
Beispiel #16
0
        /**
        * Writes a text line to the document. It takes care of all the attributes.
        * <P>
        * Before entering the line position must have been established and the
        * <CODE>text</CODE> argument must be in text object scope (<CODE>beginText()</CODE>).
        * @param line the line to be written
        * @param text the <CODE>PdfContentByte</CODE> where the text will be written to
        * @param graphics the <CODE>PdfContentByte</CODE> where the graphics will be written to
        * @param currentValues the current font and extra spacing values
        * @param ratio
        * @throws DocumentException on error
        */
        internal void WriteLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio)
        {
            PdfFont currentFont = (PdfFont)(currentValues[0]);
            float lastBaseFactor = (float)currentValues[1];
            //PdfChunk chunkz;
            int numberOfSpaces;
            int lineLen;
            bool isJustified;
            float hangingCorrection = 0;
            float hScale = 1;
            float lastHScale = float.NaN;
            float baseWordSpacing = 0;
            float baseCharacterSpacing = 0;

            numberOfSpaces = line.NumberOfSpaces;
            lineLen = line.ToString().Length;
            // does the line need to be justified?
            isJustified = line.HasToBeJustified() && (numberOfSpaces != 0 || lineLen > 1);
            if (isJustified) {
                if (line.NewlineSplit && line.WidthLeft >= (lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1))) {
                    if (line.RTL) {
                        text.MoveText(line.WidthLeft - lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1), 0);
                    }
                    baseWordSpacing = ratio * lastBaseFactor;
                    baseCharacterSpacing = lastBaseFactor;
                }
                else {
                    float width = line.WidthLeft;
                    PdfChunk last = line.GetChunk(line.Size - 1);
                    if (last != null) {
                        String s = last.ToString();
                        char c;
                        if (s.Length > 0 && hangingPunctuation.IndexOf((c = s[s.Length - 1])) >= 0) {
                            float oldWidth = width;
                            width += last.Font.Width(c) * 0.4f;
                            hangingCorrection = width - oldWidth;
                        }
                    }
                    float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1);
                    baseWordSpacing = ratio * baseFactor;
                    baseCharacterSpacing = baseFactor;
                    lastBaseFactor = baseFactor;
                }
            }

            int lastChunkStroke = line.LastStrokeChunk;
            int chunkStrokeIdx = 0;
            float xMarker = text.XTLM;
            float baseXMarker = xMarker;
            float yMarker = text.YTLM;
            bool adjustMatrix = false;

            // looping over all the chunks in 1 line
            foreach (PdfChunk chunk in line) {
                Color color = chunk.Color;
                hScale = 1;

                if (chunkStrokeIdx <= lastChunkStroke) {
                    float width;
                    if (isJustified) {
                        width = chunk.GetWidthCorrected(baseCharacterSpacing, baseWordSpacing);
                    }
                    else
                        width = chunk.Width;
                    if (chunk.IsStroked()) {
                        PdfChunk nextChunk = line.GetChunk(chunkStrokeIdx + 1);
                        if (chunk.IsAttribute(Chunk.BACKGROUND)) {
                            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];
                            if (obj[1] is String)
                                RemoteGoto(filename, (String)obj[1], xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.Font.Size);
                            else
                                RemoteGoto(filename, (int)obj[1], xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.Font.Size);
                        }
                        if (chunk.IsAttribute(Chunk.LOCALGOTO)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.LOCALGOTO))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            LocalGoto((String)chunk.GetAttribute(Chunk.LOCALGOTO), xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.Font.Size);
                        }
                        if (chunk.IsAttribute(Chunk.LOCALDESTINATION)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.LOCALDESTINATION))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            LocalDestination((String)chunk.GetAttribute(Chunk.LOCALDESTINATION), new PdfDestination(PdfDestination.XYZ, xMarker, yMarker + chunk.Font.Size, 0));
                        }
                        if (chunk.IsAttribute(Chunk.GENERICTAG)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.GENERICTAG))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            Rectangle rect = new Rectangle(xMarker, yMarker, xMarker + width - subtract, yMarker + chunk.Font.Size);
                            IPdfPageEvent pev = writer.PageEvent;
                            if (pev != null)
                                pev.OnGenericTag(writer, this, rect, (String)chunk.GetAttribute(Chunk.GENERICTAG));
                        }
                        if (chunk.IsAttribute(Chunk.PDFANNOTATION)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.PDFANNOTATION))
                                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);
                            PdfAnnotation annot = PdfFormField.ShallowDuplicate((PdfAnnotation)chunk.GetAttribute(Chunk.PDFANNOTATION));
                            annot.Put(PdfName.RECT, new PdfRectangle(xMarker, yMarker + descender, xMarker + width - subtract, yMarker + ascender));
                            text.AddAnnotation(annot);
                        }
                        float[] paramsx = (float[])chunk.GetAttribute(Chunk.SKEW);
                        object hs = chunk.GetAttribute(Chunk.HSCALE);
                        if (paramsx != null || hs != null) {
                            float b = 0, c = 0;
                            if (paramsx != null) {
                                b = paramsx[0];
                                c = paramsx[1];
                            }
                            if (hs != null)
                                hScale = (float)hs;
                            text.SetTextMatrix(hScale, b, c, 1, xMarker, yMarker);
                        }
                        if (chunk.IsImage()) {
                            Image image = chunk.Image;
                            float[] matrix = image.Matrix;
                            matrix[Image.CX] = xMarker + chunk.ImageOffsetX - matrix[Image.CX];
                            matrix[Image.CY] = yMarker + chunk.ImageOffsetY - matrix[Image.CY];
                            graphics.AddImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
                            text.MoveText(xMarker + lastBaseFactor + image.ScaledWidth - text.XTLM, 0);
                        }
                    }
                    xMarker += width;
                    ++chunkStrokeIdx;
                }

                if (chunk.Font.CompareTo(currentFont) != 0) {
                    currentFont = chunk.Font;
                    text.SetFontAndSize(currentFont.Font, currentFont.Size);
                }
                float rise = 0;
                Object[] textRender = (Object[])chunk.GetAttribute(Chunk.TEXTRENDERMODE);
                int tr = 0;
                float strokeWidth = 1;
                Color strokeColor = null;
                object fr = chunk.GetAttribute(Chunk.SUBSUPSCRIPT);
                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 = (Color)textRender[2];
                        if (strokeColor == null)
                            strokeColor = color;
                        if (strokeColor != null)
                            text.SetColorStroke(strokeColor);
                    }
                }
                if (fr != null)
                    rise = (float)fr;
                if (color != null)
                    text.SetColorFill(color);
                if (rise != 0)
                    text.SetTextRise(rise);
                if (chunk.IsImage()) {
                    adjustMatrix = true;
                }
                // If it is a CJK chunk or Unicode TTF we will have to simulate the
                // space adjustment.
                else if (isJustified && numberOfSpaces > 0 && chunk.IsSpecialEncoding()) {
                    if (hScale != lastHScale) {
                        lastHScale = hScale;
                        text.SetWordSpacing(baseWordSpacing / hScale);
                        text.SetCharacterSpacing(baseCharacterSpacing / hScale);
                    }
                    String s = chunk.ToString();
                    int idx = s.IndexOf(' ');
                    if (idx < 0)
                        text.ShowText(chunk.ToString());
                    else {
                        float spaceCorrection = - baseWordSpacing * 1000f / chunk.Font.Size / hScale;
                        PdfTextArray textArray = new PdfTextArray(s.Substring(0, idx));
                        int lastIdx = idx;
                        while ((idx = s.IndexOf(' ', lastIdx + 1)) >= 0) {
                            textArray.Add(spaceCorrection);
                            textArray.Add(s.Substring(lastIdx, idx - lastIdx));
                            lastIdx = idx;
                        }
                        textArray.Add(spaceCorrection);
                        textArray.Add(s.Substring(lastIdx));
                        text.ShowText(textArray);
                    }
                }
                else {
                    if (isJustified && hScale != lastHScale) {
                        lastHScale = hScale;
                        text.SetWordSpacing(baseWordSpacing / hScale);
                        text.SetCharacterSpacing(baseCharacterSpacing / hScale);
                    }
                    text.ShowText(chunk.ToString());
                }

                if (rise != 0)
                    text.SetTextRise(0);
                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);
                if (chunk.IsAttribute(Chunk.SKEW) || chunk.IsAttribute(Chunk.HSCALE)) {
                    adjustMatrix = true;
                    text.SetTextMatrix(xMarker, yMarker);
                }
            }
            if (isJustified) {
                text.SetWordSpacing(0);
                text.SetCharacterSpacing(0);
                if (line.NewlineSplit)
                    lastBaseFactor = 0;
            }
            if (adjustMatrix)
                text.MoveText(baseXMarker - text.XTLM, 0);
            currentValues[0] = currentFont;
            currentValues[1] = lastBaseFactor;
        }
Beispiel #17
0
 void SetLineWidth(PdfContentByte cb, IDictionary<String, String> css)
 {
     String width;
     if (css.TryGetValue(SVGAttributes.STROKE_WIDTH, out width))
     {
         try
         {
             cb.SetLineWidth(float.Parse(width));
         } catch {
             //DO nothing
         }
     }
 }
Beispiel #18
0
        public void Draw(PdfContentByte cb, IList<float[]> lines, IList<IElement> list)
        {
            if (lines.Count < 2)
            {
                return; //Do nothing
            }

            //TODO check all the style elements
            cb.SetLineWidth(3);
            //first set a letter type
            BaseFont bf = BaseFont.CreateFont("c:/windows/fonts/arial.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED);
            cb.SetFontAndSize(bf, fontsize);

            float xPrevious = lines[0][0], yPrevious = lines[0][1];
            int indexOfTextElement = 0, indexOfCharacter = 0;

            String currentCharacter = GetCharacter(indexOfTextElement, indexOfCharacter);
            while (string.IsNullOrEmpty(currentCharacter))
            {
                if (indexOfCharacter >= GetLengthOfText(indexOfTextElement) - 1)
                {
                    //this was the last character of the text element
                    if (indexOfTextElement == list.Count - 1)
                    {
                        //this was the last text element; exit while loop
                        return; //stop
                    }
                    else
                    {
                        //goto first character of the next element
                        //TODO set the css
                        indexOfTextElement++;
                        indexOfCharacter = 0;
                    }
                }
                currentCharacter = GetCharacter(indexOfTextElement, indexOfCharacter);
            }

            double halfWidthOfCharacter = cb.GetEffectiveStringWidth(currentCharacter, true)/2.0;
            double totalLength = 0;

            bool lookForStart = true;

            for (int j = 1; j < lines.Count; j++)
            {

                float[] point = lines[j];

                double lengthLijnStuk = CalculateDistance(xPrevious, yPrevious, point[0], point[1]);
                //System.out.Println(lengthLijnStuk);
                totalLength = totalLength + lengthLijnStuk;
                //System.out.Println(totalLength);

                while (totalLength >= halfWidthOfCharacter)
                {
                    double tussen = totalLength - halfWidthOfCharacter;
                    double xyAlongThis = lengthLijnStuk - tussen - halfWidthOfCharacter;
                    double[] xy = GetPointOnLine(xPrevious, yPrevious, point[0], point[1], xyAlongThis);

                    if (lookForStart)
                    {
                        ShowText(cb, point[0], point[1], xPrevious, yPrevious, xy[0], xy[1], currentCharacter);
                        lookForStart = false;
                        totalLength = tussen; //distance to the end of the line segment

                    }
                    else
                    {
                        //look for the end point
                        lookForStart = true;
                        totalLength = tussen; //distance to the end of the line segment 

                        indexOfCharacter++;
                        currentCharacter = GetCharacter(indexOfTextElement, indexOfCharacter);

                        while (currentCharacter == null || currentCharacter.Length == 0)
                        {
                            if (indexOfCharacter >= GetLengthOfText(indexOfTextElement) - 1)
                            {
                                //this was the last character of the text element
                                if (indexOfTextElement == list.Count - 1)
                                {
                                    //this was the last text element; exit while loop
                                    return;
                                }
                                else
                                {
                                    //goto first character of the next element
                                    indexOfTextElement++;
                                    indexOfCharacter = 0;
                                }
                            }
                            currentCharacter = GetCharacter(indexOfTextElement, indexOfCharacter);
                        }
                        halfWidthOfCharacter = cb.GetEffectiveStringWidth(currentCharacter, true)/2.0;
                    }
                }

                xPrevious = point[0];
                yPrevious = point[1];
            }
        }
 /**
  * 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) {
     cb.SetColorStroke(BaseColor.BLACK);
     cb.SetColorFill(BaseColor.LIGHT_GRAY);
     cb.Rectangle(x, y, 100, 200);
     cb.Fill();
     cb.SetLineWidth(2);
     cb.Rectangle(x, y, 200, 200);
     cb.Stroke();
 }
Beispiel #20
0
 /**
 * 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();
 }
 /**
  * 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();
 }
Beispiel #22
0
 public bool Open(PdfContentByte cb, float fontSize, float xtlm, float ytlm)
 {
     if (!_isPrevEmDash)
     {
         var padding = fontSize * _emDashPaddingRatio;
         cb.EndText();
         cb.SetLineWidth(_lineWidth);
         cb.MoveTo(xtlm, ytlm - padding);
         _isPrevEmDash = true;
         return true;
     }
     else
     {
         return false;
     }
 }
        /**
        * Writes a text line to the document. It takes care of all the attributes.
        * <P>
        * Before entering the line position must have been established and the
        * <CODE>text</CODE> argument must be in text object scope (<CODE>beginText()</CODE>).
        * @param line the line to be written
        * @param text the <CODE>PdfContentByte</CODE> where the text will be written to
        * @param graphics the <CODE>PdfContentByte</CODE> where the graphics will be written to
        * @param currentValues the current font and extra spacing values
        * @param ratio
        * @throws DocumentException on error
        */
        internal float WriteLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio)  {
            PdfFont currentFont = (PdfFont)(currentValues[0]);
            float lastBaseFactor = (float)currentValues[1];
            //PdfChunk chunkz;
            int numberOfSpaces;
            int lineLen;
            bool isJustified;
            float hangingCorrection = 0;
            float hScale = 1;
            float lastHScale = float.NaN;
            float baseWordSpacing = 0;
            float baseCharacterSpacing = 0;
            float glueWidth = 0;
            float lastX = text.XTLM + line.OriginalWidth;
            
            numberOfSpaces = line.NumberOfSpaces;
            lineLen = line.GetLineLengthUtf32();
            // does the line need to be justified?
            isJustified = line.HasToBeJustified() && (numberOfSpaces != 0 || lineLen > 1);
            int separatorCount = line.GetSeparatorCount();
            if (separatorCount > 0) {
                glueWidth = line.WidthLeft / separatorCount;
            }
            else if (isJustified && separatorCount == 0) {
                if (line.NewlineSplit && line.WidthLeft >= (lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1))) {
                    if (line.RTL) {
                        text.MoveText(line.WidthLeft - lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1), 0);
                    }
                    baseWordSpacing = ratio * lastBaseFactor;
                    baseCharacterSpacing = lastBaseFactor;
                }
                else {
                    float width = line.WidthLeft;
                    PdfChunk last = line.GetChunk(line.Size - 1);
                    if (last != null) {
                        String s = last.ToString();
                        char c;
                        if (s.Length > 0 && hangingPunctuation.IndexOf((c = s[s.Length - 1])) >= 0) {
                            float oldWidth = width;
                            width += last.Font.Width(c) * 0.4f;
                            hangingCorrection = width - oldWidth;
                        }
                    }
                    float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1);
                    baseWordSpacing = ratio * baseFactor;
                    baseCharacterSpacing = baseFactor;
                    lastBaseFactor = baseFactor;
                }
            }
            else if (line.alignment == Element.ALIGN_LEFT || line.alignment == Element.ALIGN_UNDEFINED) {
                lastX -= line.WidthLeft;
            }
            
            int lastChunkStroke = line.LastStrokeChunk;
            int chunkStrokeIdx = 0;
            float xMarker = text.XTLM;
            float baseXMarker = xMarker;
            float yMarker = text.YTLM;
            bool adjustMatrix = false;
            float tabPosition = 0;
            
            // looping over all the chunks in 1 line
            foreach (PdfChunk chunk in line) {
                if (IsTagged(writer) && chunk.accessibleElement != null) {
                    text.OpenMCBlock(chunk.accessibleElement);
                }
                BaseColor color = chunk.Color;
                float fontSize = chunk.Font.Size;
                float ascender;
                float descender;
                if (chunk.IsImage())
                {
                    ascender = chunk.Height();
                    descender = 0;
                }
                else
                {
                    ascender = chunk.Font.Font.GetFontDescriptor(BaseFont.ASCENT, fontSize);
                    descender = chunk.Font.Font.GetFontDescriptor(BaseFont.DESCENT, fontSize);
                }
                hScale = 1;
                
                if (chunkStrokeIdx <= lastChunkStroke) {
                    float width;
                    if (isJustified) {
                        width = chunk.GetWidthCorrected(baseCharacterSpacing, baseWordSpacing);
                    }
                    else {
                        width = chunk.Width();
                    }
                    if (chunk.IsStroked()) {
                        PdfChunk nextChunk = line.GetChunk(chunkStrokeIdx + 1);
                        if (chunk.IsSeparator()) {
                            width = glueWidth;
                            Object[] sep = (Object[])chunk.GetAttribute(Chunk.SEPARATOR);
                            IDrawInterface di = (IDrawInterface)sep[0];
                            bool vertical = (bool)sep[1];
                            if (vertical) {
                                di.Draw(graphics, baseXMarker, yMarker + descender, baseXMarker + line.OriginalWidth, ascender - descender, yMarker);      
                            }
                            else {
                                di.Draw(graphics, xMarker, yMarker + descender, xMarker + width, ascender - descender, yMarker);
                            }
                        }
                        if (chunk.IsTab()) {
                            if (chunk.IsAttribute(Chunk.TABSETTINGS))
                            {
                                TabStop tabStop = chunk.TabStop;
                                if (tabStop != null) {
                                    tabPosition = tabStop.Position + baseXMarker;
                                    if (tabStop.Leader != null)
                                        tabStop.Leader.Draw(graphics, xMarker, yMarker + descender, tabPosition, ascender - descender, yMarker);
                                }
                                else {
                                    tabPosition = xMarker;
                                }
                            } else {
                                //Keep deprecated tab logic for backward compatibility...
                                Object[] tab = (Object[])chunk.GetAttribute(Chunk.TAB);
                                IDrawInterface di = (IDrawInterface)tab[0];
                                tabPosition = (float)tab[1] + (float)tab[3];
                                if (tabPosition > xMarker)
                                    di.Draw(graphics, xMarker, yMarker + descender, tabPosition, ascender - descender, yMarker);
                            }
                            float tmp = xMarker;
                            xMarker = tabPosition;
                            tabPosition = tmp;
                        }
                        if (chunk.IsAttribute(Chunk.BACKGROUND)) {
                            bool inText = graphics.InText;
                            if (inText && IsTagged(writer)) {
                                graphics.EndText();
                            }
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.BACKGROUND))
                                subtract = 0;
                            if (nextChunk == null)
                                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));
                            }
                            text.AddAnnotation(annot, true);
                            if (IsTagged(writer) && chunk.accessibleElement != null) {
                                int structParent = GetStructParentIndex(annot);
                                annot.Put(PdfName.STRUCTPARENT, new PdfNumber(structParent));
                                PdfStructureElement strucElem;
                                structElements.TryGetValue(chunk.accessibleElement.ID, out strucElem);
                                if (strucElem != null) {
                                    PdfArray kArray = strucElem.GetAsArray(PdfName.K);
                                    if (kArray == null) {
                                        kArray = new PdfArray();
                                        PdfObject k = strucElem.Get(PdfName.K);
                                        if (k != null) {
                                            kArray.Add(k);
                                        }
                                        strucElem.Put(PdfName.K, kArray);
                                    }
                                    PdfDictionary dict = new PdfDictionary();
                                    dict.Put(PdfName.TYPE, PdfName.OBJR);
                                    dict.Put(PdfName.OBJ, annot.IndirectReference);
                                    kArray.Add(dict);
                                    writer.StructureTreeRoot.SetAnnotationMark(structParent, strucElem.Reference);
                                }
                            }
                        }
                        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];
                            if (obj[1] is String)
                                RemoteGoto(filename, (String)obj[1], xMarker, yMarker + descender + chunk.TextRise, xMarker + width - subtract, yMarker + ascender + chunk.TextRise);
                            else
                                RemoteGoto(filename, (int)obj[1], xMarker, yMarker + descender + chunk.TextRise, xMarker + width - subtract, yMarker + ascender + chunk.TextRise);
                        }
                        if (chunk.IsAttribute(Chunk.LOCALGOTO)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.LOCALGOTO))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            LocalGoto((String)chunk.GetAttribute(Chunk.LOCALGOTO), xMarker, yMarker, xMarker + width - subtract, yMarker + fontSize);
                        }
                        if (chunk.IsAttribute(Chunk.LOCALDESTINATION)) {
                            /*float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.LOCALDESTINATION))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;*/
                            LocalDestination((String)chunk.GetAttribute(Chunk.LOCALDESTINATION), new PdfDestination(PdfDestination.XYZ, xMarker, yMarker + fontSize, 0));
                        }
                        if (chunk.IsAttribute(Chunk.GENERICTAG)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.GENERICTAG))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            Rectangle rect = new Rectangle(xMarker, yMarker, xMarker + width - subtract, yMarker + fontSize);
                            IPdfPageEvent pev = writer.PageEvent;
                            if (pev != null)
                                pev.OnGenericTag(writer, this, rect, (String)chunk.GetAttribute(Chunk.GENERICTAG));
                        }
                        if (chunk.IsAttribute(Chunk.PDFANNOTATION)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.PDFANNOTATION))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            PdfAnnotation annot = PdfFormField.ShallowDuplicate((PdfAnnotation)chunk.GetAttribute(Chunk.PDFANNOTATION));
                            annot.Put(PdfName.RECT, new PdfRectangle(xMarker, yMarker + descender, xMarker + width - subtract, yMarker + ascender));
                            text.AddAnnotation(annot, true);
                        }
                        float[] paramsx = (float[])chunk.GetAttribute(Chunk.SKEW);
                        object hs = chunk.GetAttribute(Chunk.HSCALE);
                        if (paramsx != null || hs != null) {
                            float b = 0, c = 0;
                            if (paramsx != null) {
                                b = paramsx[0];
                                c = paramsx[1];
                            }
                            if (hs != null)
                                hScale = (float)hs;
                            text.SetTextMatrix(hScale, b, c, 1, xMarker, yMarker);
                        }
                        if (!isJustified)
                        {
                            if (chunk.IsAttribute(Chunk.WORD_SPACING))
                            {
                                float ws = (float)chunk.GetAttribute(Chunk.WORD_SPACING);
                                text.SetWordSpacing(ws);
                            }
                        }

                        if (chunk.IsAttribute(Chunk.CHAR_SPACING)) {
                    	    float cs = (float) chunk.GetAttribute(Chunk.CHAR_SPACING);
						    text.SetCharacterSpacing(cs);
					    }
                        if (chunk.IsImage()) {
                            Image image = chunk.Image;
                            width = chunk.ImageWidth;
                            float[] matrix = image.GetMatrix(chunk.ImageScalePercentage);
                            matrix[Image.CX] = xMarker + chunk.ImageOffsetX - matrix[Image.CX];
                            matrix[Image.CY] = yMarker + chunk.ImageOffsetY - matrix[Image.CY];
                            graphics.AddImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
                            text.MoveText(xMarker + lastBaseFactor + chunk.ImageWidth - text.XTLM, 0);
                        }
                    }

                    xMarker += width;
                    ++chunkStrokeIdx;
                }

                if (!chunk.IsImage() && chunk.Font.CompareTo(currentFont) != 0) {
                    currentFont = chunk.Font;
                    text.SetFontAndSize(currentFont.Font, currentFont.Size);
                }
                float rise = 0;
                Object[] textRender = (Object[])chunk.GetAttribute(Chunk.TEXTRENDERMODE);
                int tr = 0;
                float strokeWidth = 1;
                BaseColor strokeColor = null;
                object fr = chunk.GetAttribute(Chunk.SUBSUPSCRIPT);
                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);
                    }
                }
                if (fr != null)
                    rise = (float)fr;
                if (color != null)
                    text.SetColorFill(color);
                if (rise != 0)
                    text.SetTextRise(rise);
                if (chunk.IsImage()) {
                    adjustMatrix = true;
                }
                else if (chunk.IsHorizontalSeparator()) {
                    PdfTextArray array = new PdfTextArray();
                    array.Add(-glueWidth * 1000f / chunk.Font.Size / hScale);
                    text.ShowText(array);
                }
                else if (chunk.IsTab() && tabPosition != xMarker)
                {
                    PdfTextArray array = new PdfTextArray();
                    array.Add((tabPosition - xMarker) * 1000f / chunk.Font.Size / hScale);
                    text.ShowText(array);
                }
                
                // If it is a CJK chunk or Unicode TTF we will have to simulate the
                // space adjustment.
                else if (isJustified && numberOfSpaces > 0 && chunk.IsSpecialEncoding()) {
                    if (hScale != lastHScale) {
                        lastHScale = hScale;
                        text.SetWordSpacing(baseWordSpacing / hScale);
                        text.SetCharacterSpacing(baseCharacterSpacing / hScale + text.CharacterSpacing);
                    }
                    String s = chunk.ToString();
                    int idx = s.IndexOf(' ');
                    if (idx < 0)
                        text.ShowText(s);
                    else {
                        float spaceCorrection = - baseWordSpacing * 1000f / chunk.Font.Size / hScale;
                        PdfTextArray textArray = new PdfTextArray(s.Substring(0, idx));
                        int lastIdx = idx;
                        while ((idx = s.IndexOf(' ', lastIdx + 1)) >= 0) {
                            textArray.Add(spaceCorrection);
                            textArray.Add(s.Substring(lastIdx, idx - lastIdx));
                            lastIdx = idx;
                        }
                        textArray.Add(spaceCorrection);
                        textArray.Add(s.Substring(lastIdx));
                        text.ShowText(textArray);
                    }
                }
                else {
                    if (isJustified && hScale != lastHScale) {
                        lastHScale = hScale;
                        text.SetWordSpacing(baseWordSpacing / hScale);
                        text.SetCharacterSpacing(baseCharacterSpacing / hScale + text.CharacterSpacing);
                    }
                    text.ShowText(chunk.ToString());
                }
                
                if (rise != 0)
                    text.SetTextRise(0);
                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);            
                if (chunk.IsAttribute(Chunk.SKEW) || chunk.IsAttribute(Chunk.HSCALE)) {
                    adjustMatrix = true;
                    text.SetTextMatrix(xMarker, yMarker);
                }
                if (chunk.IsAttribute(Chunk.CHAR_SPACING)) {
				    text.SetCharacterSpacing(baseCharacterSpacing);
                }
                if (chunk.IsAttribute(Chunk.WORD_SPACING)) {
                    text.SetWordSpacing(baseWordSpacing);
                }
                if (IsTagged(writer) && chunk.accessibleElement != null) {
                    text.CloseMCBlock(chunk.accessibleElement);
                }
            }
            if (isJustified) {
                text.SetWordSpacing(0);
                text.SetCharacterSpacing(0);
                if (line.NewlineSplit)
                    lastBaseFactor = 0;
            }
            if (adjustMatrix)
                text.MoveText(baseXMarker - text.XTLM, 0);
            currentValues[0] = currentFont;
            currentValues[1] = lastBaseFactor;
            return lastX;
        }
Beispiel #24
0
 private static void Reset(PdfContentByte cb)
 {
     cb.SetLineWidth(1);
     cb.ResetCMYKColorFill();
     cb.ResetCMYKColorStroke();
     cb.ResetGrayFill();
     cb.ResetGrayStroke();
     cb.ResetRGBColorFill();
     cb.ResetRGBColorStroke();
 }
Beispiel #25
-9
 // ---------------------------------------------------------------------------    
 /**
  * Draws a rectangle
  * @param content the direct content layer
  * @param width the width of the rectangle
  * @param height the height of the rectangle
  */
 public static void DrawRectangle(
   PdfContentByte content, float width, float height)
 {
     content.SaveState();
     PdfGState state = new PdfGState();
     state.FillOpacity = 0.6f;
     content.SetGState(state);
     content.SetRGBColorFill(0xFF, 0xFF, 0xFF);
     content.SetLineWidth(3);
     content.Rectangle(0, 0, width, height);
     content.FillStroke();
     content.RestoreState();
 }