public void Pdf_ConvertAndSign_Tests() { try { pdfService.ConvertToSomeFormat("pdf-sample.pdf", PDFDocumentConvertFormat.Html, Utils.CloudStorage_Input_Folder, Utils.Local_Output_Path + "pdf-html-out.html"); pdfService.ConvertToSomeFormat("pdf-sample.pdf", PDFDocumentConvertFormat.Html, Utils.CloudStorage_Input_Folder, Utils.CloudStorage_Output_Folder + "/pdf-html-out.html"); pdfService.ConvertToSomeFormat("pdf-sample.pdf", PDFDocumentConvertFormat.Doc, Utils.CloudStorage_Input_Folder, Utils.Local_Output_Path + "pdf-doc-out.doc"); pdfService.ConvertToSomeFormat("pdf-sample.pdf", PDFDocumentConvertFormat.Doc, Utils.CloudStorage_Input_Folder, Utils.CloudStorage_Output_Folder + "/pdf-doc-out.doc"); #region Sign document storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-signed.pdf"); PDFSignature signature = new PDFSignature(); signature.SignaturePath = Utils.CloudStorage_Input_Folder + "/signature.pfx"; signature.SignatureType = "PKCS7"; signature.Password = "******"; signature.Appearance = Utils.CloudStorage_Input_Folder + "/signature.jpg"; signature.Reason = "Success"; signature.Contact = "*****@*****.**"; signature.Location = "Australia"; signature.Visible = true; signature.FormFieldName = "Signature1"; signature.Authority = "Aspose Marketplace"; signature.Rectangle = new Rectangle(100, 100, 200, 200); signature.Date = DateTime.Now.ToString(); pdfService.SignDocument("pdf-signed.pdf", Utils.CloudStorage_Output_Folder, signature); storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/pdf-signed.pdf", Utils.Local_Output_Path + "/pdf-signed.pdf"); #endregion Sign document } catch (Exception ex) { Assert.Fail(ex.Message); } }
/// <summary> /// Sign document. /// </summary> /// <param name="name">The document name.</param> /// <param name="storage">The document storage.</param> /// <param name="folder">The document folder.</param> public void SignDocument(string name, string folder, PDFSignature singature, string storage = "") { // POST pdf/{name}/sign?appSid={appSid}&storage={storage}&folder={folder} string apiUrl = string.Format(@"pdf/{0}/sign?storage={1}&folder={2}", name, storage, folder); ServiceController.Post(apiUrl, AppSid, AppKey, JsonConvert.SerializeObject(singature)); }
public void Pdf_Pages_Tests() { try { storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-pages.pdf"); PagesResponse pagesResponse = pdfService.Pages.ReadDocumentPagesInfo("pdf-pages.pdf", Utils.CloudStorage_Output_Folder); System.Threading.Thread.Sleep(3000); // Just for testing PagesResponse pagesResponse2 = pdfService.Pages.AddNewPageToEndOfTheDocument("pdf-pages.pdf", Utils.CloudStorage_Output_Folder); PageResponse pageResponse = pdfService.Pages.ReadDocumentPageInfo("pdf-pages.pdf", 1, Utils.CloudStorage_Output_Folder); System.Threading.Thread.Sleep(3000); // Just for testing pdfService.Pages.ConvertToSomeFormat("pdf-pages.pdf", 1, PDFPageConvertFormat.Png, Utils.Local_Output_Path + "\\pdf-page-out.png", Utils.CloudStorage_Output_Folder); WordsPerPageResponse wordsPerPageResponse = pdfService.Pages.GetNumberOfWordsPerDocumentPage("pdf-sample.pdf", Utils.CloudStorage_Input_Folder); System.Threading.Thread.Sleep(3000); // Just for testing pdfService.Pages.DeleteDocumentPageByItsNumber("pdf-pages.pdf", 1, Utils.CloudStorage_Output_Folder); pdfService.Pages.MovePageToNewPosition("pdf-pages.pdf", 1, 3, Utils.CloudStorage_Output_Folder); System.Threading.Thread.Sleep(3000); // Just for testing //--------------------------------------------------------------------- storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-pages.pdf"); PDFSignature signature = new PDFSignature(); signature.SignaturePath = Utils.CloudStorage_Input_Folder + "/signature.pfx"; signature.SignatureType = "PKCS7"; signature.Password = "******"; signature.Appearance = Utils.CloudStorage_Input_Folder + "/signature.jpg"; signature.Reason = "Success"; signature.Contact = "*****@*****.**"; signature.Location = "Australia"; signature.Visible = true; signature.FormFieldName = "Signature1"; signature.Authority = "Aspose Marketplace"; signature.Rectangle = new Rectangle(100, 100, 200, 200); signature.Date = DateTime.Now.ToString(); pdfService.Pages.SignPage("pdf-pages.pdf", 1, Utils.CloudStorage_Output_Folder, signature); //--------------------------------------------------------------------- System.Threading.Thread.Sleep(3000); // Just for testing storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-pages.pdf"); PageStamp stamp = new PageStamp(); stamp.Type = 0; stamp.Background = true; stamp.BottomMargin = 2.1; stamp.HorizontalAlignment = 0; stamp.LeftMargin = 3.1; stamp.Opacity = 4.1; stamp.RightMargin = 5.1; stamp.Rotate = 0; stamp.RotateAngle = 6.1; stamp.TopMargin = 7.1; stamp.VerticalAlignment = 0; stamp.XIndent = 8.1; stamp.YIndent = 9.1; stamp.Zoom = 10.1; stamp.TextAlignment = 0; stamp.Value = "sample string 11"; Color backGroundColor = new Color(64, 64, 64, 64); TextState textState = new TextState(); textState.BackgroundColor = backGroundColor; textState.ForegroundColor = backGroundColor; textState.FontSize = 12; textState.Font = "Tahoma"; textState.FontStyle = 1; stamp.TextState = textState; stamp.FileName = Utils.CloudStorage_Input_Folder + "/signature.jpg"; stamp.Width = 13.1; stamp.Height = 14.1; stamp.PageIndex = 1; stamp.StartingNumber = 1; System.Threading.Thread.Sleep(3000); // Just for testing pdfService.Pages.AddPageStamp("pdf-pages.pdf", 1, Utils.CloudStorage_Output_Folder, stamp); System.Threading.Thread.Sleep(3000); // Just for testing storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/pdf-pages.pdf", Utils.Local_Output_Path + "/pdf-pages.pdf"); } catch (Exception ex) { Assert.Fail(ex.Message); } }