在JasperReports中以任何角度旋转文本 [英] Rotate text at any degree in JasperReports

查看:165
本文介绍了在JasperReports中以任何角度旋转文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 iReport 生成 pdf 。我需要在任何程度上旋转文本。正如我在文档中看到的那样, iReport 可以在90度,180度,270度和360度旋转文本。我也希望它在动态值上。

为此,我尝试这些程序,但没有得到预期的结果。

I am using iReport to generate pdf. I need to rotate text at any degree. As I read in documentation, iReport can rotate text at 90, 180, 270 and 360 degree. Also I want it on dynamic value.
For This I try these procedure but not get expected result.

使用自定义jar旋转图像

当我尝试保存图像并查看其预览时,它的 Java 方法正常工作。但是当我制作一个jar文件并将其包含在 iReport 中时,我无法获得任何结果。

Its a Java method working fine when I try save an image and see its preview. But When I make a jar file and include this in iReport, I could not get any result.

我尝试使用css样式两种类型。

I try to use css styling two types.

首先,我将文本字段标记为html。使用内联css旋转文本。但它不再适用了。示例就在这里。

First I make a text field an markup it as html. Use inline css to rotate text. But its not working anymore.example is here.

<title>
    <band height="313" splitType="Stretch">
        <image>
            <reportElement uuid="c4edca6a-50d8-481f-bea0-9513268d4a88" x="13" y="13" width="150"    height="41"/>
            <imageExpression><![CDATA[$P{REPORT_SCRIPTLET}.rotateText( $V{SpecialDescription},new    java.awt.Font("Sans Serif",1,100), 100, 100, 45, java.awt.Color.white)]]></imageExpression>
        </image>
        <textField isStretchWithOverflow="true">
            <reportElement uuid="22594755-7eba-4313-a1fd-41ac20dc50b5" x="141" y="101" width="234" height="53"/><textElement markup="html"/>
            <textFieldExpression><![CDATA["<html><div  style=\"-moz- transform:rotate(20deg)translateX(230px)scale(1.5); -o-transform: rotate(20deg)  translateX(230px) scale(1.5);-webkit-transform:  rotate(20deg)translateX(230px)scale(1.5);transform: rotate(50deg) translateX(230px)  scale(1.5);\">Hello</div><html>"]]></textFieldExpression>
        </textField>
    </band>
</title>

此外,我尝试使用html组件添加css。为此,我添加 htmlComponent.jar 并编写生成它的代码,但它也无效。

Also I try to add css using html component. For this I add htmlComponent.jar and write code for generate it, but it is also not working.

一个更多的事情,当我尝试添加颜色背景颜色,它给我预期的颜色,但它没有旋转文字。

One more thing, when I try add color an background color it give me expected color, but it did not rotate text.

有没有其他方法可以旋转文字?

Is there any another way to rotate text?

推荐答案

你可以使用itext将文本旋转到任何程度。您可以使用iText阅读使用jasper报告创建的PDF。要么将pdf读取为byteArray,如果它尚未写入pdf文件,则使用itext PdfReader读取内容

You can rotate the text to any degree using itext. You can use iText to read the pdf you created using jasper reports. Either read the pdf as byteArray if it is not already written to a pdf file, then use itext PdfReader to read the contents

我希望以下链接可以帮助您水印,但也可用于将内容旋转到一定程度。

I hope the following link helps you which is for watermark but can be utilized for rotating the content to a degree as well.

https://stackoverflow.com/a/45534733/4664978

这篇关于在JasperReports中以任何角度旋转文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆