當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。