如何在java中使用iText包装文本?

时间:2016-09-09 06:31:15

标签: java itext

我有现有的PDF模板文档,因为我有文本字段,文本区域等。在那些字段中我想写一个动态内容,我从数据库中获取。

截至目前,我正在使用pdfStamper的x,y坐标字段编写动态内容。问题是内容的长度超出文本字段并且在其他文本上重叠请参考下图。

enter image description here

我希望在达到文本字段的最大长度时包装此文本。

Code i用于编写内容是。

    //Read Template
    PdfReader pdfReader = new PdfReader("src\\main\\resources\\templates\\IES.pdf");
  //Create copy of template
PdfStamper pdfStamper = new PdfStamper(pdfReader,
                    new FileOutputStream("D:\\pdfSamples\\Output\\IES.pdf"));
//Initialize additional content object
                PdfContentByte content=initialReExamScreenOnePrintPDF.createNewContentByte(pageNo, pdfStamper);

                //Start Placing Text-Radio-CheckBox
                content.beginText();

content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Some Text",36, 123,0);
//End Content
content.endText();
pdfStamper.close();
pdfReader.close();

请帮助解决此问题

0 个答案:

没有答案