async void ValidateSignatureAndUpload() { Dialog.ShowLoading(""); if (Contract.SignImageSource != null) { PdfDocument duplicate = (PdfDocument)Contract.Document.Clone(); var addPage = duplicate.Pages.Add(); var width = addPage.GetClientSize().Width; PdfGraphics graphics = addPage.Graphics; PdfBitmap image = new PdfBitmap(new MemoryStream(contract.SignImageSource)); graphics.DrawImage(image, new RectangleF(20, 40, width / 2, 60)); MemoryStream m = new MemoryStream(); duplicate.Save(m); var document = await StoreManager.DocumentStore.GetItemByContractId(Contract.Id, "saleContract"); if (document == null) { var documentItem = new Document() { Path = Contract.Id + '/' + "saleContract.pdf", Name = contract.Id + ".pdf", InternalName = "saleContract", ReferenceKind = "contract", ReferenceId = contract.Id, MimeType = "application/pdf" }; var uploaded = await StoreManager.DocumentStore.InsertImage(m.ToArray(), documentItem); } else { await PclStorage.SaveFileLocal(m.ToArray(), document.Id); document.ToUpload = true; await StoreManager.DocumentStore.UpdateAsync(document); await StoreManager.DocumentStore.OfflineUploadSync(); } Contract.ToSend = true; var isSent = await StoreManager.ContractStore.UpdateAsync(Contract); if (isSent) { await CoreMethods.DisplayAlert(AppResources.Alert, AppResources.EmailSent, AppResources.Ok); BackButton.Execute(null); } } Dialog.HideLoading(); }