插入一个base64连接$ C $光盘镜像到XSL-FO文件,而使用Apache-POI [英] Inserting a base64 encoded image into xsl-fo file while using apache-poi

查看:180
本文介绍了插入一个base64连接$ C $光盘镜像到XSL-FO文件,而使用Apache-POI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache POI转换.DOC使用WordToFoConverter类.fo,我在Word文件为Base64转换的图像,但我怎么了追加到由阿帕奇产生的XSL-FO code -poi?

I am using Apache POI to convert .doc to .fo using the WordToFoConverter class, I have converted the images in the word file to base64, but how do i append it to the xsl-fo code generated by apache-poi?

考虑样本FO通过Apache的POI生成的文件 -

Consider the sample fo file generated by Apache-POI-

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="page-page0" page-height="11.0in" page-width="8.5in">
<fo:region-body margin="1.0in 1.0in 1.0in 1.0in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:declarations>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="">
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">CA, Inc.</dc:creator>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
</fo:declarations>
<fo:page-sequence master-reference="page-page0">
<fo:flow flow-name="xsl-region-body">
<fo:block hyphenate="true" linefeed-treatment="preserve" space-after="10pt" text-align="start" white-space-collapse="false">
***<!--Image link to '0.jpg' can be here-->
<fo:inline font-family="Times New Roman" font-size="11" font-style="normal" font-weight="normal">               </fo:inline>
<!--Image link to '9ab33.png' can be here-->
<fo:leader/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

我要如何插入在图像中的 * 的位置?

推荐答案

直接插入图像,恩的base64 codeD中的src属性,同时注意选中相应的MIME类型...例如为JPEG图像

insert the image directly, base64 encoded in the "src" attribute, taking care to mark the appropriate mimetype ... for example for JPEG image:

<fo:external-graphic src="url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA....')"/>

下面是一个模板,可以帮助您了解的结构:

Here's a template that can help you understand the structure:

 <xsl:template match="encodedImage">
    <fo:external-graphic>
        <xsl:attribute name="src">
            <xsl:text>url('data:</xsl:text>
            <xsl:value-of select="attachmentContentType"/>                
            <xsl:text>;base64,</xsl:text>
            <xsl:value-of select="encodedImageBytes"/>
            <xsl:text>')</xsl:text>
        </xsl:attribute>
    </fo:external-graphic>
</xsl:template>

这篇关于插入一个base64连接$ C $光盘镜像到XSL-FO文件,而使用Apache-POI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆