/// <summary> /// Add page stamp. /// </summary> /// <param name="name">The document name.</param> /// <param name="pageNumber">The page number.</param> /// <param name="stamp">Stamp object with data.</param> /// <param name="folder">The document folder.</param> /// <param name="storage">The document storage.</param> public void AddPageStamp(string name, int pageNumber, string folder, PageStamp stamp, string storage = "") { // PUT pdf/{name}/pages/{pageNumber}/stamp?appSid={appSid}&storage={storage}&folder={folder} string apiUrl = string.Format(@"pdf/{0}/pages/{1}/stamp?storage={2}&folder={3}", name, pageNumber, storage, folder); ServiceController.Put(apiUrl, AppSid, AppKey, JsonConvert.SerializeObject(stamp)); }
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); } }