0
アラビア語でPDFBoxを使用してレポートを作成したい私はstackoverflowで別のソリューションを見たことがありますが、まだ問題に解決策を得ることはできません。 アラビア語の言葉が逆順で登場しました。もし私がここで助けてくれれば私のコードです。アラビア語をPDFBoxに表示する方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String relativeWebPath = "/font/arial.ttf";
String absoluteDiskPath = getServletContext().getRealPath(relativeWebPath);
File file = new File(absoluteDiskPath);
System.out.print(file);
ByteArrayOutputStream output=new ByteArrayOutputStream();
PDDocument document=new PDDocument();
PDFont font = PDType0Font.load(document, new File(absoluteDiskPath));
PDPage test=new PDPage();
document.addPage(test);
PDPageContentStream content=new PDPageContentStream(document, test);
final String EXAMPLE = "النص العربي";
System.out.print(EXAMPLE);
content.beginText();
content.newLineAtOffset(50, 680);
content.setFont(font, 12);
content.showText(EXAMPLE);
System.out.print(EXAMPLE);
content.endText();
content.close();
PDFTextStripper textStripper = new PDFTextStripper();
String Text = textStripper.getText(document);
System.out.print(Text);
document.save(output);
document.close();
response.setContentType("application/pdf;base64,BASE_64_ENCODED_PDF");
response.addHeader("Content-Disposition", "inline; filename=\"TestReport.pdf\"");
response.getCharacterEncoding();
response.getOutputStream().write(output.toByteArray());
}
icu4j-49_1.jarとicu4j-charset-49_1.jarを追加しました。これは、単一の単語ではなく、بのような単一の分離された文字として表示されます。 –
いいえ2.0ではicu4jを使用していません。 https://issues.apache.org/jira/browse/PDFBOX-2118 –