/// <summary>Sets the /Contents value to the specified byte[].</summary> /// <param name="contents">a byte[] representing the digest</param> public virtual void SetContents(byte[] contents) { PdfString contentsString = new PdfString(contents).SetHexWriting(true); contentsString.MarkAsUnencryptedObject(); Put(PdfName.Contents, contentsString); }
public PdfSignature(PdfDictionary sigDictionary) : base(sigDictionary) { PdfString contents = GetPdfObject().GetAsString(PdfName.Contents); if (contents != null) { contents.MarkAsUnencryptedObject(); } }
private void PopulateSignatureNames() { if (acroForm == null) { return; } IList <Object[]> sorter = new List <Object[]>(); foreach (KeyValuePair <String, PdfFormField> entry in acroForm.GetFormFields()) { PdfFormField field = entry.Value; PdfDictionary merged = field.GetPdfObject(); if (!PdfName.Sig.Equals(merged.Get(PdfName.FT))) { continue; } PdfDictionary v = merged.GetAsDictionary(PdfName.V); if (v == null) { continue; } PdfString contents = v.GetAsString(PdfName.Contents); if (contents == null) { continue; } else { contents.MarkAsUnencryptedObject(); } PdfArray ro = v.GetAsArray(PdfName.ByteRange); if (ro == null) { continue; } int rangeSize = ro.Size(); if (rangeSize < 2) { continue; } int length = ro.GetAsNumber(rangeSize - 1).IntValue() + ro.GetAsNumber(rangeSize - 2).IntValue(); sorter.Add(new Object[] { entry.Key, new int[] { length, 0 } }); } JavaCollectionsUtil.Sort(sorter, new SignatureUtil.SorterComparator()); if (sorter.Count > 0) { try { if (((int[])sorter[sorter.Count - 1][1])[0] == document.GetReader().GetFileLength()) { totalRevisions = sorter.Count; } else { totalRevisions = sorter.Count + 1; } } catch (System.IO.IOException) { } // TODO: add exception handling (at least some logger) for (int k = 0; k < sorter.Count; ++k) { Object[] objs = sorter[k]; String name = (String)objs[0]; int[] p = (int[])objs[1]; p[1] = k + 1; sigNames.Put(name, p); orderedSignatureNames.Add(name); } } }