static void CreateDocumentText(C1PdfDocument pdf)
{
// use landscape for more impact
pdf.Landscape = true;
// measure and show some text
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);
// create StringFormat used to set text alignment and line spacing
var fmt = new StringFormat();
fmt.LineSpacing = -1.5; // 1.5 char height
fmt.Alignment = HorizontalAlignment.Center;
// measure it
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);
// draw a rounded frame
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);
// draw the text
pdf.DrawString(text, font, Windows.UI.Colors.White, rc, fmt);
// now draw some text rotating about the center of the page
rc = pdf.PageRectangle;
rc = PdfUtils.Offset(rc, rc.Width / 2.2, rc.Height / 2.5);
// build StringFormat used to rotate the text
fmt = new StringFormat();
// rotate the string in small increments
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);
}
}
|