當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfReader.RemoveFields方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfReader.RemoveFields方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfReader.RemoveFields方法的具體用法?C# PdfReader.RemoveFields怎麽用?C# PdfReader.RemoveFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.PdfReader的用法示例。


在下文中一共展示了PdfReader.RemoveFields方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MakePage

 /// <summary>
 /// Makes a single PDF page by reference.
 /// </summary>
 /// <param name="filePath">The file path.</param>
 /// <param name="x">The running record total.</param>
 /// <param name="dt">DataTable contaning report query.</param>
 /// <param name="bdt">DataTable containing the report detail query.</param>
 /// <param name="verticalSpacing">The vertical spacing between each line in the report detail.</param>
 /// <param name="rpp">Records Per Page.</param>
 /// <param name="page">Current Page to read from.</param>
 /// <param name="currentPage">Current page to write to.</param>
 /// <param name="totalPages">The total number of pages.</param>
 /// <param name="queryArguments">The query arguments.</param>
 /// <returns>rendered pdf page</returns>
 private static MemoryStream MakePage(string filePath, ref int x, ref DataTable dt, ref DataTable bdt,
 int verticalSpacing, int rpp, int page, int currentPage, int totalPages, Dictionary<string, object> queryArguments)
 {
     ("FUNCTION /w binaryStream makePage").Debug(10);
     MemoryStream ms = new MemoryStream();
     PdfReader reader = new PdfReader(filePath);
     PdfStamper stamp = new PdfStamper(reader, ms);
     Dictionary<string, AField> docFields = new Dictionary<string, AField>();
     reader.SelectPages(page.ToString());
     float top = 0;
     for(var y = 0; rpp > y; y++) {
         if(y + x > bdt.Rows.Count - 1) { break; };
         foreach(string fieldKey in stamp.AcroFields.Fields.Keys) {
             if(fieldKey.StartsWith(">>") || fieldKey.StartsWith(">>image")) {
                 WriteField(x + y, 1, top, fieldKey, ref stamp, ref docFields, currentPage, totalPages, bdt, queryArguments);
             }
         }
         top -= verticalSpacing;
     }
     foreach(string fieldKey in stamp.AcroFields.Fields.Keys) {
         if(
         (fieldKey.StartsWith(">") && (!fieldKey.StartsWith(">>"))) ||
         (fieldKey.StartsWith(">image") && (!fieldKey.StartsWith(">>image"))) || fieldKey.StartsWith("_page")
         ) {
             WriteField(0, 0, 0, fieldKey, ref stamp, ref docFields, currentPage, totalPages, dt, queryArguments);
         }
     }
     reader.RemoveFields();
     foreach(KeyValuePair<string, AField> f in docFields) {
         Rectangle rect = f.Value.Rect;
         string value = f.Value.Value;
         TextField field = new TextField(stamp.Writer, rect, f.Key);
         field.DefaultText = value;
         field.FieldName = f.Key;
         field.Options = iTextSharp.text.pdf.TextField.MULTILINE;
         stamp.AddAnnotation(field.GetTextField(), 1);
     }
     stamp.Close();
     reader.Close();
     reader = new PdfReader(ms.GetBuffer());
     MemoryStream os = new MemoryStream();
     stamp = new PdfStamper(reader, os);
     WriteAFieldCollection(ref stamp, docFields, filePath);
     reader.RemoveFields();
     stamp.Close();
     reader.Close();
     return os;
 }
開發者ID:CorbinDallas,項目名稱:Rendition,代碼行數:62,代碼來源:Pdf.cs


注:本文中的iTextSharp.text.pdf.PdfReader.RemoveFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。