public void ReadmeExample_ListPages() { int page = 1; int pageSize = 10; var parameterDict = new Dictionary <string, string>() { { "page", page.ToString() }, { "page_size", pageSize.ToString() } }; PagesResponse <RecipePage> recipePages = butterClient.ListPages <RecipePage>("recipe", parameterDict); var viewModel = new RecipesViewModel(); viewModel.PreviousPageNumber = recipePages.Meta.PreviousPage; viewModel.NextPageNumber = recipePages.Meta.NextPage; viewModel.PagesCount = recipePages.Meta.Count; viewModel.Recipes = new List <RecipeViewModel>(); foreach (Page <RecipePage> recipe in recipePages.Data) { RecipeViewModel recipeViewModel = new RecipeViewModel(); recipeViewModel.Category = recipe.Fields.category; recipeViewModel.RecipeName = recipe.Fields.recipe_name; recipeViewModel.MainIngredient = recipe.Fields.main_ingredient; recipeViewModel.EstimatedCookingTimeInMinutes = recipe.Fields.estimated_cooking_time_in_minutes; recipeViewModel.IngredientList = recipe.Fields.ingredient_list; recipeViewModel.Instructions = recipe.Fields.instructions; viewModel.Recipes.Add(recipeViewModel); } Assert.IsNotNull(viewModel); }
public ActionResult Index(int page = 1, int pageSize = 10) { var butterClient = new ButterCMSClient("YOUR KEY"); var parameterDict = new Dictionary <string, string>() { { "page", page.ToString() }, { "page_size", pageSize.ToString() }, }; PagesResponse <Page> caseStudyPages = butterClient.ListPages <Page>("sample-page", parameterDict); var viewModel = new PagesViewModel(); viewModel.CaseStudies = new List <PageViewModel>(); PageResponse <Page> myPage = butterClient.RetrievePage <Page>("*", "sample-page", parameterDict); PageViewModel caseStudyViewModel = new PageViewModel(); caseStudyViewModel.Readme = myPage.Data.Fields.readme; caseStudyViewModel.Seo = myPage.Data.Fields.seo; caseStudyViewModel.twitterCard = myPage.Data.Fields.twitter_card; caseStudyViewModel.openGraph = myPage.Data.Fields.open_graph; caseStudyViewModel.Slug = myPage.Data.Slug; viewModel.CaseStudies.Add(caseStudyViewModel); return(View(viewModel)); }
private async Task <Page> SelectPageAsync(Section section) { Log.Debug("fetching pages..."); PagesResponse pages = await _client.GetSectionPagesAsync(section.Id); Log.Debug("select page:"); List <Page> pageList = pages.Pages.OrderBy(p => p.CreatedTime).ToList(); int i = 0; foreach (Page page in pageList) { Log.Debug("{i}. {title}", ++i, page.Title); } int idx = AskNumber(); Page result = pageList[idx - 1]; Log.Debug("selected {title}", result.Title); return(result); }
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); } }