本文整理汇总了C#中iTextSharp.text.pdf.PdfStamper.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# PdfStamper.Dispose方法的具体用法?C# PdfStamper.Dispose怎么用?C# PdfStamper.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp.text.pdf.PdfStamper
的用法示例。
在下文中一共展示了PdfStamper.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportToMultiplePDF
void ExportToMultiplePDF(int index)
{
int finishedReports = 0;
PdfStamper stamper = null;
PdfReader reader = null;
//Go through each student in the list
foreach (var student in StudentList)
{
string savePath = System.IO.Path.Combine(System.IO.Path.GetFullPath(textSavePath.Text),
string.Format("{0}.pdf",
index == 0
? student.Name.Replace(' ', '_')
: student.NameReversed));
//Create FileStream for the template pdf
var templateStream = new FileStream(System.IO.Path.GetFullPath(textTempLocation.Text), FileMode.Open);
//Create FileStream for new student report pdf
var studentStream = new FileStream(savePath, FileMode.Create);
//Open existing pdf
reader = new PdfReader(templateStream);
//Create stamper to set the contents of the fields
stamper = new PdfStamper(reader, studentStream);
var form = stamper.AcroFields;
//Setting the text of the template to the stored info
form.SetField("Street", student.Address);
form.SetField("CityZipState", student.CityZipState);
form.SetField("ClassName", student.ClassName);
form.SetField("Comments", student.Comments);
form.SetField("Grade", student.Grade.ToString());
form.SetField("Critique", student.Critique);
form.SetField("HighSchool", student.HighSchool);
form.SetField("Session", student.Session);
form.SetField("Absences", student.SemesterTotalAbs.ToString());
form.SetField("Tardies", student.SemesterTotalTdy.ToString());
form.SetField("NetAbsences", student.SemesterNetAbs.ToString());
form.SetField("StuNameReversed", student.NameReversed);
form.SetField("Date", DateTime.Now.ToShortDateString());
//Flatten the fields that we do not want editable
stamper.FormFlattening = true;
stamper.PartialFormFlattening("StuNameReversed");
stamper.PartialFormFlattening("Street");
stamper.PartialFormFlattening("CityZipState");
stamper.PartialFormFlattening("HighSchool");
stamper.PartialFormFlattening("ClassName");
stamper.PartialFormFlattening("Session");
stamper.PartialFormFlattening("Absences");
stamper.PartialFormFlattening("Tardies");
stamper.PartialFormFlattening("NetAbsences");
stamper.PartialFormFlattening("Grade");
stamper.PartialFormFlattening("Critique");
stamper.Dispose();
reader.Dispose();
//reports progress to update status text on the bottom
bgProgressThread.ReportProgress(++finishedReports);
}
}