private static void Saven2(TPdfStream DataStream, TXRefSection XRef, TPdfVisibleSignature VSig, int n2Id) { string s = String.Format(CultureInfo.InvariantCulture, "{0} {1} {2} {3} {4} {5} cm ", VSig.Rect.Width, 0, 0, VSig.Rect.Height, 0, 0); string StreamContents = "q " + s + TPdfTokens.GetString(TPdfToken.ImgPrefix) + "0 Do Q"; XRef.SetObjectOffset(n2Id, DataStream); TIndirectRecord.SaveHeader(DataStream, n2Id); BeginDictionary(DataStream); WriteCommonXObject(DataStream, VSig.Rect, StreamContents); TPdfResources Resources = new TPdfResources(null, false, null); using (MemoryStream ImgStream = new MemoryStream(VSig.ImageData)) { Resources.AddImage(null, ImgStream, FlxConsts.NoTransparentColor, false); } SaveProcSet(DataStream, XRef, true); SaveResourcesImgXObject(DataStream, XRef, Resources); EndDictionary(DataStream); WriteStream(DataStream, StreamContents); TIndirectRecord.SaveTrailer(DataStream); Resources.SaveObjects(DataStream, XRef); }
private static void Saven0(TPdfStream DataStream, TXRefSection XRef, TPdfVisibleSignature VSig, int n0Id) { string StreamContents = "% DSBlank"; XRef.SetObjectOffset(n0Id, DataStream); TIndirectRecord.SaveHeader(DataStream, n0Id); BeginDictionary(DataStream); WriteCommonXObject(DataStream, new RectangleF(0, 0, 100, 100), StreamContents); SaveProcSet(DataStream, XRef, false); EndDictionary(DataStream); EndDictionary(DataStream); WriteStream(DataStream, StreamContents); TIndirectRecord.SaveTrailer(DataStream); }
internal override void SaveToStream(TPdfStream DataStream, TXRefSection XRef, TPageInfo ParentPage) { BeginSaveToStream(DataStream, XRef); //Annot SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.AnnotName)); //Annots and Fields mix their dictionaries. See "Digital Signature Appearances" to see why annots are required even in non visible sigs. SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.WidgetName)); RectangleF Rect = new RectangleF(0, 0, 0, 0); TPdfVisibleSignature VSig = Signature as TPdfVisibleSignature; int APId = -1; if (VSig != null) { Rect = VSig.Rect; APId = SaveAPRef(DataStream, XRef); } SaveKey(DataStream, TPdfToken.RectName, TPdfTokens.GetString(TPdfToken.OpenArray) + String.Format(CultureInfo.InvariantCulture, "{0} {1} {2} {3}", Rect.Left, Rect.Top, Rect.Right, Rect.Bottom) + TPdfTokens.GetString(TPdfToken.CloseArray) ); SaveKey(DataStream, TPdfToken.PName, TIndirectRecord.GetCallObj(ParentPage.Id)); SaveKey(DataStream, TPdfToken.FName, 132); //bits 3 and 8 //Field SaveKey(DataStream, TPdfToken.FTName, TPdfTokens.GetString(TPdfToken.SigName)); if (Signature.Name != null) { SaveUnicodeKey(DataStream, TPdfToken.TName, Signature.Name); } SaveKey(DataStream, TPdfToken.FfName, 1); XRef.SetObjectOffset(GetSigDictionaryId(DataStream, XRef), DataStream); SaveKey(DataStream, TPdfToken.VName, TIndirectRecord.GetCallObj(SigDictionaryId)); EndSaveToStream(DataStream, XRef); if (VSig != null) { SaveAPObj(DataStream, XRef, APId, VSig); } SaveSigDictionary(DataStream, XRef, SigDictionaryId); }
internal static int GetSignaturePage(TPdfSignature Signature, int PageCount) { int Result = 0; TPdfVisibleSignature VSig = Signature as TPdfVisibleSignature; if (VSig != null) { Result = VSig.Page - 1; } if (Result < 0 || Result >= PageCount) { Result = PageCount - 1; } return(Result); }
private static void SaveFRM(TPdfStream DataStream, TXRefSection XRef, TPdfVisibleSignature VSig, int FRMId) { string StreamContents = "q 1 0 0 1 0 0 cm /n0 Do Q" + TPdfTokens.NewLine + "q 1 0 0 1 0 0 cm /n2 Do Q"; XRef.SetObjectOffset(FRMId, DataStream); TIndirectRecord.SaveHeader(DataStream, FRMId); BeginDictionary(DataStream); WriteCommonXObject(DataStream, VSig.Rect, StreamContents); int n0Id = XRef.GetNewObject(DataStream); int n2Id = XRef.GetNewObject(DataStream); SaveProcSet(DataStream, XRef, false); SaveResourcesSecondXObject(DataStream, n0Id, n2Id); EndDictionary(DataStream); WriteStream(DataStream, StreamContents); TIndirectRecord.SaveTrailer(DataStream); Saven0(DataStream, XRef, VSig, n0Id); Saven2(DataStream, XRef, VSig, n2Id); }
private static void SaveAPObj(TPdfStream DataStream, TXRefSection XRef, int APId, TPdfVisibleSignature VSig) { string StreamContents = "q 1 0 0 1 0 0 cm /FRM Do Q"; //AP Object XRef.SetObjectOffset(APId, DataStream); TIndirectRecord.SaveHeader(DataStream, APId); BeginDictionary(DataStream); WriteCommonXObject(DataStream, VSig.Rect, StreamContents); int FRMId = XRef.GetNewObject(DataStream); SaveProcSet(DataStream, XRef, false); SaveResourcesFirstXObject(DataStream, XRef, FRMId); EndDictionary(DataStream); WriteStream(DataStream, StreamContents); TIndirectRecord.SaveTrailer(DataStream); SaveFRM(DataStream, XRef, VSig, FRMId); }