layout1.cs
来自「用C#實現能產生PDF格式文件的源碼」· CS 代码 · 共 58 行
CS
58 行
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using PdfSharp.Drawing;
using PdfSharp.Drawing.Layout;
namespace XDrawing.TestLab.Tester
{
/// <summary>
/// Checks some internal optimizations in PDF creation.
/// </summary>
public class Layout1 : TesterBase
{
public Layout1()
{
}
public override void RenderPage(XGraphics gfx)
{
//base.RenderPage(gfx);
XTextFormatter tf = new XTextFormatter(gfx);
XRect rect;
string text = this.properties.Font1.Text;
//text = "First\nSecond Line\nlaksdjf 234 234";
rect = new XRect(40, 100, 250, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
//tf.Alignment = ParagraphAlignment.Left;
tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
rect, XStringFormat.TopLeft);
rect = new XRect(310, 100, 250, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.Alignment = XParagraphAlignment.Right;
tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
rect, XStringFormat.TopLeft);
rect = new XRect(40, 400, 250, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.Alignment = XParagraphAlignment.Center;
tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
rect, XStringFormat.TopLeft);
rect = new XRect(310, 400, 250, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.Alignment = XParagraphAlignment.Justify;
tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
rect, XStringFormat.TopLeft);
}
public override string Description
{
get {return "Layout 1";}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?