Docx4J - Docx到PDF转换 - 页眉和页脚区域树计算异常

时间:2018-02-23 09:33:06

标签: xsl-fo apache-fop docx4j pdf-conversion

我试图在Docx4J的帮助下使用基于FO的PDF输出将DOCX文件转换为PDF。

DOCX文件和转换后的PDF文件的屏幕截图附在问题的最后。

我在页眉/页脚对齐方面遇到问题。目前,我发现引擎似乎有问题计算块的块 - 进度 - 维度 - 分配(bpda),这给出了数字格式异常,如下所示:

  

对于@bpda,

     

阻止bap =“0 0 0 0”bpd =“0”ipd =“468000”ipda =“468000”

     

对于输入字符串:“”:java.lang.NumberFormatException:用于输入   string:“”

我追踪了Docx4J源代码并在下面的代码段中找到了:

Element block = (Element)region.getChildNodes().item(m);
if (block.getLocalName().equals("block")) {
    try {
        bpda += Integer.parseInt(block.getAttribute("bpda"));
    } catch (java.lang.NumberFormatException nfe) {
        // safe to ignore?
        log.error("For @bpda, \n"+ XmlUtils.w3CDomNodeToString(block));
        log.error(nfe.getMessage(), nfe);
    }

} else {
    // eg beforeFloat, mainReference, footnote
    log.debug(simplePageMasterName + " - Unexpected element: " + block.getLocalName());

因此,该块没有“bpda”属性,并且代码决定使数字格式异常静音。这是错位的原因吗?我该怎么做才能纠正对齐?

带有正确对齐页脚的Docx文件: Docx file with proper aligned footer

已转换的PDF文件 - 页脚未对齐: Converted PDF file - footer is misaligned

0 个答案:

没有答案
相关问题