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


C# PdfReader.KillXref方法代碼示例

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


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

示例1: SetXfa

 /**
 * Sets the XFA key from a byte array. The old XFA is erased.
 * @param form the data
 * @param reader the reader
 * @param writer the writer
 * @throws java.io.IOException on error
 */
 public static void SetXfa(XfaForm form, PdfReader reader, PdfWriter writer)
 {
     PdfDictionary af = (PdfDictionary)PdfReader.GetPdfObjectRelease(reader.Catalog.Get(PdfName.ACROFORM));
     if (af == null) {
         return;
     }
     PdfObject xfa = GetXfaObject(reader);
     if (xfa.IsArray()) {
         PdfArray ar = (PdfArray)xfa;
         int t = -1;
         int d = -1;
         for (int k = 0; k < ar.Size; k += 2) {
             PdfString s = ar.GetAsString(k);
             if ("template".Equals(s.ToString())) {
                 t = k + 1;
             }
             if ("datasets".Equals(s.ToString())) {
                 d = k + 1;
             }
         }
         if (t > -1 && d > -1) {
             reader.KillXref(ar.GetAsIndirectObject(t));
             reader.KillXref(ar.GetAsIndirectObject(d));
             PdfStream tStream = new PdfStream(SerializeDoc(form.templateNode));
             tStream.FlateCompress(writer.CompressionLevel);
             ar[t] = writer.AddToBody(tStream).IndirectReference;
             PdfStream dStream = new PdfStream(SerializeDoc(form.datasetsNode));
             dStream.FlateCompress(writer.CompressionLevel);
             ar[d] = writer.AddToBody(dStream).IndirectReference;
             af.Put(PdfName.XFA, new PdfArray(ar));
             return;
         }
     }
     reader.KillXref(af.Get(PdfName.XFA));
     PdfStream str = new PdfStream(SerializeDoc(form.domDocument));
     str.FlateCompress(writer.CompressionLevel);
     PdfIndirectReference refe = writer.AddToBody(str).IndirectReference;
     af.Put(PdfName.XFA, refe);
 }
開發者ID:bmictech,項目名稱:iTextSharp,代碼行數:46,代碼來源:XfaForm.cs

示例2: SetXfa

 /**
 * Sets the XFA key from a byte array. The old XFA is erased.
 * @param xfaData the data
 * @param reader the reader
 * @param writer the writer
 * @throws java.io.IOException on error
 */
 public static void SetXfa(byte[] xfaData, PdfReader reader, PdfWriter writer)
 {
     PdfDictionary af = (PdfDictionary)PdfReader.GetPdfObjectRelease(reader.Catalog.Get(PdfName.ACROFORM));
     if (af == null) {
         return;
     }
     reader.KillXref(af.Get(PdfName.XFA));
     PdfStream str = new PdfStream(xfaData);
     str.FlateCompress();
     PdfIndirectReference refe = writer.AddToBody(str).IndirectReference;
     af.Put(PdfName.XFA, refe);
 }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:19,代碼來源:XfaForm.cs


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