diff --git a/src/Proto/Documents/DocumentProtocol.cs b/src/Proto/Documents/DocumentProtocol.cs index 9cd309a1..9a9aafde 100644 --- a/src/Proto/Documents/DocumentProtocol.cs +++ b/src/Proto/Documents/DocumentProtocol.cs @@ -1,4 +1,6 @@ -using System.Runtime.InteropServices; +using System; +using System.IO; +using System.Runtime.InteropServices; namespace Diadoc.Api.Proto.Documents { @@ -8,6 +10,8 @@ public interface IDocumentProtocol { byte[] PrintForm { get; } byte[] Signature { get; } + void SavePrintFormToFile(string path); + void SaveSignatureToFile(string path); } [ComVisible(true)] @@ -16,6 +20,25 @@ public interface IDocumentProtocol [ComDefaultInterface(typeof(IDocumentProtocol))] public partial class DocumentProtocol: SafeComObject, IDocumentProtocol { + public void SavePrintFormToFile(string path) + { + if (PrintForm == null) + { + throw new Exception("There is no content to save"); + } + + File.WriteAllBytes(path, PrintForm); + } + + public void SaveSignatureToFile(string path) + { + if (Signature == null) + { + throw new Exception("There is no content to save"); + } + + File.WriteAllBytes(path, Signature); + } } [ComVisible(true)]