Wednesday, June 18, 2008

Verifying that the PDF print server works

Here's another posting on PDF printing in Application Express. Sometimes it's just a bit difficult to figure out what exactly is wrong if a report doesn't print properly. Sometimes all a customer gets in an empty / zero-length PDF file and no other indication on where it failed. A good place to look at are the log files of your OC4J server or J2EE container. Often BI Publisher or Apache FOP leave some clues there. But at other times there's just nothing helpful to find in these logs. And this could be due to your APEX instance not getting through to your print server which could be caused by not having configured the print server settings properly in Application Express.

One way to make sure your print server is up and running and configured properly is setting up a static HTML form that simulates what APEX is doing internally, i.e posting some XML data along with an XSL-FO stylesheet to a print server via HTTP and receiving back a PDF document as the response. If this works properly, you can at least be sure that your print server works. So then the next step would be to double-check the print server settings in APEX, make sure that network services are enabled when running 11g and ensure that you can reach your print server from your database server.

Here’s some HTML code that can be used to simulate or test your print server. Just replace the [host] and [port] values in the form tag with your actual values and then load the file into your browser and give it a try using e.g. the sample XML data and sample XSL-FO stylesheet below (just copy and paste in your form). This assumes you’re using Apache FOP, when using BI Publisher, also replace /fop/apex_fop.jsp with /xmlpserver/convert.

Static HTML form to test print server:
<html>
<body>
<form action="http://[host]:[port]/fop/apex_fop.jsp" method="post" name="foptest">
<textarea name="xml" cols="80" rows="10">
</textarea><br />
<textarea name="template" cols="80" rows="10">
</textarea><br />
<input type="test" name="_xtype" value="xsl-fo" /><br />
<input type="test" name="_xf" value="pdf" /><br />
<input type="submit" />
<form>
</body>
</html>

Sample XML Data:
<?xml version="1.0" encoding="UTF-8"?>
<ROWSET>
<ROW>
<FIRST_NAME>John</FIRST_NAME>
<LAST_NAME>Doe</LAST_NAME>
</ROW>
<ROW>
<FIRST_NAME>Jane</FIRST_NAME>
<LAST_NAME>Doe</LAST_NAME>
</ROW>
</ROWSET>

Sample XSL-FO style sheet:
<?xml version = '1.0' encoding = 'utf-8'?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ora="http://www.oracle.com/XSL/Transform/java/" xmlns:xdofo="http://xmlns.oracle.com/oxp/fo/extensions" xmlns:xdoxslt="http://www.oracle.com/XSL/Transform/java/oracle.apps.xdo.template.rtf.XSLTFunctions" xmlns:xdoxliff="urn:oasis:names:tc:xliff:document:1.1" xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="master0" margin-left="84.6pt" margin-right="84.6pt" page-height="792.0pt" page-width="612.0pt" margin-top="36.0pt" margin-bottom="36.0pt">
<fo:region-before region-name="region-header" extent="36.0pt"/>
<fo:region-body region-name="region-body" margin-top="36.0pt" margin-bottom="36.0pt"/>
<fo:region-after region-name="region-footer" extent="36.0pt" display-align="after"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="master0">
<fo:title>Report</fo:title>
<fo:static-content flow-name="region-header"/>
<fo:static-content flow-name="region-footer"/>
<fo:flow flow-name="region-body">
<fo:block padding-bottom="0.25pt" padding-top="0.25pt">
<fo:table start-indent="0.0pt" xdofo:table-summary="Template Table 1" xdofo:row-header-count="0">
<fo:table-column column-width="147.6pt"/>
<fo:table-column column-width="147.6pt"/>
<fo:table-header>
<fo:table-row keep-with-next="always">
<fo:table-cell padding-start="5.15pt" vertical-align="top" border-bottom="0.5pt solid #000000" border-end-color="#000000" padding-top="0.0pt" border-end-style="solid" border-start-color="#000000" padding-end="5.15pt" number-columns-spanned="1" border-top="0.5pt solid #000000" border-start-style="solid" height="0.0pt" border-end-width="0.5pt" padding-bottom="0.0pt" border-start-width="0.5pt" background-color="#ff4040">
<fo:block orphans="2" widows="2" linefeed-treatment="preserve" start-indent="0.0pt" text-align="start" padding-bottom="0.0pt" end-indent="0.0pt" padding-top="0.0pt">
<fo:inline height="12.0pt" font-family="Arial" white-space-collapse="false" font-size="12.0pt" font-weight="bold">First Name</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="5.15pt" vertical-align="top" border-bottom="0.5pt solid #000000" border-end-color="#000000" padding-top="0.0pt" border-end-style="solid" border-start-color="#000000" padding-end="5.15pt" number-columns-spanned="1" border-top="0.5pt solid #000000" border-start-style="solid" height="0.0pt" border-end-width="0.5pt" padding-bottom="0.0pt" border-start-width="0.5pt" background-color="#ff4040">
<fo:block orphans="2" widows="2" linefeed-treatment="preserve" start-indent="0.0pt" text-align="start" padding-bottom="0.0pt" end-indent="0.0pt" padding-top="0.0pt">
<fo:inline height="12.0pt" font-family="Arial" white-space-collapse="false" font-size="12.0pt" font-weight="bold">Last Name</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:for-each select=".//ROW" xdofo:ctx="3">
<fo:table-row xdofo:repeat="R">
<fo:table-cell padding-start="5.15pt" vertical-align="top" border-bottom="0.5pt solid #000000" border-end-color="#000000" padding-top="0.0pt" border-end-style="solid" border-start-color="#000000" padding-end="5.15pt" number-columns-spanned="1" border-top="0.5pt solid #000000" border-start-style="solid" height="0.0pt" border-end-width="0.5pt" padding-bottom="0.0pt" border-start-width="0.5pt">
<fo:block xdofo:xliff-note="F , FIRST_NAME" orphans="2" widows="2" linefeed-treatment="preserve" start-indent="0.0pt" text-align="start" padding-bottom="0.0pt" end-indent="0.0pt" padding-top="0.0pt" height="0pt">
<fo:inline height="12.0pt" font-family="Arial" white-space-collapse="false" font-size="12.0pt">
<xsl:value-of select=".//FIRST_NAME" xdofo:field-name="FIRST_NAME"/>
</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="5.15pt" vertical-align="top" border-bottom="0.5pt solid #000000" border-end-color="#000000" padding-top="0.0pt" border-end-style="solid" border-start-color="#000000" padding-end="5.15pt" number-columns-spanned="1" border-top="0.5pt solid #000000" border-start-style="solid" height="0.0pt" border-end-width="0.5pt" padding-bottom="0.0pt" border-start-width="0.5pt">
<fo:block xdofo:xliff-note="LAST_NAME" orphans="2" widows="2" linefeed-treatment="preserve" start-indent="0.0pt" text-align="start" padding-bottom="0.0pt" end-indent="0.0pt" padding-top="0.0pt" height="0.0pt">
<fo:inline height="12.0pt" font-family="Arial" white-space-collapse="false" font-size="12.0pt">
<xsl:value-of select=".//LAST_NAME" xdofo:field-name="LAST_NAME"/>
</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>

213 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. This comment has been removed by a blog administrator.

    ReplyDelete
  13. This comment has been removed by a blog administrator.

    ReplyDelete
  14. This comment has been removed by a blog administrator.

    ReplyDelete
  15. This comment has been removed by a blog administrator.

    ReplyDelete
  16. This comment has been removed by a blog administrator.

    ReplyDelete
  17. This comment has been removed by a blog administrator.

    ReplyDelete
  18. This comment has been removed by a blog administrator.

    ReplyDelete
  19. This comment has been removed by a blog administrator.

    ReplyDelete
  20. This comment has been removed by a blog administrator.

    ReplyDelete
  21. This comment has been removed by a blog administrator.

    ReplyDelete
  22. This comment has been removed by a blog administrator.

    ReplyDelete
  23. This comment has been removed by a blog administrator.

    ReplyDelete
  24. This comment has been removed by a blog administrator.

    ReplyDelete
  25. This comment has been removed by a blog administrator.

    ReplyDelete
  26. This comment has been removed by a blog administrator.

    ReplyDelete
  27. This comment has been removed by a blog administrator.

    ReplyDelete
  28. This comment has been removed by a blog administrator.

    ReplyDelete
  29. This comment has been removed by a blog administrator.

    ReplyDelete
  30. This comment has been removed by a blog administrator.

    ReplyDelete
  31. This comment has been removed by a blog administrator.

    ReplyDelete
  32. This comment has been removed by a blog administrator.

    ReplyDelete
  33. This comment has been removed by a blog administrator.

    ReplyDelete
  34. This comment has been removed by a blog administrator.

    ReplyDelete
  35. This comment has been removed by a blog administrator.

    ReplyDelete
  36. This comment has been removed by a blog administrator.

    ReplyDelete
  37. This comment has been removed by a blog administrator.

    ReplyDelete
  38. This comment has been removed by a blog administrator.

    ReplyDelete
  39. This comment has been removed by a blog administrator.

    ReplyDelete
  40. This comment has been removed by a blog administrator.

    ReplyDelete
  41. This comment has been removed by a blog administrator.

    ReplyDelete
  42. This comment has been removed by a blog administrator.

    ReplyDelete
  43. This comment has been removed by a blog administrator.

    ReplyDelete
  44. This comment has been removed by a blog administrator.

    ReplyDelete
  45. This comment has been removed by a blog administrator.

    ReplyDelete
  46. This comment has been removed by a blog administrator.

    ReplyDelete
  47. This comment has been removed by a blog administrator.

    ReplyDelete
  48. This comment has been removed by a blog administrator.

    ReplyDelete
  49. This comment has been removed by a blog administrator.

    ReplyDelete
  50. This comment has been removed by a blog administrator.

    ReplyDelete
  51. This comment has been removed by a blog administrator.

    ReplyDelete
  52. This comment has been removed by a blog administrator.

    ReplyDelete
  53. This comment has been removed by a blog administrator.

    ReplyDelete
  54. This comment has been removed by a blog administrator.

    ReplyDelete
  55. This comment has been removed by a blog administrator.

    ReplyDelete
  56. This comment has been removed by a blog administrator.

    ReplyDelete
  57. This comment has been removed by a blog administrator.

    ReplyDelete
  58. This comment has been removed by a blog administrator.

    ReplyDelete
  59. This comment has been removed by a blog administrator.

    ReplyDelete
  60. This comment has been removed by a blog administrator.

    ReplyDelete
  61. This comment has been removed by a blog administrator.

    ReplyDelete
  62. This comment has been removed by a blog administrator.

    ReplyDelete
  63. This comment has been removed by a blog administrator.

    ReplyDelete
  64. This comment has been removed by a blog administrator.

    ReplyDelete
  65. This comment has been removed by a blog administrator.

    ReplyDelete
  66. This comment has been removed by a blog administrator.

    ReplyDelete
  67. This comment has been removed by a blog administrator.

    ReplyDelete
  68. This comment has been removed by a blog administrator.

    ReplyDelete
  69. This comment has been removed by a blog administrator.

    ReplyDelete
  70. This comment has been removed by a blog administrator.

    ReplyDelete
  71. This comment has been removed by a blog administrator.

    ReplyDelete
  72. This comment has been removed by a blog administrator.

    ReplyDelete
  73. This comment has been removed by a blog administrator.

    ReplyDelete
  74. This comment has been removed by a blog administrator.

    ReplyDelete
  75. This comment has been removed by a blog administrator.

    ReplyDelete
  76. This comment has been removed by a blog administrator.

    ReplyDelete
  77. This comment has been removed by a blog administrator.

    ReplyDelete
  78. This comment has been removed by a blog administrator.

    ReplyDelete
  79. This comment has been removed by a blog administrator.

    ReplyDelete
  80. This comment has been removed by a blog administrator.

    ReplyDelete
  81. This comment has been removed by a blog administrator.

    ReplyDelete
  82. This comment has been removed by a blog administrator.

    ReplyDelete
  83. This comment has been removed by a blog administrator.

    ReplyDelete
  84. This comment has been removed by a blog administrator.

    ReplyDelete
  85. This comment has been removed by a blog administrator.

    ReplyDelete
  86. This comment has been removed by a blog administrator.

    ReplyDelete
  87. This comment has been removed by a blog administrator.

    ReplyDelete
  88. This comment has been removed by a blog administrator.

    ReplyDelete
  89. This comment has been removed by a blog administrator.

    ReplyDelete
  90. This comment has been removed by a blog administrator.

    ReplyDelete
  91. This comment has been removed by a blog administrator.

    ReplyDelete
  92. This comment has been removed by a blog administrator.

    ReplyDelete
  93. This comment has been removed by a blog administrator.

    ReplyDelete
  94. This comment has been removed by a blog administrator.

    ReplyDelete
  95. This comment has been removed by a blog administrator.

    ReplyDelete
  96. This comment has been removed by a blog administrator.

    ReplyDelete
  97. This comment has been removed by a blog administrator.

    ReplyDelete
  98. This comment has been removed by a blog administrator.

    ReplyDelete
  99. This comment has been removed by a blog administrator.

    ReplyDelete
  100. This comment has been removed by a blog administrator.

    ReplyDelete
  101. This comment has been removed by a blog administrator.

    ReplyDelete
  102. This comment has been removed by a blog administrator.

    ReplyDelete
  103. This comment has been removed by a blog administrator.

    ReplyDelete
  104. This comment has been removed by a blog administrator.

    ReplyDelete
  105. This comment has been removed by a blog administrator.

    ReplyDelete
  106. This comment has been removed by a blog administrator.

    ReplyDelete
  107. This comment has been removed by a blog administrator.

    ReplyDelete
  108. This comment has been removed by a blog administrator.

    ReplyDelete
  109. This comment has been removed by a blog administrator.

    ReplyDelete
  110. This comment has been removed by a blog administrator.

    ReplyDelete
  111. This comment has been removed by a blog administrator.

    ReplyDelete
  112. This comment has been removed by a blog administrator.

    ReplyDelete
  113. This comment has been removed by a blog administrator.

    ReplyDelete
  114. This comment has been removed by a blog administrator.

    ReplyDelete
  115. This comment has been removed by a blog administrator.

    ReplyDelete
  116. This comment has been removed by a blog administrator.

    ReplyDelete
  117. This comment has been removed by a blog administrator.

    ReplyDelete
  118. This comment has been removed by a blog administrator.

    ReplyDelete
  119. This comment has been removed by a blog administrator.

    ReplyDelete
  120. This comment has been removed by a blog administrator.

    ReplyDelete
  121. This comment has been removed by a blog administrator.

    ReplyDelete
  122. This comment has been removed by a blog administrator.

    ReplyDelete
  123. This comment has been removed by a blog administrator.

    ReplyDelete
  124. This comment has been removed by a blog administrator.

    ReplyDelete
  125. This comment has been removed by a blog administrator.

    ReplyDelete
  126. This comment has been removed by a blog administrator.

    ReplyDelete
  127. This comment has been removed by a blog administrator.

    ReplyDelete
  128. This comment has been removed by a blog administrator.

    ReplyDelete
  129. This comment has been removed by a blog administrator.

    ReplyDelete
  130. This comment has been removed by a blog administrator.

    ReplyDelete
  131. This comment has been removed by a blog administrator.

    ReplyDelete
  132. This comment has been removed by a blog administrator.

    ReplyDelete
  133. This comment has been removed by a blog administrator.

    ReplyDelete
  134. This comment has been removed by a blog administrator.

    ReplyDelete
  135. This comment has been removed by a blog administrator.

    ReplyDelete
  136. This comment has been removed by a blog administrator.

    ReplyDelete
  137. This comment has been removed by a blog administrator.

    ReplyDelete
  138. This comment has been removed by a blog administrator.

    ReplyDelete
  139. This comment has been removed by a blog administrator.

    ReplyDelete
  140. This comment has been removed by a blog administrator.

    ReplyDelete
  141. This comment has been removed by a blog administrator.

    ReplyDelete
  142. This comment has been removed by a blog administrator.

    ReplyDelete
  143. This comment has been removed by a blog administrator.

    ReplyDelete
  144. This comment has been removed by a blog administrator.

    ReplyDelete
  145. This comment has been removed by a blog administrator.

    ReplyDelete
  146. This comment has been removed by a blog administrator.

    ReplyDelete
  147. This comment has been removed by a blog administrator.

    ReplyDelete
  148. This comment has been removed by a blog administrator.

    ReplyDelete
  149. This comment has been removed by a blog administrator.

    ReplyDelete
  150. This comment has been removed by a blog administrator.

    ReplyDelete
  151. This comment has been removed by a blog administrator.

    ReplyDelete
  152. This comment has been removed by a blog administrator.

    ReplyDelete
  153. This comment has been removed by a blog administrator.

    ReplyDelete
  154. This comment has been removed by a blog administrator.

    ReplyDelete
  155. This comment has been removed by a blog administrator.

    ReplyDelete
  156. This comment has been removed by a blog administrator.

    ReplyDelete
  157. This comment has been removed by a blog administrator.

    ReplyDelete
  158. This comment has been removed by a blog administrator.

    ReplyDelete
  159. This comment has been removed by a blog administrator.

    ReplyDelete
  160. This comment has been removed by a blog administrator.

    ReplyDelete
  161. This comment has been removed by a blog administrator.

    ReplyDelete
  162. This comment has been removed by a blog administrator.

    ReplyDelete
  163. This comment has been removed by a blog administrator.

    ReplyDelete
  164. This comment has been removed by a blog administrator.

    ReplyDelete
  165. This comment has been removed by a blog administrator.

    ReplyDelete
  166. This comment has been removed by a blog administrator.

    ReplyDelete
  167. This comment has been removed by a blog administrator.

    ReplyDelete
  168. This comment has been removed by a blog administrator.

    ReplyDelete
  169. This comment has been removed by a blog administrator.

    ReplyDelete
  170. This comment has been removed by a blog administrator.

    ReplyDelete
  171. This comment has been removed by a blog administrator.

    ReplyDelete
  172. This comment has been removed by a blog administrator.

    ReplyDelete
  173. This comment has been removed by a blog administrator.

    ReplyDelete
  174. This comment has been removed by a blog administrator.

    ReplyDelete
  175. This comment has been removed by a blog administrator.

    ReplyDelete
  176. This comment has been removed by a blog administrator.

    ReplyDelete
  177. This comment has been removed by a blog administrator.

    ReplyDelete
  178. This comment has been removed by a blog administrator.

    ReplyDelete
  179. This comment has been removed by a blog administrator.

    ReplyDelete
  180. This comment has been removed by a blog administrator.

    ReplyDelete
  181. This comment has been removed by a blog administrator.

    ReplyDelete
  182. This comment has been removed by a blog administrator.

    ReplyDelete
  183. This comment has been removed by a blog administrator.

    ReplyDelete
  184. This comment has been removed by a blog administrator.

    ReplyDelete
  185. This comment has been removed by a blog administrator.

    ReplyDelete
  186. This comment has been removed by a blog administrator.

    ReplyDelete
  187. This comment has been removed by a blog administrator.

    ReplyDelete
  188. This comment has been removed by a blog administrator.

    ReplyDelete
  189. This comment has been removed by a blog administrator.

    ReplyDelete
  190. This comment has been removed by a blog administrator.

    ReplyDelete
  191. This comment has been removed by a blog administrator.

    ReplyDelete
  192. This comment has been removed by a blog administrator.

    ReplyDelete
  193. This comment has been removed by a blog administrator.

    ReplyDelete
  194. This comment has been removed by a blog administrator.

    ReplyDelete
  195. This comment has been removed by a blog administrator.

    ReplyDelete
  196. This comment has been removed by a blog administrator.

    ReplyDelete
  197. This comment has been removed by a blog administrator.

    ReplyDelete
  198. This comment has been removed by a blog administrator.

    ReplyDelete
  199. This comment has been removed by a blog administrator.

    ReplyDelete
  200. This comment has been removed by a blog administrator.

    ReplyDelete