word xml 空格符

标签中加空格符

  这个就代表着空格,一个 相当于英文的一个字母的占位,四个 相当于一个汉字的占位。

空格符

<w:r><w:tab/></w:r><w:r><w:tab/></w:r><w:r><w:tab/></w:r><w:r><w:tab/></w:r><w:r><w:tab/></w:r>

添加图片

<w:r><w:rPr><w:noProof/></w:rPr>
            <w:pict><w:binData w:name="wordml://02000003.jpg" xml:space="preserve">#(sign_base64)
</w:binData>
                <v:shape id="_x0000_s1032" type="#_x0000_t75"
                         style="position:absolute;left:0;text-align:left;margin-left:79.15pt;margin-top:14.4pt;width:66.65pt;height:36.65pt;z-index:4;mso-position-horizontal-relative:text;mso-position-vertical-relative:text"><v:imagedata src="wordml://02000003.jpg" o:title="1-1P11410015C94"/></v:shape></w:pict></w:r></w:p><w:p
            wsp:rsidR="00D702E8" wsp:rsidRDefault="00DA1EC3"><w:pPr><w:ind w:first-line-chars="300" w:first-line="840"/><w:rPr><w:sz w:val="28"/>
        <w:sz-cs w:val="28"/></w:rPr></w:pPr>

新版的word xml添加图片后必须修改

//这里也必须修改
<pkg:part pkg:name="/word/media/image1.png" pkg:contentType="image/png" pkg:compression="store">
        <pkg:binaryData>#(sign_base64)
        </pkg:binaryData>
    </pkg:part>
    <pkg:part pkg:name="/word/media/image2.png" pkg:contentType="image/png" pkg:compression="store">
        <pkg:binaryData>#(sign_base64)
        </pkg:binaryData>
    </pkg:part>
    <pkg:part pkg:name="/word/media/image3.png" pkg:contentType="image/png" pkg:compression="store">
        <pkg:binaryData>#(card_base64)
        </pkg:binaryData>
    </pkg:part>

在这里插入图片描述

//图片改base64

private String getbase64(String img_url) throws IOException {
        String suffix = card_url.substring(card_url.lastIndexOf(".") + 1);
        URL urls = new URL(card_url);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Image image = Toolkit.getDefaultToolkit().getImage(urls);
        BufferedImage biOut = toBufferedImage(image);
        ImageIO.write(biOut, suffix, baos);
        return Base64Util.encode(baos.toByteArray());
    }
    
    public static BufferedImage toBufferedImage(Image image) {
        if (image instanceof BufferedImage) {
            return (BufferedImage) image;
        }
        // This code ensures that all the pixels in the image are loaded
        image = new ImageIcon(image).getImage();
        BufferedImage bimage = null;
        GraphicsEnvironment ge = GraphicsEnvironment
                .getLocalGraphicsEnvironment();
        try {
            int transparency = Transparency.OPAQUE;
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            GraphicsConfiguration gc = gs.getDefaultConfiguration();
            bimage = gc.createCompatibleImage(image.getWidth(null),
                    image.getHeight(null), transparency);
        } catch (HeadlessException e) {
            // The system does not have a screen
        }
        if (bimage == null) {
            // Create a buffered image using the default color model
            int type = BufferedImage.TYPE_INT_RGB;
            bimage = new BufferedImage(image.getWidth(null),
                    image.getHeight(null), type);
        }
        // Copy image to buffered image
        Graphics g = bimage.createGraphics();
        // Paint the image onto the buffered image
        g.drawImage(image, 0, 0, null);
        g.dispose();
        return bimage;
    }
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值