Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.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
Java iText-使用图像呈现页面底部的段落_Java_Itext - Fatal编程技术网

Java iText-使用图像呈现页面底部的段落

Java iText-使用图像呈现页面底部的段落,java,itext,Java,Itext,我正在使用iText2.1.7。在我生成的文档的最后一页,我有一个签名段落,我总是希望在最后一页的底部呈现 我将所有文本捆绑在一个段落中,然后将其全部放在一个单元格表中,并使用PDFWriter将其写入页面上的固定位置。段落中的文本显示得很好,但图像未包含在内 当我直接将段落本身添加到报告中时,图像渲染良好,但我没有这里需要的定位控制 下面是代码片段: private void addSignatureAndContactInformationAndParagraphThree() th

我正在使用iText2.1.7。在我生成的文档的最后一页,我有一个签名段落,我总是希望在最后一页的底部呈现

我将所有文本捆绑在一个段落中,然后将其全部放在一个单元格表中,并使用PDFWriter将其写入页面上的固定位置。段落中的文本显示得很好,但图像未包含在内

当我直接将段落本身添加到报告中时,图像渲染良好,但我没有这里需要的定位控制

下面是代码片段:

    private void addSignatureAndContactInformationAndParagraphThree() throws DocumentException {
    Font bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, PDFReportUtils.SIGNATURE_NAME_FONT_SIZE);
    Font regular = FontFactory.getFont(FontFactory.HELVETICA, PDFReportUtils.BODY_FONT_SIZE);

    Chunk kindRegards = new Chunk("Kind regards,\n", regular);
    Chunk companyName = new Chunk(getReport().getCompanyName() + "\n", regular);
    Chunk author = new Chunk(getReport().getReportAuthor() + "\n", bold);
    Chunk email = new Chunk(getReport().getReportAuthorEmail() + "\n", regular);
    Chunk phone = new Chunk(getReport().getReportAuthorPhone() + "\n\n", regular);

    PdfPTable singleCellTable = new PdfPTable(1);
    singleCellTable.setTotalWidth((getPdfDocument().right(getPdfDocument().rightMargin())
            - getPdfDocument().left(getPdfDocument().leftMargin())) + 300f);
    PdfPCell singleCell = new PdfPCell();
    singleCell.setBorder(Rectangle.NO_BORDER);

    Paragraph signatureImageBlock = new Paragraph();
    signatureImageBlock.add(kindRegards);
    if(getSignatureImage() != null)
    {
        signatureImageBlock.add(getSignatureImage());
    }
    signatureImageBlock.add(companyName);
    signatureImageBlock.add(author);
    signatureImageBlock.add(email);
    signatureImageBlock.add(phone);
    signatureImageBlock.add(getParagraphThree());

    singleCell.addElement(signatureImageBlock);
    singleCellTable.addCell(singleCell);

    singleCellTable.writeSelectedRows(0, -1,
            getPdfDocument().left(getPdfDocument().leftMargin()) - 45f,
            singleCellTable.getTotalHeight() + getPdfDocument().bottom(getPdfDocument().bottomMargin()),
            writer.getDirectContent());
}
getSignatureImage()检查用户是否配置了签名映像,然后是来自硬盘驱动器的映像(以下是返回语句):


你知道为什么它会呈现所有文本,但根本不包含图像吗?我已经调试了它,以确保它从getSignatureImage()获取图像。

发现了问题。我需要将图像添加到块中才能正确渲染!希望这对其他人有帮助

Chunk signatureImage = new Chunk(getSignatureImage(), 0, 0, true);
        signatureImageBlock.add(signatureImage);
Chunk signatureImage = new Chunk(getSignatureImage(), 0, 0, true);
        signatureImageBlock.add(signatureImage);