-
Notifications
You must be signed in to change notification settings - Fork 12
/
UploadDocument.cs
47 lines (39 loc) · 1.9 KB
/
UploadDocument.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.IO;
using System.Threading.Tasks;
using SignNow.Net.Model;
namespace SignNow.Net.Examples.Documents
{
public static partial class DocumentExamples
{
/// <summary>
/// Uploads a PDF with fillable field (Signature field)
/// </summary>
/// <param name="pdfFilePath">Full qualified path to your PDF with field tags.</param>
/// <param name="signNowContext">signNow container with services.</param>
public static async Task<SignNowDocument> UploadDocumentWithFieldExtract(string pdfFilePath, SignNowContext signNowContext)
{
await using var fileStream = File.OpenRead(pdfFilePath);
// Upload the document with field extract
var uploadResponse = signNowContext.Documents
.UploadDocumentWithFieldExtractAsync(fileStream, "DocumentSampleWithSignatureTextTag.pdf").Result;
var documentId = uploadResponse.Id;
return await signNowContext.Documents.GetDocumentAsync(documentId);
}
/// <summary>
/// Uploads a PDF document to signNow and returns SignNowDocument object.
/// </summary>
/// <param name="pdfFilePath">Full qualified path to your PDF file.</param>
/// <param name="signNowContext">signNow container with services.</param>
public static async Task<SignNowDocument> UploadDocument(string pdfFilePath, SignNowContext signNowContext)
{
var pdfFileName = "document-example.pdf";
await using var fileStream = File.OpenRead(pdfFilePath);
// Upload the document
var uploadResponse = signNowContext.Documents
.UploadDocumentAsync(fileStream, pdfFileName).Result;
// Gets document ID from successful response
var documentId = uploadResponse.Id;
return await signNowContext.Documents.GetDocumentAsync(documentId);
}
}
}