getting blank page when printing with fop 1.1

时光总嘲笑我的痴心妄想 提交于 2019-12-11 08:34:27

问题


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

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

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>

config file

<?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>

steps :

  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)

回答1:


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

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).

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.

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

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

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. :(



来源:https://stackoverflow.com/questions/16901845/getting-blank-page-when-printing-with-fop-1-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!