- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试将我的文本环绕在图像周围。
我需要创建的结构如下图所示:
这是我试过的
我试过使用表,但没有成功。我很难将文本字段用作 html 并将图像传递给它并将对齐方式设置为左侧,但我发现无法在文本字段中传递图像。我开始使用 jaspersoft Studio pro 及其 html 元素 来解决问题。但是我不知道如何将数据库中的图像字段作为 html 源传递。 html元素中的表达式为:
"<img src= '$F{Image}' align='left'/> <p>"+$F{KN_Zusatzinfo_DV_Einleitungstext} +"</p>"
此代码不显示图像,而是显示一个框而不是图像。并且打印的文本没有被拉伸(stretch)。我使用的页面样式是两栏。 HTML 输出如图所示
使用像下面这样的静态路径到图像是可行的,但这对我来说不是一个选项,因为我需要从数据库中读取图像:
"<style>.left { float: left; margin-left: 1em; width :40%;}</style><p><img class = left src= C:/Users/iman/JaspersoftWorkspace/Qreport/sample1.png />
如果我只是使用一个带有文本框的图像元素,输出和设计 View 如下图所示:
html 方法的HTML 源是:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
a {
text-decoration: none
}
</style>
</head>
<body text="#000000" link="#000000" alink="#000000" vlink="#000000">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="50%"> </td>
<td align="center">
<a name="JR_PAGE_ANCHOR_0_1"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:10px"></td>
<td style="width:20px"></td>
<td style="width:40px"></td>
<td style="width:210px"></td>
<td style="width:32px"></td>
<td style="width:58px"></td>
<td style="width:10px"></td>
<td style="width:182px"></td>
<td style="width:9px"></td>
<td style="width:24px"></td>
</tr>
<tr valign="top" style="height:25px">
<td colspan="10">
</td>
</tr>
<tr valign="top" style="height:5px">
<td colspan="6">
</td>
<td colspan="3" rowspan="2" style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #6B66FA; font-size: 10px; line-height: 1.2578125;">HCH-A - Aortenklappenchirurgie, isoliert (Konventionell chirurgisch)</span>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:20px">
<td>
</td>
<td colspan="2" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #BABABA; font-size: 10px; line-height: 1.2578125;">Ergebnisse</span>
</td>
<td colspan="3">
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:20px">
<td colspan="7">
</td>
<td colspan="2" style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #000000; font-size: 10px; line-height: 1.2578125;">Dr XYZ</span>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:88px">
<td colspan="10">
</td>
</tr>
<tr valign="top" style="height:74px">
<td colspan="5">
</td>
<td colspan="3" rowspan="2">
<div style='width:250px;height:90px;background-color: #FFFFFF; overflow:hidden;'>
<img src='((java.awt.Image)field_Image.getValue())' align='left' />
<p>Bei der Aortenklappe handelt es sich um das „Ventil“ zwischen der linken HerzkeAortenklappenchirurgie, isoliert - konventionell - Aortenklappenchirurgie, isoliert - kathetergestützt Die Qualitätsindikatoren der k........
appenchirauch die Indikationsstellung betrachtet. Sofern nicht anders angegeben, ist die Beschreibung der Qualitätsindikatoren eine Fortschreibung der QIDB 2014 des AQUA-Institutes.</p>
</div>
</td>
<td colspan="2">
</td>
</tr>
<tr valign="top" style="height:16px">
<td colspan="2">
</td>
<td colspan="2" rowspan="2">
<div style='width:250px;height:90px;background-color: #FFFFFF; overflow:hidden;'>
<img src='((java.awt.Image)field_Image.getValue())' align='left' />
<p>Bei der Aortenklappe handelt es sich um das „Ventil“ zwischen der linken Herzkammer und der Hauptschlagader (Aorta). Schließt die Klappe nicht mehr dicht, spriitätsindikatoren der konventionellen Aortenklappenchirurgie fokussieren schwere Komplikationen und Sterblichkeit.
Bei der kathetergestützten Aortenklappenchirurgie wird darüber hinaus auch die Indikationsstellung betrachtet. Sofern nicht anders angegeben, ist die Beschreibung der Qualitätsindikatoren eine Fortschreibung der QIDB 2014 des AQUA-Institutes.</p>
</div>
</td>
<td>
</td>
<td colspan="2">
</td>
</tr>
<tr valign="top" style="height:74px">
<td colspan="2">
</td>
<td colspan="6">
</td>
</tr>
<tr valign="top" style="height:520px">
<td colspan="10">
</td>
</tr>
</table>
<br/>
<br/>
<a name="JR_PAGE_ANCHOR_0_2"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:10px"></td>
...
<td style="width:24px"></td>
</tr>
<tr valign="top" style="height:27px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:20px">
<td>
</td>
<td colspan="2" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #BABABA; font-size: 10px; line-height: 1.2578125;">Ergebnisse</span>
</td>
<td colspan="4">
</td>
</tr>
<tr valign="top" style="height:7px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:21px">
<td colspan="5">
</td>
<td style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #6B66FA; font-size: 10px; line-height: 1.2578125;">HCH-A - Aortenklappenchirurgie, isoliert </span>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:125px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:90px">
<td colspan="2">
</td>
<td colspan="2">
<div style='width:250px;height:90px;background-color: #FFFFFF; overflow:hidden;'>
<img src='((java.awt.Image)field_Image.getValue())' align='left' />
<p>....deleted some text because it exceeded the limit..</p>
</div>
</td>
<td colspan="3">
</td>
</tr>
<tr valign="top" style="height:552px">
<td colspan="7">
</td>
</tr>
</table>
<br/>
<br/>
<a name="JR_PAGE_ANCHOR_0_3"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:595px"></td>
</tr>
<tr valign="top" style="height:842px">
<td>
</td>
</tr>
</table>
<![if IE]>
<script>
var links = document.querySelectorAll('link.jrWebFont');
setTimeout(function() {
if (links) {
for (var i = 0; i < links.length; i++) {
links.item(i).href = links.item(i).href;
}
}
}, 0);
</script>
<![endif]>
</td>
<td width="50%"> </td>
</tr>
</table>
</body>
</html>
图像元素加文本字段的 HTML 源代码是:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
a {
text-decoration: none
}
</style>
</head>
<body text="#000000" link="#000000" alink="#000000" vlink="#000000">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="50%"> </td>
<td align="center">
<a name="JR_PAGE_ANCHOR_0_1"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:10px"></td>
<td style="width:60px"></td>
<td style="width:232px"></td>
<td style="width:33px"></td>
<td style="width:35px"></td>
<td style="width:10px"></td>
<td style="width:5px"></td>
<td style="width:186px"></td>
<td style="width:1px"></td>
<td style="width:23px"></td>
</tr>
<tr valign="top" style="height:25px">
<td colspan="10">
</td>
</tr>
<tr valign="top" style="height:5px">
<td colspan="5">
</td>
<td colspan="3" rowspan="2" style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #6B66FA; font-size: 10px; line-height: 1.2578125;">HCH-A - Aortenklappenchirurgie, isoliert (Konventionell chirurgisch)</span>
</td>
<td colspan="2">
</td>
</tr>
<tr valign="top" style="height:20px">
<td>
</td>
<td style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #BABABA; font-size: 10px; line-height: 1.2578125;">Ergebnisse</span>
</td>
<td colspan="3">
</td>
<td colspan="2">
</td>
</tr>
<tr valign="top" style="height:20px">
<td colspan="6">
</td>
<td colspan="2" style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #000000; font-size: 10px; line-height: 1.2578125;">Dr XYZ</span>
</td>
<td colspan="2">
</td>
</tr>
<tr valign="top" style="height:94px">
<td colspan="10">
</td>
</tr>
<tr valign="top" style="height:50px">
<td colspan="4">
</td>
<td colspan="3">
<img src="report7921484792758494686.html_files/img_0_0_3" style="width: 50px" alt="" />
</td>
<td colspan="3">
</td>
</tr>
<tr valign="top" style="height:24px">
<td colspan="10">
</td>
</tr>
<tr valign="top" style="height:477px">
<td colspan="3">
</td>
<td colspan="6" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #000000; font-size: 10px; line-height: 1.2578125;">Bei der Aortenklappe handelt es sinken Herzkammer und der Hauptschlagader (Aorta). Einsatz einer künstlichen Herzklappe behandelt.<br/><br/>Bei beiden kathetergestützten Methoden wird über ein spezielles Ballonkathetersystem zunächst der Bereich der </span>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:127px">
<td colspan="10">
</td>
</tr>
</table>
<br/>
<br/>
<a name="JR_PAGE_ANCHOR_0_2"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:10px"></td>
...
<td style="width:24px"></td>
</tr>
<tr valign="top" style="height:27px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:20px">
<td>
</td>
<td colspan="2" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #BABABA; font-size: 10px; line-height: 1.2578125;">Ergebnisse</span>
</td>
<td colspan="4">
</td>
</tr>
<tr valign="top" style="height:7px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:21px">
<td colspan="5">
</td>
<td style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #6B66FA; font-size: 10px; line-height: 1.2578125;">HCH-A - Aortenklappenchirurgie, isoliert </span>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:139px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:264px">
<td colspan="2">
</td>
<td colspan="2" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #000000; font-size: 10px; line-height: 1.2578125;">alten, verengten Aortenklappe erweitert. - des AQUA-Institutes.</span>
</td>
<td colspan="3">
</td>
</tr>
<tr valign="top" style="height:364px">
<td colspan="7">
</td>
</tr>
</table>
<br/>
<br/>
<a name="JR_PAGE_ANCHOR_0_3"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:10px"></td>
<td style="width:10px"></td>
...
<td style="width:1px"></td>
<td style="width:23px"></td>
</tr>
<tr valign="top" style="height:27px">
<td colspan="11">
</td>
</tr>
<tr valign="top" style="height:20px">
<td>
</td>
<td colspan="3" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #BABABA; font-size: 10px; line-height: 1.2578125;">Ergebnisse</span>
</td>
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:7px">
<td colspan="11">
</td>
</tr>
<tr valign="top" style="height:21px">
<td colspan="8">
</td>
<td style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #6B66FA; font-size: 10px; line-height: 1.2578125;">HCH-A - Aortenklappenchirurgie, isoliert </span>
</td>
<td colspan="2">
</td>
</tr>
<tr valign="top" style="height:65px">
<td colspan="11">
</td>
</tr>
<tr valign="top" style="height:66px">
<td colspan="7">
</td>
<td colspan="3" rowspan="4" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #000000; font-size: 10px; line-height: 1.2578125;"><br/>Bei beiden kathetergestützten Me die Indikationsstellung betrachtet.<br/><br/>Sofern nicht anders angegeben, ist die Beschreibung der Qualitätsindikatoren eine Fortschreibung der QIDB 2014 des AQUA-Institutes.</span>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:50px">
<td colspan="3">
</td>
<td colspan="2">
<img src="report7921484792758494686.html_files/img_0_2_2" style="width: 50px" alt="" />
</td>
<td colspan="2">
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:24px">
<td colspan="7">
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:161px">
<td colspan="2">
</td>
<td colspan="4" rowspan="2" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #000000; font-size: 10px; line-height: 1.2578125;">Bei der Aortenklapprzspitze über einen 3 bis 5 cm langen Hautschnitt im Rippenbereich (linker Brustkorb, im 4. oder 5. Rippenzwischenraum) freigelegt. <br/>- Beim endovaskulären Aortenklappenersatz ist lediglich ein gezielter Einstich (Punktion), zumeist in die Leistenarterie, notwendig. <br/></span>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:279px">
<td colspan="2">
</td>
<td colspan="5">
</td>
</tr>
<tr valign="top" style="height:122px">
<td colspan="11">
</td>
</tr>
</table>
<br/>
<br/>
<a name="JR_PAGE_ANCHOR_0_4"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:10px"></td>
<td style="width:60px"></td>
...
<td style="width:1px"></td>
<td style="width:23px"></td>
</tr>
<tr valign="top" style="height:27px">
<td colspan="9">
</td>
</tr>
<tr valign="top" style="height:20px">
<td>
</td>
<td style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #BABABA; font-size: 10px; line-height: 1.2578125;">Ergebnisse</span>
</td>
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:7px">
<td colspan="9">
</td>
</tr>
<tr valign="top" style="height:21px">
<td colspan="5">
</td>
<td colspan="2" style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #6B66FA; font-size: 10px; line-height: 1.2578125;">HCH-A - Aortenklappenchirurgie, isoliert </span>
</td>
<td colspan="2">
</td>
</tr>
<tr valign="top" style="height:91px">
<td colspan="9">
</td>
</tr>
<tr valign="top" style="height:50px">
<td colspan="4">
</td>
<td colspan="2">
<img src="report7921484792758494686.html_files/img_0_3_2" style="width: 50px" alt="" />
</td>
<td colspan="3">
</td>
</tr>
<tr valign="top" style="height:24px">
<td colspan="9">
</td>
</tr>
<tr valign="top" style="height:477px">
<td colspan="3">
</td>
<td colspan="5" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif;r Brustkorb, im 4. oder 5. Rippenzwischenraum) freigelegt. <br/>- Beim endovaskulären Aortenklappenersatz ist lediglich ein gezielter Einstich (Punktion), zumeist in die Leistenarterie, notwendig. <br/><br/>Bei beiden kathetergestützten Methoden wird über ein spezielles Ballonkathetersystem zunächst der Bereich der </span>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:125px">
<td colspan="9">
</td>
</tr>
</table>
<br/>
<br/>
<a name="JR_PAGE_ANCHOR_0_5"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:10px"></td>
<td style="width:10px"></td>
<td style="width:50px"></td>
<td style="width:220px"></td>
<td style="width:80px"></td>
<td style="width:201px"></td>
<td style="width:24px"></td>
</tr>
<tr valign="top" style="height:27px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:20px">
<td>
</td>
<td colspan="2" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #BABABA; font-size: 10px; line-height: 1.2578125;">Ergebnisse</span>
</td>
<td colspan="4">
</td>
</tr>
<tr valign="top" style="height:7px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:21px">
<td colspan="5">
</td>
<td style="text-indent: 0px; text-align: right;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #6B66FA; font-size: 10px; line-height: 1.2578125;">HCH-A - Aortenklappenchirurgie, isoliert </span>
</td>
<td>
</td>
</tr>
<tr valign="top" style="height:139px">
<td colspan="7">
</td>
</tr>
<tr valign="top" style="height:264px">
<td colspan="2">
</td>
<td colspan="2" style="text-indent: 0px; text-align: left;">
<span style="font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif; color: #000000; font-size: 10px; line-height: 1.2578125;">alten, verengten Aortenklappe erweitert. Anschließend wird eine zusammengefaltete Herzklappenchirurgie fokussieren schwere Komplikationen und Sterblichkeit. Bei der kathetergestützten Aortenklappenchirurgie wird darüber hinaus auch die Indikationsstellung betrachtet.<br/><br/>Sofern nicht anders angegeben, ist die Beschreibung der Qualitätsindikatoren des AQUA-Institutes.</span>
</td>
<td colspan="3">
</td>
</tr>
<tr valign="top" style="height:364px">
<td colspan="7">
</td>
</tr>
</table>
<br/>
<br/>
<a name="JR_PAGE_ANCHOR_0_6"></a>
<table class="jrPage" cellpadding="0" cellspacing="0" border="0" style="empty-cells: show; width: 595px; border-collapse: collapse; background-color: white;">
<tr valign="top" style="height:0">
<td style="width:595px"></td>
</tr>
<tr valign="top" style="height:842px">
<td>
</td>
</tr>
</table>
<![if IE]>
<script>
var links = document.querySelectorAll('link.jrWebFont');
setTimeout(function() {
if (links) {
for (var i = 0; i < links.length; i++) {
links.item(i).href = links.item(i).href;
}
}
}, 0);
</script>
<![endif]>
</td>
<td width="50%"> </td>
</tr>
</table>
</body>
</html>
我怎样才能实现这个结构?
最佳答案
如果您使用 html 组件将文本环绕在图像周围,您不仅会遇到从数据库中提取图像的问题,html 组件还会创建 html 的图像,因此内容可能会根据需要调整大小/剪裁关于文本长度和 html(图像)组件的设置。
我建议使用两个 textField
环绕图像(参见 jrxml),然后计算文本将在何处进入下一个字段,这样您就可以在第一个 中获得文本的第一部分textField
和第二部分 textField
此代码演示了如何使用 FontMetric
来计算 Jasper Report 将根据 textField
的大小中断文本的位置(代码说明在注释中)。该代码在 NullPointer
(null
文本)和非溢出文本上不是完全安全的,此外它可以优化,但我会把它留给 OP
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
public class WrapImage {
/**
* Get position where string will break
* @param text, the text
* @param width, the width of the component
* @param height, the height of the component
* @return the position
*/
public static int getBreakPosition(String text, int width, int height){
//Start font context
AffineTransform affinetransform = new AffineTransform();
FontRenderContext frc = new FontRenderContext(affinetransform,true,true);
//Set same font as used in jasper-report
Font font = new Font("SansSerif", Font.PLAIN, 10);
//Get height to understand how many lines
double textheight = font.getStringBounds(text, frc).getHeight();
int nrLines = (int)Math.floor(height/textheight);
//init variables
int breakPos = 0;
int line = 1;
//loop the lines
while (line<=nrLines){
//get remaining text
String textPart = text.substring(breakPos,text.length());
//get how much text will fit in line
breakPos += getLineBreakPosition(textPart, width, font, frc)+1;
line++;
}
return breakPos;
}
/**
* Get where a single line will break
* @param text, the text
* @param width, width of component
* @param font, the font used
* @param frc, the FontRenderContext
* @return
*/
protected static int getLineBreakPosition(String text, int width, Font font, FontRenderContext frc){
int breakPos = 0;
String tmpText = text;
while (font.getStringBounds(tmpText, frc).getWidth()>width){
//the break position is space
breakPos = tmpText.lastIndexOf(' ');
if (breakPos<=0){
breakPos = 0;
break;
}
tmpText = tmpText.substring(0,breakPos);
}
return breakPos;
}
}
在这个简短的例子中,我使用了一个带有一些 arbitrary sample 的参数文本。 WrapImage
类位于类路径中。我将一个变量设置为计算出的断点。然后在文本上使用 substring
以在第一个 textfield
中获取第一部分,在第二个 textField
中获取第二部分 为了简化示例,我使用了来自桌面,有关如何从数据库中提取图像的信息,请参阅:Using images stored in database
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="wrappingText" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryWithPageHeaderAndFooter="true" uuid="cd3e4316-a3c4-4847-a085-3bfa1d9425af">
<parameter name="longText" class="java.lang.String">
<defaultValueExpression><![CDATA["Whether you've come to ask questions, or to generously share what you know, remember that we’re all here to learn, together. Be welcoming and patient, especially with those who may not know everything you do. Oh, and bring your sense of humor. Just in case. That basically covers it. But these three guidelines may help: Rudeness and belittling language are not okay. Your tone should match the way you'd talk in person with someone you respect and whom you want to respect you. If you don't have time to say something politely, just leave it for someone who does. Be welcoming, be patient, and assume good intentions. Don't expect new users to know all the rules — they don't. And be patient while they learn. If you're here for help, make it as easy as possible for others to help you. Everyone here is volunteering, and no one responds well to demands for help. Don't be a jerk. These are just a few examples. If you see them, flag them. In summary, have fun, and be good to each other."]]></defaultValueExpression>
</parameter>
<variable name="breakPos" class="java.lang.Integer">
<initialValueExpression><![CDATA[WrapImage.getBreakPosition($P{longText}, 250, 100)]]></initialValueExpression>
</variable>
<title>
<band height="220" splitType="Stretch">
<image>
<reportElement x="10" y="20" width="80" height="80" uuid="6b4bb467-f7fd-4a15-994b-7c1a01b86428"/>
<imageExpression><![CDATA["C:\\Users\\pette\\Desktop\\queen_bee.jpg"]]></imageExpression>
</image>
<textField>
<reportElement x="100" y="0" width="250" height="100" uuid="f4507624-0410-4feb-9dc5-7d3342b882f0"/>
<textElement textAlignment="Justified" verticalAlignment="Bottom"/>
<textFieldExpression><![CDATA[$P{longText}.substring(0,$V{breakPos}.intValue())]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="100" width="350" height="120" uuid="8790bbdd-2066-4ceb-9fc9-dad6154df88c"/>
<textElement textAlignment="Justified"/>
<textFieldExpression><![CDATA[$P{longText}.substring($V{breakPos}.intValue()+1)]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
关于java - 如何在图像周围环绕文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38187873/
我正在学习 ada 并且我正在尝试为枚举实现附加重载。 基本上我希望能够向 Day 类型添加一个 Integer 并获得生成的 Day 值。所以星期一 + 2 => 星期三。 这是我的简化代码: pr
Pycharm 具有“包围”代码片段的功能。有一些已经设置好的功能: 我想添加print()(使用python3),我该怎么做? 最佳答案 AFAIU,您可以为此定义自己的“实时”模板。 定义实时模板
例。我有一个包含15个对象的数组。我想从给定的索引开始枚举。假设从索引5开始,然后是上方的索引,下方,上方,下方等的索引...我确实希望它绕起来。 因此,在我的示例中,索引的顺序将是这样。 5、6、4
我需要帮助创建 UIPickerView 来环绕选项。因此,选择器不是这样的: 我希望它看起来像这样(没有“min”): 我到处找,但找不到用 Swift 2.0 实现的方法谢谢! 最佳答案 以下是有
如何让 UITextView 将其文本包裹在 UIImage 周围,如下图所示? 图像大小不一定是事先已知的。 最佳答案 IOS 7 及以上版本: UIBezierPath * imgRect = [
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: UIScrollView. Any thoughts on implementing “infinite” scro
我像这样创建纹理: this->width = width; this->height = height; glGenFramebuffers(1, &framebuffer); glBindFram
在编码和模板化中,我经常需要换行文本的特定部分。是否有任何快捷方式可以包装当前选择,例如: Hello World "Hello World" Hello World {{ trans 'Hello
我正在做一个项目,我们有一些从数据库中填充的 Highcharts 图表;其中之一是散点图,我们需要包围放置在图表外部区域的点。 我们需要像 this 这样的图表但是我们需要散点图外部点周围的区域;使
我有一个 500 像素高和 50 像素宽的 jpg。它由 10 个 50px x 50px 的正方形组成,每个正方形包含一个从 1 到 10 的数字(1 在图像顶部,10 在底部)。 (jpg 在这里
我正在尝试为那些了解它的人创建一个类似 Microsoft Project 的元素控件。 我有一个Container Div,然后有两个子容器如下: 每个子容器都有很多内部 div,例如,我的第一个子
我有 4 个 div,一个我想向左浮动,视频播放器(加载了 jquery),另一个包含一些将向右浮动的帮助/提示文本。这两个应该排在顶部。在视频播放器下方将是一个 div 内的表格。 当有人点击表格中
这个问题在这里已经有了答案: Proper use of flex properties when nesting flex containers (1 个回答) 关闭 4 年前。
我在使用自定义列表图像时遇到问题/其中图标隐藏在列表环绕的 float 元素后面。 http://jsfiddle.net/V8evM/ HTML This is list item n
是否可以将 textview 环绕在 textview 周围,第二个 textview 将环绕到第一个 textview 下的下一行? 例如: 我尝试过使用 android:layout_weig
图片最能说明问题: 它只是一个 float: left 图像 ( http://jsbin.com/itihes/1 )。有什么方法可以防止纯 CSS 中的动态文本出现这个问题吗?我确实希望文本换行,
我在 C 规范中读到一点,无符号变量(特别是 unsigned short int)在整数溢出时执行一些所谓的环绕 ,尽管我在带符号的变量上找不到任何东西,除了我留下了未定义的行为。 我的教授告诉我,
如果您想要容器底部的 div,如何让文本环绕 div? 我可以弄清楚如何让文本环绕在 div 上,只要它在顶部,但如果我尝试将它推到页面底部,文本要么不会'不要继续跨越 div 的顶部,否则 div
假设数组的长度为 1000。我正在尝试创建一种简单的方法来遍历存储在数组中的图像路径而不会越界。当涉及到单击“下一步”按钮以增加数组索引时,下面的方法使用模数很好地处理了环绕,但当我必须减少并从索引中
假设我的光标在单词 word 内.使用 vim-surround,输入序列 ysiw*将替换 word与 *word* . 问题:是否有我可以输入的单个序列来代替生成 **word** (即,单词加粗
我是一名优秀的程序员,十分优秀!