使用 fop 1.1 打印时出现空白页 [英] getting blank page when printing with fop 1.1

查看:21
本文介绍了使用 fop 1.1 打印时出现空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

using fop1.1 , i'm trying to print a document using the intermediate file method disscussed in this section fop intermediate format

问题在于它在第 3 步中打印了一个空白页.

the problem is that it prints a blank page in the 3rd step .

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

this is the FO file i'm using for my tests :

    <?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 creator 打印空白页)
  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 (the pdf file is generated correctly)
  3. fop -atin myfile.at.xml -print ( a blank page is printed using pdf creator)

推荐答案

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

There seems to be a problem with the AWT renderer (the print renderer uses the AWT renderer) in FOP 1.1. I tried your example using the following as your step 3:

fop -atin myfile.at.xml -awt

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

I noticed the same result - a blank page. (NOTE: to get the AWT render to work on Windows, you will need to edit fop.bat so that -Djava.awt.headless=false).

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

I found it strange that no errors were logged to the console, and I couldn't find any bugs reported in FOP's JIRA instance. So I decided to have a play with FOP 1.0.

解决方法 - 下载 FOP 1.0 而不是 FOP 1.1.将以下内容用作您的第 3 步:

The workaround - download FOP 1.0 instead of FOP 1.1. Use the following as your Step 3:

fop -atin myfile.at.xml -print all

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

NOTE: The all argument is used to print all pages. Omitting this argument fails in 1.0, but has been fixed in 1.1.

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

Hope the above is a workable solution for you! It seems very much as though there's an unresolved/unreported issue with FOP 1.1 and the AWT renderer. :(

这篇关于使用 fop 1.1 打印时出现空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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