pdfsharp.net的代码示例
示例
代码源在此处查看输出
using System;
using System.Diagnostics;
using System.IO;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace HelloWorld
{
/// <summary>
///此示例是强制性的HelloWorld程序。
/// </summary>
class Program
{
static void Main(string[] args)
{
//创建一个新的PDF文档
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
//创建一个空白页
PdfPage page = document.AddPage();
//获取用于绘制的XGraphics对象
XGraphics gfx = XGraphics.FromPdfPage(page);
//创建字体
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
//画文字
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
//保存文档...
const string filename = "HelloWorld.pdf";
document.Save(filename);
//...并启动查看器。
Process.Start(filename);
}
}
}
热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短