Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-cloud-kb/dfded4473660d220829162064f9ef8c7 to your computer and use it in GitHub Desktop.
Save aspose-cloud-kb/dfded4473660d220829162064f9ef8c7 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using Aspose.Pdf.Cloud.Sdk.Api;
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Aspose.PDF.Cloud.Examples.Kb
{
public class PdfTasks
{
public static void CountWords()
{
PdfApi pdfApi = new PdfApi("Client Secret", "Client ID");
String fileName = "sample.pdf";
String storage = "";
String folder = "";
try
{
// Upload source file to aspose cloud storage for counting words
pdfApi.UploadFile(fileName, new MemoryStream(System.IO.File.ReadAllBytes(fileName)));
// Invoke Aspose.PDF Cloud SDK API to get words count per page from pdf document
WordCountResponse apiResponse = pdfApi.GetWordsPerPage(fileName, storage, folder);
if (apiResponse != null && apiResponse.Status.Equals("OK"))
{
foreach (PageWordCount PageWordCount in apiResponse.WordsPerPage.List)
{
Console.WriteLine("Page Number :: " + PageWordCount.PageNumber + " Total Words :: " + PageWordCount.Count);
}
Console.ReadKey();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment