当前位置: 首页>>代码示例>>C#>>正文


C# PdfStamper.Dispose方法代码示例

本文整理汇总了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);

                }
        }
开发者ID:JRDuenow,项目名称:ProgressBuilder,代码行数:71,代码来源:Export.cs


注:本文中的iTextSharp.text.pdf.PdfStamper.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。