Xsl:fo api fop

Soyez le premier à donner votre avis sur cette source.

Snippet vu 17 074 fois - Téléchargée 27 fois

Contenu du snippet

voila le xsl qui va avec la source de creation pdf

Source / Exemple :


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" >
  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>

  <!-- ========================= -->
  <!-- element a la racine -->
  <!-- ========================= -->
  <xsl:template match="document">
	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" background-image="url('fond.jpg')">
		<fo:layout-master-set >
			<fo:simple-page-master master-name="essai"
				page-height="29.7cm" page-width="21cm"
				margin-top="2cm" margin-bottom="2cm"
				margin-left="2cm" margin-right="2cm"
				>

				<fo:region-before extent="4.8cm"/>
				<xsl:if test="@type != 'facture'">
				<fo:region-after extent="2.4cm"/>
				</xsl:if>
				<xsl:if test="@type = 'facture'">
				<fo:region-after extent="3.2cm"/>
				</xsl:if>

        			<fo:region-body  margin-top="5.4cm"
	  						margin-bottom="2.8cm"/>
        		</fo:simple-page-master>
		</fo:layout-master-set>

   <fo:page-sequence master-reference="essai" font-family="sans-serif" font-size="8pt" text-align="center" >

	<!--========================entete===============================-->
	<fo:static-content flow-name="xsl-region-before">
		<fo:block>
			<fo:table table-layout="fixed" >
			<!-- declaration des column pour l'entete avec le logo-->
				<fo:table-column column-width="8cm" border="0"/>
				<fo:table-column column-width="9cm" border="0"/>
			<!-- corps du tableau	-->
				<fo:table-body>
			<!-- ========================= -->
  			<!-- les element de l'entete image et date   -->
 			 <!-- ========================= -->
					<fo:table-row>
						<fo:table-cell>
							<fo:block>

							</fo:block>
						</fo:table-cell>

						<fo:table-cell>
							<fo:block font-size="14pt" font-weight="bold" space-after="0.3cm">
								<xsl:if test="@type = 'devis'">
									Devis
								</xsl:if>
								<xsl:if test="@type = 'facture'">
									Facture
								</xsl:if>
								<xsl:if test="@type = 'bl'">
									Bon de livraison
								</xsl:if>

							</fo:block>
							<fo:block >
								Feuillet : <fo:page-number/> <xsl:number count="essai" format="1"/>
							</fo:block>
							<fo:block >
								Date : <xsl:value-of select="date_creation"/>
							</fo:block>
							<xsl:if test ="@type !='bl'">
							<fo:block space-after="1cm">
								<xsl:if test ="@type ='devis'">	Valable jusqu'au : </xsl:if>
								<xsl:if test ="@type ='facture'">Echeance : </xsl:if>
								<xsl:value-of select="date_validite"/>
							</fo:block>
							</xsl:if>
						</fo:table-cell>
					</fo:table-row>
				</fo:table-body>
			</fo:table>
	</fo:block>

	<fo:block>
		<fo:table table-layout="fixed">
		<!-- declaration des column pour le references-->
			<fo:table-column column-width="8cm" border="0.5pt solid black"/>
			<fo:table-column column-width="9cm" border="0.5pt solid black"/>

		<!-- declaration de l'entete des coordonnees -->
			<fo:table-header font-weight="bold" color="white" background-color="#84b6e0">
				<fo:table-row border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black">
					<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black">
						<fo:block space-after="0.2cm" space-before="0.2cm">
							Nos references
						</fo:block>
					</fo:table-cell>

					<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black">
						<fo:block space-after="0.2cm" space-before="0.2cm">
							Vos coordonnees
						</fo:block>
					</fo:table-cell>
				</fo:table-row>
			</fo:table-header>

		<!-- corps du tableau	-->
			<fo:table-body>
			<!-- ========================= -->
  			<!-- les element du tableau de coordonnees   -->
  			<!-- ========================= -->
  				<fo:table-row>
					<fo:table-cell>
						<fo:block space-before="0.5cm">
							Client : <xsl:value-of select="client"/>
						</fo:block>
						<fo:block space-after="0.5cm">
							<xsl:if test ="@type ='bl'">Bon de livraison :</xsl:if>
							<xsl:if test ="@type ='facture'">Facture :</xsl:if>
							<xsl:if test ="@type ='devis'">Devis :</xsl:if>
							<xsl:value-of select="code"/>
						</fo:block>
					</fo:table-cell>

					<fo:table-cell>
						<fo:block space-before="0.1cm">
							<xsl:value-of select="societe"/>
							</fo:block>
						<fo:block>
		 					<xsl:value-of select="contact"/>
							</fo:block>
						<fo:block>
							<xsl:value-of select="adresse"/>
							</fo:block>
						<fo:block space-after="0.1cm">
		 					<xsl:value-of select="cp"/>   <xsl:value-of select="ville"/>
							</fo:block>
					</fo:table-cell>
				</fo:table-row>
			</fo:table-body>
		</fo:table>
	</fo:block>
</fo:static-content>

		<!--==============bas de page=======================-->
			 <xsl:if test="@type !='bl'">
			<fo:static-content flow-name="xsl-region-after">
				<fo:block>
					<fo:table table-layout="fixed" >
						<!-- declaration des column pour l'entete avec le logo-->
						<fo:table-column column-width="4cm" border="0.5pt solid black"/>
						<fo:table-column column-width="4cm" border="0.5pt solid black"/>
						<fo:table-column column-width="4cm" border="0.5pt solid black"/>
						<fo:table-column column-width="5cm" border="0.5pt solid black"/>
					<!-- corps du tableau	-->
						<fo:table-body>
							<fo:table-row>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
								border-right="0.5pt solid black" border-left="0.5pt solid black" 											color="white" background-color="#84b6e0">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										Paiement
									</fo:block>
								</fo:table-cell>

								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										<xsl:value-of select="paiement"/>
									</fo:block>
								</fo:table-cell>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black"
										color="white" background-color="#84b6e0">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										Total HT
									</fo:block>
								</fo:table-cell>

								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										<xsl:value-of select="doc_ht"/> ?
									</fo:block>
								</fo:table-cell>
							</fo:table-row>

							<fo:table-row>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" >
									<fo:block space-after="0.2cm" space-before="0.2cm">

									</fo:block>
								</fo:table-cell>

								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											 border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">

									</fo:block>
								</fo:table-cell>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black"
											color="white" background-color="#84b6e0">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										Total TVA
									</fo:block>
								</fo:table-cell>

								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										<xsl:value-of select="doc_tva"/> ?
									</fo:block>
								</fo:table-cell>
							</fo:table-row>

							<fo:table-row>
								<xsl:if test="@type = 'devis'">
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black"
											color="white" background-color="#84b6e0">
									<fo:block space-after="0.2cm" space-before="0.2cm">
											Accompte

									</fo:block>
								</fo:table-cell>

								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">

											<xsl:value-of select="accompte"/> ?

									</fo:block>
								</fo:table-cell>
								</xsl:if>
								<xsl:if test="@type = 'facture'">
									<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">
									</fo:block>
								</fo:table-cell>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">
									</fo:block>
								</fo:table-cell>
								</xsl:if>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black"
											color="white" background-color="#84b6e0">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										Total TTC
									</fo:block>
								</fo:table-cell>

								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										<xsl:value-of select="doc_ttc"/> ?
									</fo:block>
								</fo:table-cell>
							</fo:table-row>

							<xsl:if test="@type = 'facture'">
							<fo:table-row>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black"
											color="white" background-color="#84b6e0">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										Accompte
									</fo:block>
								</fo:table-cell>

								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										<xsl:value-of select="accompte"/> ?
									</fo:block>
								</fo:table-cell>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black"
											color="white" background-color="#84b6e0">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										Net a payer
									</fo:block>
								</fo:table-cell>

								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
											border-right="0.5pt solid black" border-left="0.5pt solid black">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										<xsl:value-of select="netpayer"/> ?
									</fo:block>
								</fo:table-cell>
							</fo:table-row>
							</xsl:if>

						</fo:table-body>
					</fo:table>
				</fo:block>
			</fo:static-content>
			</xsl:if>
			<xsl:if test="@type ='bl'">
			<fo:static-content flow-name="xsl-region-after">
				<fo:block>
					<fo:table table-layout="fixed" >
						<!-- declaration des column pour l'entete avec le logo-->
						<fo:table-column column-width="4cm" border="0.5pt solid black"/>
						<fo:table-column column-width="4cm" border="0.5pt solid black"/>
						<fo:table-column column-width="4cm" border="0.5pt solid black"/>
						<fo:table-column column-width="5cm" border="0.5pt solid black"/>
					<!-- corps du tableau	-->
						<fo:table-body>
							<fo:table-row>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
								border-right="0.5pt solid black" border-left="0.5pt solid black" 											color="white" background-color="#84b6e0" number-rows-spanned="3">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										Signature et cachet du client
									</fo:block>
								</fo:table-cell>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
								border-right="0.5pt solid black" border-left="0.5pt solid black" 											color="white" number-rows-spanned="3">
									<fo:block space-after="0.2cm" space-before="0.2cm">

									</fo:block>
								</fo:table-cell>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
								border-right="0.5pt solid black" border-left="0.5pt solid black" 											color="white" background-color="#84b6e0" number-rows-spanned="3">
									<fo:block space-after="0.2cm" space-before="0.2cm">
										Signature de l intervenant
									</fo:block>
								</fo:table-cell>
								<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
								border-right="0.5pt solid black" border-left="0.5pt solid black" 											color="white" number-rows-spanned="3">
									<fo:block space-after="0.2cm" space-before="0.2cm">

									</fo:block>
								</fo:table-cell>
							</fo:table-row>
						</fo:table-body>
					</fo:table>
				</fo:block>
			</fo:static-content>
			</xsl:if>

		<!--=================================partie principale===============-->
			<fo:flow flow-name="xsl-region-body">
				<fo:block >
            				<fo:table table-layout="fixed">
	    				<!-- declaration des colonnes  -->
             				 	<fo:table-column column-width="2cm" border="0.5pt solid black"/>
             				 	<fo:table-column column-width="9cm" border="0.5pt solid black"/>
              					<fo:table-column column-width="1cm" border="0.5pt solid black"/>
	      					<fo:table-column column-width="2cm" border="0.5pt solid black"/>
              					<fo:table-column column-width="2cm" border="0.5pt solid black"/>
              					<fo:table-column column-width="1cm" border="0.5pt solid black"/>

						<!-- declaration de l'entete des donees -->
						<fo:table-header font-weight="bold" color="white" background-color="#84b6e0">
						<fo:table-row >
							<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black" >
								<fo:block space-after="0.2cm" space-before="0.2cm">
									Reference
								</fo:block>
							</fo:table-cell>

							<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black" >
								<fo:block space-after="0.2cm" space-before="0.2cm">
									Designation
								</fo:block >
							</fo:table-cell>

							<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black" >
								<fo:block space-after="0.2cm" space-before="0.2cm">
									Q
								</fo:block>
							</fo:table-cell>

							<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black" >
								<fo:block space-after="0.2cm" space-before="0.2cm">
									PU ? HT
								</fo:block>
							</fo:table-cell>

							<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black" >
								<fo:block space-after="0.2cm" space-before="0.2cm">
									Total ? HT
								</fo:block>
							</fo:table-cell>

							<fo:table-cell border-bottom="0.5pt solid black" border-top="0.5pt solid black"
									border-right="0.5pt solid black" border-left="0.5pt solid black" >
								<fo:block space-after="0.2cm" space-before="0.2cm">
									TVA
								</fo:block>
							</fo:table-cell>
						</fo:table-row>
					</fo:table-header>

						<fo:table-body>
                					<xsl:apply-templates/>
              					</fo:table-body>

            				</fo:table>
          			</fo:block>
       			 </fo:flow>

		</fo:page-sequence>

	</fo:root>
  </xsl:template>

 <!-- ========================= -->
  <!-- les element ligne   -->
  <!-- ========================= -->
  <xsl:template match="ligne">
    <fo:table-row keep-together="always" >

<!-- cellule reference -->
      <fo:table-cell >
        <fo:block space-after="0.5cm" space-before.minimum="0.5cm"
	space-before.maximum="1.6cm" space-before.optimum="0.5cm">
          <xsl:value-of select="ref"/>
        </fo:block>
      </fo:table-cell>

      <!-- cellule description -->
      <fo:table-cell  >
        <fo:block space-after="0.5cm"  space-before="0.5cm"
			start-indent.minimum="0.2cm" end-indent.minimun="0.2cm">

<xsl:if test=" @id=160"><fo:block><fo:inline color="rgb(0, 51, 204)"><fo:inline font-family="wingdings">Loic</fo:inline> <fo:inline font-size="18pt" font-family="impact"><fo:inline font-weight="bold">LEPLOMB</fo:inline></fo:inline></fo:inline></fo:block><fo:block ><fo:inline text-decoration="underline" font-family="georgia,times new roman,times,serif">Moislains</fo:inline></fo:block><fo:block ><fo:inline text-decoration="line-through" font-family="tahoma,arial,helvetica,sans-serif" background-color="rgb(255, 0, 0)">Rouen</fo:inline></fo:block><fo:block >E=mc<fo:inline baseline-shift="super" font-size=".75em">2</fo:inline></fo:block><fo:block >E<fo:inline baseline-shift="sub">3</fo:inline></fo:block><fo:block >^M ^M ^M </fo:block></xsl:if><xsl:if test=" @id=161"><fo:block> </fo:block></xsl:if><xsl:if test=" @id=162"><fo:block> </fo:block></xsl:if>

        </fo:block>
      </fo:table-cell>

      <!-- cellule quantite -->
      <fo:table-cell>
        <fo:block space-after="0.5cm" space-before.minimum="0.5cm"
	space-before.maximum="1.6cm" space-before.optimum="0.5cm">
          <xsl:value-of select="quantite"/>
        </fo:block>
      </fo:table-cell>

      <!-- cellule pu_ht -->
      <fo:table-cell>
        <fo:block space-after="0.5cm" space-before.minimum="0.5cm"
	space-before.maximum="1.6cm" space-before.optimum="0.5cm">
          <xsl:value-of select="pu_ht"/>
        </fo:block>
      </fo:table-cell>

      <!-- cellule total_ht   -->
      <fo:table-cell>
        <fo:block space-after="0.5cm" space-before.minimum="0.5cm"
	space-before.maximum="1.6cm" space-before.optimum="0.5cm">
          <xsl:value-of select="total_ht"/>
        </fo:block>
      </fo:table-cell>

      <!-- cellule tva -->
      <fo:table-cell>
        <fo:block space-after="0.5cm" space-before.minimum="0.5cm"
	space-before.maximum="1.6cm" space-before.optimum="0.5cm">
          <xsl:value-of select="tva"/>
        </fo:block>
      </fo:table-cell>

    </fo:table-row>
  </xsl:template>

</xsl:stylesheet>

A voir également

Ajouter un commentaire

Commentaires

cs_dragon
Messages postés
2336
Date d'inscription
samedi 14 juillet 2001
Statut
Membre
Dernière intervention
5 mai 2009
3 -
sous jbuilder, tu as de jolie option XML vers DB ou DB vers XML, ... et compagnie
alex1er
Messages postés
39
Date d'inscription
jeudi 11 avril 2002
Statut
Membre
Dernière intervention
5 juin 2006
-
Encore faut il posseder JBuilder!!!

Merci pour le xsl lolofx.
cs_dragon
Messages postés
2336
Date d'inscription
samedi 14 juillet 2001
Statut
Membre
Dernière intervention
5 mai 2009
3 -
exact, surtout je crois que seulement la version pro possède ces options débloqué
vinsttc
Messages postés
1
Date d'inscription
vendredi 12 mars 2004
Statut
Membre
Dernière intervention
12 mars 2004
-
Une question avant m attaquer a FOP.

Est ce que la conversion de xml vers pdf conserve les liens hypertext et autres?
spécialement ceux qui sont imbriqués dans une portion d'image

Merci à tous ceux qui pourront me renseigner.

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.