Сначала я попытался прочитать текст на английском языке sh из файла pdf. Я могу успешно прочитать текст на английском языке sh из pdf, используя Java.
//Loading an existing document
File file = new File("C:/PdfBox_Examples/english.pdf");
PDDocument document = PDDocument.load(file);
//Instantiate PDFTextStripper class
PDFTextStripper pdfStripper = new PDFTextStripper();
//Retrieving text from PDF document
String text = pdfStripper.getText(document);
System.out.println(text);
Но я не могу прочитать текст малаялам из документа pdf на малаялам, используя Java.
//Loading an existing document
File file = new File("C:/PdfBox_Examples/malayalam.pdf");
PDDocument document = PDDocument.load(file);
//Instantiate PDFTextStripper class
PDFTextStripper pdfStripper = new PDFTextStripper();
//Retrieving text from PDF document
String text = pdfStripper.getText(document);
System.out.println(text);
![enter image description here](https://i.stack.imgur.com/S89ZZ.jpg)
EDIT
Я пробовал с iText 7
try (PdfDocument doc = new PdfDocument(new PdfReader("C:/PdfBox_Examples/malayalam.pdf"))) {
try (OutputStream os = new FileOutputStream("C:/PdfBox_Examples/output.txt")) {
String result = PdfTextExtractor.getTextFromPage(doc.getPage(1));
os.write(result.getBytes(Charset.forName("UTF-8")));
}
}
вывод ![enter image description here](https://i.stack.imgur.com/JwiiM.jpg)