iTextSharp.text.pdf.ColumnText.ShowTextAligned C# (CSharp) Метод

ShowTextAligned() публичный статический Метод

public static ShowTextAligned ( PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation ) : void
canvas PdfContentByte
alignment int
phrase Phrase
x float
y float
rotation float
Результат void
    public static void ShowTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation) {
        ShowTextAligned(canvas, alignment, phrase, x, y, rotation, PdfWriter.RUN_DIRECTION_NO_BIDI, 0);
    }

Same methods

ColumnText::ShowTextAligned ( PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation, int runDirection, int arabicOptions ) : void

Usage Example

Пример #1
0
        /**
         * Get the <code>PdfAppearance</code> of a list field
         * @throws IOException on error
         * @throws DocumentException on error
         * @return A <code>PdfAppearance</code>
         */
        internal PdfAppearance GetListAppearance()
        {
            PdfAppearance app = GetBorderAppearance();

            if (choices == null || choices.Length == 0)
            {
                return(app);
            }
            app.BeginVariableText();

            int topChoice = GetTopChoice();

            BaseFont ufont = RealFont;
            float    usize = fontSize;

            if (usize == 0)
            {
                usize = 12;
            }
            bool  borderExtra = borderStyle == PdfBorderDictionary.STYLE_BEVELED || borderStyle == PdfBorderDictionary.STYLE_INSET;
            float h           = box.Height - borderWidth * 2;
            float offsetX     = borderWidth;

            if (borderExtra)
            {
                h       -= borderWidth * 2;
                offsetX *= 2;
            }
            float leading = ufont.GetFontDescriptor(BaseFont.BBOXURY, usize) - ufont.GetFontDescriptor(BaseFont.BBOXLLY, usize);
            int   maxFit  = (int)(h / leading) + 1;
            int   first   = 0;
            int   last    = 0;

            first = topChoice;
            last  = first + maxFit;
            if (last > choices.Length)
            {
                last = choices.Length;
            }
            topFirst = first;
            app.SaveState();
            app.Rectangle(offsetX, offsetX, box.Width - 2 * offsetX, box.Height - 2 * offsetX);
            app.Clip();
            app.NewPath();
            BaseColor fcolor = (textColor == null) ? GrayColor.GRAYBLACK : textColor;

            // background boxes for selected value[s]
            app.SetColorFill(new BaseColor(10, 36, 106));
            for (int curVal = 0; curVal < choiceSelections.Count; ++curVal)
            {
                int curChoice = choiceSelections[curVal];
                // only draw selections within our display range... not strictly necessary with
                // that clipping rect from above, but it certainly doesn't hurt either
                if (curChoice >= first && curChoice <= last)
                {
                    app.Rectangle(offsetX, offsetX + h - (curChoice - first + 1) * leading, box.Width - 2 * offsetX, leading);
                    app.Fill();
                }
            }
            float xp = offsetX * 2;
            float yp = offsetX + h - ufont.GetFontDescriptor(BaseFont.BBOXURY, usize);

            for (int idx = first; idx < last; ++idx, yp -= leading)
            {
                String ptext = choices[idx];
                int    rtl   = CheckRTL(ptext) ? PdfWriter.RUN_DIRECTION_LTR : PdfWriter.RUN_DIRECTION_NO_BIDI;
                ptext = RemoveCRLF(ptext);
                // highlight selected values against their (presumably) darker background
                BaseColor textCol = choiceSelections.Contains(idx) ? GrayColor.GRAYWHITE : fcolor;
                Phrase    phrase  = ComposePhrase(ptext, ufont, textCol, usize);
                ColumnText.ShowTextAligned(app, Element.ALIGN_LEFT, phrase, xp, yp, 0, rtl, 0);
            }
            app.RestoreState();
            app.EndVariableText();
            return(app);
        }
All Usage Examples Of iTextSharp.text.pdf.ColumnText::ShowTextAligned