Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 23, 2021 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/116dd2536967d784fb63cebcc96f2ec3 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/116dd2536967d784fb63cebcc96f2ec3 to your computer and use it in GitHub Desktop.
Convert JPG PNG TIFF Image to Searchable PDF with OCR using C#
// Set path for input image to recognize
string image = "p24.jpg";
// Initialize AsposeOcr class instance
AsposeOcr api = new AsposeOcr();
// Recognize input image with RecognizeImage method
RecognitionResult result = api.RecognizeImage(image, new RecognitionSettings());
// Save output to searchable PDF file
result.Save("test.pdf", SaveFormat.Pdf);
// Set path for input image to recognize
string image = "p24.jpg";
// Initialize AsposeOcr class object
AsposeOcr api = new AsposeOcr();
// Initialize RecognitionSettings class instance
RecognitionSettings settings = new RecognitionSettings();
// Calculate skew angle of the image
float angle = api.CalculateSkew(image);
settings.SkewAngle = angle;
// Recognize input image with RecognizeImage method
RecognitionResult result = api.RecognizeImage(image, settings);
// Save image to searchable PDF file with OCR
result.Save("Test.pdf", SaveFormat.Pdf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment