使用iText在PDF文档中绘制一个矩形 [英] Draw a rectangle in a PDF document using iText

查看:657
本文介绍了使用iText在PDF文档中绘制一个矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iText中是否有方法在PDF文档中绘制矩形?

Is there a way in iText to draw a rectangle in a PDF document?

推荐答案

以下是解决方案。谢谢Dylan McClung。

Here is the solution. Thanks Dylan McClung.

PdfWriter writer = ...;
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
cb.setColorStroke(Color.black);
cb.rectangle(x,y,x1,y1);
cb.stroke();
cb.restoreState();

这篇关于使用iText在PDF文档中绘制一个矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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