我想用apache poi将docx转换为pdf,使用docx4j正确生成docx.使用简单文档转换工作正常,但是当我想转换更风格化的文档时,POI会抛出异常:
org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException:union value'0000FF"> http://schemas.openxmlformats.org/wordprocessingml/2006/main'15:09:20 org.apache.poi.xwpf.converter.core .XWPFConverterException:org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException:union value'0000FF"> http://schemas.openxmlformats.org/wordprocessingml/2006/main'at org.apache.poi.xwpf.converter.pdf. PdfConverter.doConvert(PdfConverter.java:70)〜[org.apache.poi.xwpf.converter.pdf-1.0.6.jar:1.0.6]
有这个例外的原因:
<w:r>
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
<w:color w:val="0000FF"><span style="background-color: rgb(51, 153, 102);"><span style="background-color: rgb(255, 0, 0);"><font color="99CC00"/>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
<w:highlight w:val="red"/>
</w:rPr>
<w:t xml:space="preserve">Juillet-Aout</w:t>
</w:r>
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;
public class ConvertDocxPdf
{
public static void main( String[] args )
{
long startTime = System.currentTimeMillis();
try
{
// 1) Load docx with POI …Run Code Online (Sandbox Code Playgroud) 我有一个这样的字符串:
嘿,我的名字是$ name $; 我有$岁多岁,我喜欢玩$ sport $,我住的是$ country $!
我想在地图中返回$之间的每个单词的长度,例如,我的地图应该是:
起初我想过在我的函数中进行递归调用,但是我没有办法做到这一点?
我正在使用 PostgreSQL 和 PlayFramework,我需要将 an 转换Option[String]为 aTimestamp以执行我的查询。
我的Option[String]日期格式如下:2016/07/26
时间戳的格式为:2016-07-26
我知道我可以添加 to_stimetamp(myDate, 'YYYY-MM-DD')到我的查询中,但我不想使用它(实际上我不知道以后是否会使用 MySQL 或 PostgreSQL,因为 MySQL 中不存在该函数)
那我该怎么办呢?