1

使用 fop1.1 ,我正在尝试使用本节fop 中间格式中讨论的中间文件方法打印文档

问题是它在第三步打印了一个空白页。

这是我用于测试的 FO 文件:

    <?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions">
   <fo:layout-master-set>
      <fo:simple-page-master master-name="all" page-height="5.4cm" page-width="9.56cm" margin-top="0cm" margin-bottom="0cm" margin-left="0cm" margin-right="0cm">
         <fo:region-body margin-top="0cm" margin-bottom="0cm" background-color="transparent" />
      </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="all">
      <fo:flow flow-name="xsl-region-body">
         <fo:block>
            <fo:block-container absolute-position="absolute" top="5px" left="11px" height="30px" width="300px" overflow="hidden">
               <fo:block font-weight="normal" font-style="italic" font-family="Arial">852147</fo:block>
            </fo:block-container>
            <fo:block-container absolute-position="absolute" top="50px" left="10px" height="30px" width="300px" overflow="hidden">
               <fo:block font-weight="bold" font-style="normal" font-family="Arial" font-size="10pt">nabil</fo:block>
            </fo:block-container>
            <fo:block-container absolute-position="absolute" top="100px" left="10px" height="30px" width="300px" overflow="hidden">
               <fo:block font-weight="bold" font-style="normal" font-family="Arial" font-size="10pt">madara</fo:block>
            </fo:block-container>
         </fo:block>
      </fo:flow>
   </fo:page-sequence>
</fo:root>

配置文件

<?xml version="1.0"?>
<!-- $Id: fop.xconf 1339442 2012-05-17 01:42:56Z gadams $ -->



<!-- NOTE: This is the version of the configuration -->
<fop version="1.1">
<fonts>
      <auto-detect/>
      </fonts>

<!-- Strict user configuration -->
  <strict-configuration>true</strict-configuration>

  <!-- Strict FO validation -->
  <strict-validation>true</strict-validation>

  <!-- Base URL for resolving relative URLs -->
  <base>.</base>

  <!-- Font Base URL for resolving relative font URLs -->
  <font-base>./</font-base>


  <source-resolution>72</source-resolution>

  <target-resolution>72</target-resolution>


  <default-page-settings height="11in" width="8.26in"/>


 <renderers>
    <renderer mime="application/pdf">
      <filterList>
        <!-- provides compression using zlib flate (default is on) -->
        <value>flate</value>



      </filterList>

      <fonts>
      <auto-detect/>

      </fonts>


    </renderer>
</renderers>

</fop>

脚步 :

  1. fop -c cfg.xml -fo myfile.fo -at application/pdf myfile.at.xml
  2. fop -c cfg.xml -atin myfile.at.xml -pdf myfile.pdf (pdf文件生成正确)
  3. fop -atin myfile.at.xml -print(使用pdf创建器打印空白页)
4

1 回答 1

3

FOP 1.1 中的 AWT 渲染器(打印渲染器使用 AWT 渲染器)似乎存在问题。我使用以下作为您的第 3 步尝试了您的示例:

fop -atin myfile.at.xml -awt

我注意到了同样的结果——一个空白页。(注意:要让 AWT 渲染在 Windows 上工作,您需要进行编辑fop.bat,以便-Djava.awt.headless=false)。

我发现控制台没有记录任何错误很奇怪,而且我在 FOP 的 JIRA 实例中找不到任何报告的错误。所以我决定尝试一下 FOP 1.0。

解决方法- 下载 FOP 1.0 而不是 FOP 1.1。使用以下作为您的第 3 步

fop -atin myfile.at.xml -print all

注意: all参数用于打印所有页面。省略此参数在 1.0 中失败,但已在 1.1 中修复。

希望以上对您来说是一个可行的解决方案!似乎 FOP 1.1 和 AWT 渲染器存在未解决/未报告的问题。:(

于 2013-08-05T02:44:55.967 回答