如何在iReport中将页面方向更改为RTL,因为正在处理应以英语和英语显示的报告。阿拉伯语,我使用本地文本出现在两种语言,但我找不到任何改变方向
我知道之前曾问过这个问题,但我没有找到任何答案:How to make a report page direction to change to "rtl"?
答案 0 :(得分:0)
据我搜索没有属性,你可以使用下面的util class:
package foo.bar.utils.export;
import java.util.Iterator;
import java.util.List;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintFrame;
import net.sf.jasperreports.engine.JRPrintPage;
import net.sf.jasperreports.engine.JasperPrint;
/**
* Report utilities
* Please refer to: http://community.jaspersoft.com/questions/523041/right-left-arabic-reports
* There is another solution at: http://jaspermirror.sourceforge.net/
* which is not used here
* @author AFattahi
*
*/
public class ReportUtils {
private ReportUtils(){
}
/**
* mirror each page layout
* @param print
*/
public static void mirrorLayout(JasperPrint print) {
int pageWidth = print.getPageWidth();
for (Object element : print.getPages()) {
JRPrintPage page = (JRPrintPage) element;
mirrorLayout(page.getElements(), pageWidth);
}
}
/**
* mirror a list of elements
* @param print
*/
protected static void mirrorLayout(List<?> elements, int totalWidth) {
for (Iterator<?> it = elements.iterator(); it.hasNext();) {
JRPrintElement element = (JRPrintElement) it.next();
int mirrorX = totalWidth - element.getX() - element.getWidth();
element.setX(mirrorX);
if (element instanceof JRPrintFrame) {
JRPrintFrame frame = (JRPrintFrame) element;
mirrorLayout(frame.getElements(), frame.getWidth());
}
}
}
}