如下内容内容是关于一个C#通过iTextSharp封装的PDF文件操作类的内容,希望对各位有用处。
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace DotNet.Utilities
{
public class PDFOperation
{
#region 构造函数
public PDFOperation()
{
rect = PageSize.A4;
document = new Document(rect);
}
public PDFOperation(string type)
{
SetPageSize(type);
document = new Document(rect);
}
public PDFOperation(string type, float marginLeft, float marginRight, float marginTop, float marginBottom)
{
SetPageSize(type);
document = new Document(rect, marginLeft, marginRight, marginTop, marginBottom);
}
#endregion
#region 私有字段
private Font font;
#endregion
#region 设置字体
public void SetBaseFont(string path)
{
basefont = BaseFont.CreateFont(path, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);