繁体   English   中英

itext创建pdf,并在图标周围包裹文字

[英]itext Create pdf with text wrapped around the icon

我正在尝试使用itext java库创建pdf文件,例如:
在此处输入图片说明

在哪里创建荧光笔图标(箭头符号),如:

Phrase ph=new Phrase("ä", FontFactory.getFont(FontFactory.ZAPFDINGBATS, 14f));

现在我想要广告的所有文字,即。

现在拥有5年分期付款选项@ J450的农场地皮@ INR450 /平方英尺,带有5英亩俱乐部房屋。www.goldeneraproperty.comM-9999999999

应该自动环绕我在上面使用FontFactory.ZAPFDINGBATS创建的图标。 但是我被困在这里。请任何人帮我解决。

我尝试创建一个由一列和一个单元格组成的表,然后将图标放在该单元格中,但这没有帮助,因为文本没有在表中环绕。 请建议我如何创建一个pdf文件,文本会自动环绕在该图标周围。谢谢提前!!!

我已将其设计为类似状态。 请在PDF文件中使用自己的对齐方式,字体,大小等。

PFB以上设计的代码:

package com.itext_dummy;

import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

public class Hello { 
    /** Path to the resulting PDF file. */
    public static final String RESULT
        = "src/hello.pdf";
    public static void main(String[] args)
        throws DocumentException, IOException {
        new Hello().createPdf(RESULT);
    }
    public void createPdf(String filename)
    throws DocumentException, IOException {
        Document document = new Document();

        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();

        Image img = Image.getInstance("src/Arrow.png");
        img.scaleAbsolute(50f, 50f);
        img.setAlignment(Image.LEFT | Image.TEXTWRAP);
        document.add(img);
        Paragraph para = new Paragraph();
        para.add("Now own a Farm Plot nr Jigani in 5yrs installment option @INR450/sqft with 5acre Club House.www.goldeneraproperty.com M-99999999994444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444");        
        document.add(para);
        document.close();
    }
}

请自行调整图像大小和段落文本的大小以及对齐方式。

也PFB我使用的图标图像:

箭头

我使用了图像,因为这是包装的唯一方法。

PFB我的结果截图: 产生的pdf

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM