Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
itextpdf重叠长字符串_Pdf_Itext - Fatal编程技术网

itextpdf重叠长字符串

itextpdf重叠长字符串,pdf,itext,Pdf,Itext,为什么有重叠的文本行 final String FONT = "fonts/segoeuisl.ttf"; Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("iTextHelloWorld.pdf")); document.open(); BaseFont bf=B

为什么有重叠的文本行

final String FONT = "fonts/segoeuisl.ttf";
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream("iTextHelloWorld.pdf"));
        document.open();
        BaseFont bf=BaseFont.createFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        Font font = new Font (bf,14,Font.NORMAL);
        Chunk chunk = new Chunk(GetDn.displayName + "jsdgfjsdgfjkgsdkjfgkjafgjsdgf7239tf2fbjlsgfsdjgfskjdfakjsdg7sf9sdft9gABFLJGJSDJFG67TSD SDFJSDJFKGSDKJFG", font);
        document.add(chunk);
        document.close();

默认情况下,chank中的字符串高度为0。 高度调整通过添加代码
chunk.setLineHeight(15)完成


这并不能回答这个问题。若要评论或要求作者澄清,请在其帖子下方留下评论。-如果这解决了你的问题,将真正有助于提高你的文章质量,并可能导致更多的投票。请记住,你是在将来回答读者的问题,而不仅仅是现在提问的人。请在回答中添加解释,并说明适用的限制和假设。
    final String FONT = "fonts/segoeuisl.ttf";
    Document document = new Document(PageSize.A4, 5, 5, 20,15);
    PdfWriter.getInstance(document, new FileOutputStream("iTextHelloWorld.pdf"));
    document.open();
    BaseFont bf = BaseFont.createFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    Font font = new Font (bf,14,Font.NORMAL);
    Chunk chunk = new Chunk(GetDn.displayName, font);
    chunk.setLineHeight(15);
    document.addAuthor(GetDn.displayName);
    document.addCreationDate();
    document.add(chunk);
    document.close();