static void CreateDocumentText(C1PdfDocument pdf)
{
// 横方向を使用して効果を高めます
pdf.Landscape = true;
// テキストを測定および表示します
var text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmood tempor incididunt ut labore magna aliqua. Ut enim ad minim veniam,
quis nostrud excecitation ullmanco laboris.
nisi ut alquip ex ea commodo consequat.";
var font = new Font("Segoe UI Light", 14, PdfFontStyle.Italic);
// テキスト配置と行スペーシングの設定に使用する StringFormat を作成します
var fmt = new StringFormat();
fmt.LineSpacing = -1.5; // 1.5 文字の高さ
fmt.Alignment = HorizontalAlignment.Center;
// 測定します
var sz = pdf.MeasureString(text, font, 72 * 3, fmt);
var rc = new Rect(pdf.PageRectangle.Width / 2, 72, sz.Width, sz.Height);
rc = PdfUtils.Offset(rc, 110, 0);
// 角丸フレームを描画します
rc = PdfUtils.Inflate(rc, 0, 0);
pdf.FillRectangle(Windows.UI.Colors.Teal, rc, new Size(0, 0));
//pdf.DrawRectangle(new Pen(Colors.DarkGray, 5), rc, new Size(0, 0));
rc = PdfUtils.Inflate(rc, -10, -10);
// テキストを描画します
pdf.DrawString(text, font, Windows.UI.Colors.White, rc, fmt);
// ここで、ページの中心を中心として回転するテキストを描画します
rc = pdf.PageRectangle;
rc = PdfUtils.Offset(rc, rc.Width / 2.2, rc.Height / 2.5);
// テキストの回転に使用する StringFormat を作成します
fmt = new StringFormat();
// 文字列を少しずつ回転します
var step = 6;
text = "C1PDF works in Windows Runtime!";
for (int i = 0; i <= 360; i += step)
{
fmt.Angle = i;
font = new Font("Courier New", 8 + i / 30.0, PdfFontStyle.Bold);
byte b = (byte)(255 * (1 - i / 360.0));
pdf.DrawString(text, font, Windows.UI.Color.FromArgb(0xff, b, b, b), rc, fmt);
}
}
|