Ejemplo n.º 1
0
        // 複数行テキストの追加(改行で文字列分割)
        public void AppendMultiLineComment(PdfContentByte pdfContentByte, string font, float fontSize, string text, float x, float y, float boxWidth, float boxHeight,
                                           int lines, float leading, string orientation = HORIZONTAL, float scale = 100f,
                                           int cyan = 0, int magenta = 0, int yellow = 0, int black = 255, int alignment = Element.ALIGN_LEFT)
        {
            var bf = BaseFont.CreateFont(font, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            pdfContentByte.SetFontAndSize(bf, fontSize);
            pdfContentByte.SetHorizontalScaling(scale);

            pdfContentByte.SetCMYKColorFill(cyan, magenta, yellow, black);

            char[]   separator = new char[] { '\r', '\n' };
            string[] comments  = text.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            // 横書きのパターン
            if (orientation == HORIZONTAL)
            {
                HorizontalText.SetMinScale(pdfContentByte, bf, comments, fontSize, boxWidth, scale);
                // y = y + boxHeight - leading;

                for (int i = 0; comments.Length > i; i++)
                {
                    if (i >= lines)
                    {
                        break;
                    }

                    string comment = comments[i];
                    HorizontalText.ShowTextH(pdfContentByte, x, y, comment, alignment, 0);
                    y -= leading;
                }
            }
            // 縦書きのパターン
            else
            {
                float vScale = VerticalText.GetMinVerticalScaling(comments, fontSize, boxHeight);
                x  = VerticalText.GetAlignedXV(x + boxWidth, fontSize) - leading;
                y -= fontSize * vScale;

                pdfContentByte.BeginText();
                for (int i = 0; comments.Length > i; i++)
                {
                    if (i >= lines)
                    {
                        break;
                    }

                    string comment = comments[i];
                    VerticalText.MakeVerticalLine(pdfContentByte, Kana.ToZenkaku(comment), x, y, fontSize, alignment, vScale, tatechuyoko: true, isShugo: true);
                    x -= leading;
                }
                pdfContentByte.EndText();
            }
        }
Ejemplo n.º 2
0
 // 1行テキストの追加
 public float Append(PdfContentByte pdfContentByte, string text, float x, float y, float boxWidth, float boxHeight,
                     float fontSize, string font, int alignment = 0, int cyan = 0, int magenta = 0, int yellow = 0, int black = 255,
                     float rotation = 0, float scale = 100f, string orientation = HORIZONTAL)
 {
     if (orientation == HORIZONTAL)
     {
         float ScaledWidth = HorizontalText.SetFontH(pdfContentByte, font, fontSize, text, boxWidth, cyan, magenta, yellow, black, scale);
         HorizontalText.ShowTextH(pdfContentByte, x, y, text, alignment, rotation);
         return(ScaledWidth + x);
     }
     else
     {
         VerticalText.SetFontV(pdfContentByte, font, fontSize, text, cyan, magenta, yellow, black);
         pdfContentByte.SetHorizontalScaling(100f);
         float alignedY = VerticalText.ShowTextV(pdfContentByte, Kana.ToZenkaku(text), x, y, fontSize, boxHeight, alignment);
         return(alignedY);
     }
 }