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 红包祝福语简短10字
18 周六早晨祝福语简短