java itext5 插入一个艺术文字 (剪切蒙版)

 /**
     * 添加艺术字
     * @param cb
    * @param page_width 页面宽度
    * @param page_height 页面高度
     * @param font_path 文字路径
     * @param font_content 文字内容
     * @param font_x 文字x坐标
     * @param font_y 文字y坐标
     * @param font_size 文字字号
     * @param font_alignment 文字对齐方式
     * @param font_rotate 文字旋转角度
     * @param image_path 图片路径
     * @param image_x 图片x坐标
     * @param image_y 图片y坐标
     * @param image_width 图片宽度
     * @param image_height 图片高度
     * @throws DocumentException
     * @throws IOException
     */
    public static void addArtText(PdfContentByte cb,float page_width,float page_height, String font_path, String font_content, float font_x, float font_y, float font_size, int font_alignment, float font_rotate, String image_path, float image_x, float image_y, float image_width, float image_height) throws DocumentException, IOException {
        PdfTemplate pdfTemplate = cb.createTemplate(page_width,page_height);
        float pt = 72f/25.4f;
        pdfTemplate.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_CLIP);
        BaseFont baseFont = BaseFont.createFont(font_path, "Identity-H", false);
        pdfTemplate.beginText();
        pdfTemplate.setFontAndSize(baseFont, font_size);
        pdfTemplate.showTextAligned(font_alignment, font_content, font_x, font_y, font_rotate);
        pdfTemplate.endText();
        Image image = Image.getInstance(image_path);
        pdfTemplate.addImage(image, image_width*pt, 0, 0,image_height*pt, image_x, image_y);
        cb.addTemplate(pdfTemplate,0,0);
    }

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值