I´m working in something like that.

I have an servlet filter that calls a JSP page that will return an xml file
with a set of pre-defined tags. This xml file will be transformed into a fo
stream with xalan using a xsl file with the fo definition of my tags. This
fo stream will be then rendered with fop. (I hope that the English is
correct...)

I'm sending the code for the filter, the xsl that I have and a xml example
for my tags. It´s is working, but the tags are still very limited because
I´m still in the begining of the project.

I´m also working in a wysiwyg tool to create the xsl file.

Hope that helps.

Denes

----- Original Message -----
From: "Fischer Tibor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 28, 2002 11:06 AM
Subject: Re: calling fop from java


> that's ok,
> sorry but i didn't said, that i have an xml, and an xsl file, and i have
> to generate the pdf from them
>
> Fishy
>
> Alexandre Denes dos Santos wrote:
>
> >Use:
> >
> >Driver driver = new Driver(InputStream in, OutputStream out);
> >driver.setRenderer(Driver.RENDER_PDF);
> >
> >driver.run();
> >
> >where in is the inputStream to the fo file that you will render and
> >out is the outputstream where the pdf content will be write to.
> >
> >The package is org.apache.fop.apps.
> >
> >Hope that helps.
> >
> >Denes
> >
> >
> >
> >----- Original Message -----
> >From: "Fischer Tibor" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Thursday, February 28, 2002 10:50 AM
> >Subject: calling fop from java
> >
> >
> >>hi
> >>
> >>i would like to call the fop's transformation procedure from a running
> >>java application, to create pdf  realtime
> >>
> >>how is it possible??
> >>what method sholud i call??
> >>
> >>Thanks,
> >>Fishy
> >>
> >>
> >
> >
> >
> >
> >
>

Attachment: teste.fo
Description: Binary data

Attachment: FopFilter.java
Description: Binary data

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output encoding="ISO-8859-1" method="xml" indent="no"/>
<xsl:strip-space elements="*"/>

<xsl:template match="/">
   <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
      <xsl:call-template name="pageConfiguration" />
      <fo:page-sequence master-reference="first">
         <xsl:call-template name="regionBefore" />
         <xsl:call-template name="regionAfter" />
         <fo:flow flow-name="xsl-region-body">
	      <fo:block border="1px solid black">
		<fo:block >
      		Table 1: with header
	      </fo:block>
            <xsl:apply-templates/>
            </fo:block>
         </fo:flow>
      </fo:page-sequence>
   </fo:root>
</xsl:template>

<xsl:template name="pageConfiguration">
  <fo:layout-master-set>
    <fo:simple-page-master 
	margin-right="{$margin-right}"
	margin-left="{$margin-left}"
	margin-bottom="{$margin-bottom}"
	margin-top="{$margin-top}"
	page-width="{$page-width}"
	page-height="{$page-height}"
	master-name="first">
	<fo:region-body margin-top="1cm" margin-bottom="2cm" margin-left="0cm" margin-right="0cm"/> 
      <fo:region-before extent="2cm"/>
      <fo:region-after extent="1.5cm"/>
    </fo:simple-page-master>
  </fo:layout-master-set>
</xsl:template>

<xsl:template name="regionBefore">
    <fo:static-content flow-name="xsl-region-before">
      <fo:block line-height="14pt" font-size="10pt" 
		text-align="end">table examples</fo:block>
    </fo:static-content>
</xsl:template>

<xsl:template name="regionAfter" >
    <fo:static-content flow-name="xsl-region-after">
      <fo:block line-height="14pt" font-size="10pt" 
		text-align="end">Page <fo:page-number/></fo:block>
    </fo:static-content>
</xsl:template>

<xsl:template match="REPORT">
   <xsl:apply-templates/>
</xsl:template>

<xsl:template match="TABLE">
      <fo:table>
  		<fo:table-column column-width="2cm"/>
		<fo:table-column column-width="2cm"/>
		<fo:table-column column-width="2cm"/>
		<fo:table-column column-width="2cm"/>
		<fo:table-column column-width="2cm"/>
		<fo:table-column column-width="2cm"/>

		<fo:table-header>
		    <fo:table-row>
			    <fo:table-cell>
			      <fo:block font-weight="bold" text-align="center" vertical-align="middle"
				  border-width="1pt" border-color="black" background-color="#F7F24D">
				      Col.1
			      </fo:block>
			    </fo:table-cell>
			    <fo:table-cell>
			      <fo:block font-weight="bold" text-align="center" vertical-align="middle"
				  border-width="1pt" border-color="black" background-color="#F7F24D">
				      Col.2
			      </fo:block>
			    </fo:table-cell>
			    <fo:table-cell>
			      <fo:block font-weight="bold" text-align="center" vertical-align="middle"
				  border-width="1pt" border-color="black" background-color="#F7F24D">
				      Col.3
			      </fo:block>
			    </fo:table-cell>
			    <fo:table-cell>
			      <fo:block font-weight="bold" text-align="center" vertical-align="middle"
				  border-width="1pt" border-color="black" background-color="#F7F24D">
				      Col.4
			      </fo:block>
			    </fo:table-cell>
			    <fo:table-cell>
			      <fo:block font-weight="bold" text-align="center" vertical-align="middle"
				  border-width="1pt" border-color="black" background-color="#F7F24D">
				      Col.5
			      </fo:block>
			    </fo:table-cell>
			    <fo:table-cell>
			      <fo:block font-weight="bold" text-align="center" vertical-align="middle"
				  border-width="1pt" border-color="black" background-color="#F7F24D">
				      Col.6
			      </fo:block>
			    </fo:table-cell>
		     </fo:table-row>
		</fo:table-header>
		<fo:table-body>
		      <xsl:apply-templates/>
		</fo:table-body>
      </fo:table>
</xsl:template>

<xsl:template match="TR">
	<fo:table-row>
         <xsl:apply-templates />
      </fo:table-row>
</xsl:template>

<xsl:template match="TD">
      <fo:table-cell>
      <fo:block border-right-width="0.5pt" text-align="center" vertical-align="middle">
      <xsl:apply-templates/>
      </fo:block>
      </fo:table-cell>
</xsl:template>

</xsl:stylesheet>

Attachment: report.dtd
Description: Binary data

Reply via email to