我有一个希伯来文档(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();
}
这完成了我们的代码