iReport - 如何将报告方向更改为RTL? [英] iReport - How to change report direction to RTL?
本文介绍了iReport - 如何将报告方向更改为RTL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在iReport中将页面方向更改为RTL,因为正在处理应以英语和英语显示的报告。阿拉伯语,我使用本地文本以两种语言出现,但我找不到任何改变方向
How can I change the page direction to RTL in iReport, as am working on a report that should be displayed in english & arabic, I am using local for the text to appear in both languages but I can't find anything to change the direction
我知道这个问题之前被问过,但我没有找不到任何答案:如何制作一个报告页面方向更改为rtl?
I know this question was asked before but I didn't find any answer: How to make a report page direction to change to "rtl"?
推荐答案
据我搜索,没有属性,你可以使用下面的util类:
As far as I searched there is no property, you can use below 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());
}
}
}
}
这篇关于iReport - 如何将报告方向更改为RTL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文