itext包导出PDF的数据显示不全问题

zx27600 2010-11-16 04:25:43
public void paint(Graphics2D g) {
Border border = displayStyle.getBorder();
Rectangle b = (border != null)
? deflateRect((Rectangle) getBounds().clone(), border.getInsets()) : getBounds();

Graphics2D gcopy = (Graphics2D) g.create();

Shape save = gcopy.getClip();
gcopy.clip(b);

String text = getText();

if ((text != null) && !text.equals("")) {

TextLine[] lines = getWrappedLines();

if (lines.length > 1) {
int ay = getHorizentalAdvance(lines[lines.length - 1].y);

for (int i = 0; i < lines.length; i++) {
TextLine line = lines[i];
gcopy.drawString(line.text, line.x + b.x, line.y + b.y + ay);
}
} else {
FontMetrics fm = gcopy.getFontMetrics();

Point base = TextView.layoutText(fm.stringWidth(text), fm,
displayStyle.getHorizontalAlignment(), displayStyle.getVerticalAlignment(),
b);
gcopy.drawString(text, base.x, base.y);
}
}

gcopy.setClip(save);

if (getBorder() != null) {
getBorder().paint(gcopy, getBounds());
}

gcopy.dispose();
}

...全文
876 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
沙罗曼蛇 2010-12-01
  • 打赏
  • 举报
回复
我也是遇到这问题,显示不开excel的格 都重叠了
zx27600 2010-11-16
  • 打赏
  • 举报
回复
具体来说是怎样控制列宽,因为PDF不能像Excel一样,如果格子内容多了,显示不全可以拉宽便可显示全;所以就是控制PDF的列宽,让数据全部显示出来
zx27600 2010-11-16
  • 打赏
  • 举报
回复
具体来说是怎样控制列宽

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧