Created
January 31, 2024 07:38
-
-
Save Annushka34/b6642405ae42ae69394c31de5f1cde9b to your computer and use it in GitHub Desktop.
pdf-to-text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aspose.OCR.Metered metered = new Aspose.OCR.Metered(); | |
metered.SetMeteredKey("PublicKey", "PrivateKey"); | |
// This code recognize image | |
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr(); | |
// Add images to OcrInput object | |
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.PDF); | |
input.Add("source1.pdf", 0, 3); // set start page and pages number | |
input.Add("source2.pdf"); // all pages for recognition | |
// Set recognition language | |
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings(); | |
recognitionSettings.Language = Aspose.OCR.Language.Latin; | |
// Recognize image | |
List<Aspose.OCR.RecognitionResult> results = recognitionEngine.Recognize(input, recognitionSettings); | |
foreach(Aspose.OCR.RecognitionResult result in results) | |
{ | |
Console.WriteLine(result.RecognitionText); | |
} | |
//save as a file | |
results[0].Save("result.txt", Aspose.OCR.SaveFormat.Text); | |
//or | |
Aspose.OCR.AsposeOcr.SaveMultipageDocument("result.pdf", Aspose.OCR.SaveFormat.Pdf, results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment