|
3 | 3 | import org.apache.pdfbox.pdmodel.font.PDFont;
|
4 | 4 | import wiki.xsx.core.pdf.component.XEasyPdfComponent;
|
5 | 5 | import wiki.xsx.core.pdf.component.image.XEasyPdfImage;
|
| 6 | +import wiki.xsx.core.pdf.component.line.XEasyPdfLine; |
6 | 7 | import wiki.xsx.core.pdf.component.text.XEasyPdfText;
|
7 | 8 | import wiki.xsx.core.pdf.doc.XEasyPdfDocument;
|
8 | 9 | import wiki.xsx.core.pdf.handler.XEasyPdfHandler;
|
@@ -271,11 +272,17 @@ void doDraw(XEasyPdfDocument document, XEasyPdfPage page, XEasyPdfRow row) throw
|
271 | 272 | if (component instanceof XEasyPdfText) {
|
272 | 273 | // 写入文本
|
273 | 274 | this.writeText(document, page, row, (XEasyPdfText) component);
|
274 |
| - // 如果组件属于图片组件,则写入图片 |
275 |
| - }else if (component instanceof XEasyPdfImage) { |
| 275 | + } |
| 276 | + // 如果组件属于图片组件,则写入图片 |
| 277 | + else if (component instanceof XEasyPdfImage) { |
276 | 278 | // 写入图片
|
277 | 279 | this.writeImage(document, page, row, (XEasyPdfImage) component);
|
278 | 280 | }
|
| 281 | + // 如果组件属于线条组件,则写入线条 |
| 282 | + else if (component instanceof XEasyPdfLine) { |
| 283 | + // 写入线条 |
| 284 | + this.writeLine(document, page, row, (XEasyPdfLine) component); |
| 285 | + } |
279 | 286 | // TODO 后续有需要,再加入其他组件
|
280 | 287 | }
|
281 | 288 | // 重置为当前行X轴原始坐标
|
@@ -358,4 +365,21 @@ private void writeImage(XEasyPdfDocument document, XEasyPdfPage page, XEasyPdfRo
|
358 | 365 | page.getParam().getPageY() - row.getParam().getMarginTop() - image.getMarginTop() - image.getHeight(document, page) - this.param.getBorderWidth() / 2
|
359 | 366 | ).draw(document, page);
|
360 | 367 | }
|
| 368 | + |
| 369 | + /** |
| 370 | + * 写入分割线 |
| 371 | + * @param document pdf文档 |
| 372 | + * @param page pdf页面 |
| 373 | + * @param row pdf表格行 |
| 374 | + * @param line pdf线条 |
| 375 | + * @throws IOException IO异常 |
| 376 | + */ |
| 377 | + private void writeLine(XEasyPdfDocument document, XEasyPdfPage page, XEasyPdfRow row, XEasyPdfLine line) throws IOException { |
| 378 | + line.setContentMode(this.param.getContentMode()) |
| 379 | + .setWidth(this.param.getWidth() - this.param.getBorderWidth() * 2) |
| 380 | + .setPosition( |
| 381 | + row.getParam().getBeginX() + this.param.getBorderWidth() / 2, |
| 382 | + page.getParam().getPageY() - row.getParam().getMarginTop() - line.getLineWidth() - this.param.getBorderWidth() / 2 |
| 383 | + ).draw(document, page); |
| 384 | + } |
361 | 385 | }
|
0 commit comments