RTL希伯来语文档使用Apache POI转换PDF

时间:2018-12-14 10:36:55

标签: java apache-poi right-to-left

我有一个希伯来文档(RTL),我想从docx转换为pdf,但是我却得到了相反的pdf。

try {

    XWPFDocument document = new XWPFDocument(new FileInputStream("D:\\abc.docx") );    

    // 2) Convert POI XWPFDocument 2 PDF with iText

    File outFile = new File( "D:\\abcded123.pdf" );
    outFile.getParentFile().mkdirs();

    OutputStream out = new FileOutputStream( outFile );

    PdfOptions options1=PdfOptions.create();
    options1.fontEncoding("windows-1255");

    System.out.println(options1.getFontEncoding());
    options1.setConfiguration(new IPdfWriterConfiguration() {

        @Override
        public void configure(com.lowagie.text.pdf.PdfWriter writer) {
            writer.createXmpMetadata();
            writer.setRunDirection(com.lowagie.text.pdf.PdfWriter.RUN_DIRECTION_RTL);                                                                       
        }
    });

    //options1.fontEncoding( "windows-1255");

    PdfConverter.getInstance().convert( document, out, options1 );
}
catch ( Throwable e ) {
    e.printStackTrace();
}

这完成了我们的代码

0 个答案:

没有答案