有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

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

到目前为止,我正在pdfStamper的帮助下,使用字段的x,y坐标编写动态内容。问题是内容长度超过了文本字段的宽度,与其他文本重叠请参考下图

enter image description here

当达到文本字段的最大长度时,我希望将此文本换行

我用来写内容的代码是

    //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) 个答案