Я использую Java iText для создания отчета на основе данных josn, у меня возникла проблема с орфографией на хинди. Я использую шрифт Google NotoSansDevanagari-Regular.ttf
Код: Выделить всё
//This is the function
private void addTextToPdf(PdfDocument pdfDocument, String text, float x, float y, int pageNumber, int fontSize, PdfFont font) throws IOException {
PdfPage page = pdfDocument.getPage(pageNumber);
PdfCanvas canvas = new PdfCanvas(page);
// Convert text to lowercase for case-insensitive comparison
String lowerText = text.toLowerCase();
// Determine the color based on the text value
DeviceRgb rectangleColor = null;
String marathiText = text; // Default to the original text
// Draw the rectangle with the determined color
if (rectangleColor != null) {
drawRectangle(pdfDocument, x-2f, y - 2.8f, 85.5f, 12f, rectangleColor);
}
// Add the Marathi text to the PDF
canvas.beginText()
.setFontAndSize(font, fontSize)
.setColor(ColorConstants.BLACK, true)
.moveText(x, y)
.showText(marathiText)
.endText();
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... java-itext
Мобильная версия