Subject: Re: [xsl] xml to pdf or word From: Cristobal Galiano Fernandez <c.galiano@xxxxx> Date: Thu, 25 Oct 2001 11:28:10 +0200 |
Hi Adam: Yes, is posible but not is a simple task. A friend send me an example of a propietary tool (proyect). I've tested in my IIS server and works at very very speed. Proyect: Generate PDF on de fly Steps a) At Design time ------------------ 1) Do the document (DMA) on Microsoft Access 2) Generate an XML file from de DMA like I attache (A VBA routine crossing object DMA do this task) Now you have a template XML based of the document in Access (DXT) 3) Built a generic XSL (XSL2PDF) for transform an DXT file but with real data (DXD) in a PDF file -The XSL2PDF must contain functions like: pdf_open_file (), pdf_begin_page () , function pdf_close (), function pdf_end_page (), pdf_creador (), pdf_setfont (), pdf_show_text (), pdf_show_text_continue(), pdf_show_boxed (), pdf_rect (), pdf_line (), pdf_open_image_file(), ... and use a PDF object constructor (ie: PDFlib) b) At Run time --------------- 4) At run time populate DXT file with real data (DXD) and use XSL2PDF Simple no! Cristóbal Galiano Fdez NB) This tool is propietary. I send you 1) A DXT file 2) A generic XSL to transform a DXT file to DXD (XSL2PDF) ___XSL2PDF don't kown the origin of the DXT file! Adam Darwin escribió: > I still don't get this. I think i'm being really > stupid, but.... > > The way I think it should work is that I have some > xml, which I translate through an xslt using the xslt > formatting objects. This is all done dynamically by a > user accessing an asp page, selecting a few options > and pressing a button. the pdf then magically pops up > on the screen. > > >From the examples I have found on the net, I can't see > how this works, as they seem to create the pdfs before > hand and not on the fly (i.e. using java compiler) > > Is what I want to do possible? > > am I just being stupid? > > all help is greatly appreciated. > > regards, > > Adam > > --- Mailer Mailer <maillistboxes@xxxxxxxxx> wrote: > > Hi Adam, > > > > I have done this kind of work, but my pdf views are > > very simple. My architecture that there will be an > > xml, which should be validated my DTD and I have > > created an xsl which will generate the PDF with that > > information. My requirement was to create an > > existing > > xml to PDF. I converted that XML to another XML and > > then finally converted to PDF. > > Please see the PDF structure first, it is a tree > > structure and suitable to be represented as XML. > > Check examples in PDFSpecs1.3 > > > > -Deep > > > > > > --- Adam Darwin <addarwin@xxxxxxxxxxx> wrote: > > > Thanks, but (and I may be missing something here) > > > these are compiled with java. I need to generate > > > the > > > pdf on the fly, so that a user selects a number of > > > options, clicks a button and the pdf opens in > > their > > > browser/computer. > > > > > > is this possible? > > > > > ____________________________________________________________ > Nokia Game is on again. > Go to http://uk.yahoo.com/nokiagame/ and join the new > all media adventure before November 3rd. > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list ------------------------------------------------------------------------------------------------- 1) A DXT file ------------------------------------------------------------------------------------ <?xml version='1.0' encoding='ISO-8859-1'?><Paginas><Pagina> <texto ID='Etiqueta27' type='100' fuente='F2' size='8' x = '38' y = '610' x1='45' y1='11' modo='0'>Id. Fiscal:</texto> <textobox ID='etiOtros' type='100' fuente='F2' size='8' x = '36' y = '468' x1='427' y1='12' modo='2'>DATOS TRIBUTARIOS</textobox> <texto ID='refOtros' type='100' fuente='F2' size='8' x = '279' y = '435' x1='87' y1='12' modo='0'>Referencia Catastral:</texto> <texto ID='objOtros' type='100' fuente='F2' size='8' x = '38' y = '452' x1='79' y1='11' modo='0'>Objeto Tributario:</texto> <texto ID='telTit' type='100' fuente='F2' size='8' x = '217' y = '500' x1='51' y1='11' modo='0'>Teléfono:</texto> <textobox ID='Etiqueta0' type='100' fuente='F2' size='10' x = '121' y = '786' x1='342' y1='14' modo='2'>DOCUMENTO DE COMPARECENCIA / JUSTIFICANTE DE REGISTRO</textobox> <texto ID='nifTit' type='100' fuente='F2' size='8' x = '38' y = '500' x1='45' y1='11' modo='0'>Id. Fiscal:</texto> <texto ID='nomTit' type='100' fuente='F2' size='8' x = '38' y = '514' x1='87' y1='12' modo='0'>Apellidos y Nombre:</texto> <textobox ID='etiTit' type='100' fuente='F2' size='8' x = '35' y = '531' x1='427' y1='12' modo='2'>TITULAR DE LA CUENTA</textobox> <texto ID='nifSP' type='100' fuente='F2' size='8' x = '38' y = '548' x1='48' y1='11' modo='0'>Id. Fiscal:</texto> <texto ID='nomSP' type='100' fuente='F2' size='8' x = '38' y = '562' x1='87' y1='11' modo='0'>Apellidos y Nombre:</texto> <textobox ID='etiDocAp' type='100' fuente='F2' size='8' x = '35' y = '361' x1='210' y1='12' modo='2'>DOCUMENTOS APORTADOS</textobox> <texto ID='Etiqueta30' type='100' fuente='F2' size='8' x = '171' y = '610' x1='42' y1='11' modo='0'>Teléfono:</texto> <textobox ID='etiDocNoAp' type='100' fuente='F2' size='8' x = '285' y = '360' x1='144' y1='11' modo='2'> DOCUMENTOS QUE SE REQUIEREN</textobox> <texto ID='Etiqueta24' type='100' fuente='F2' size='8' x = '38' y = '596' x1='45' y1='11' modo='0'>Dirección:</texto> <texto ID='nomPres' type='100' fuente='F2' size='8' x = '38' y = '624' x1='87' y1='11' modo='0'>Apellidos y Nombre:</texto> <textobox ID='Etiqueta19' type='100' fuente='F2' size='8' x = '35' y = '642' x1='427' y1='11' modo='2'>PRESENTADOR</textobox> <texto ID='Etiqueta5' type='100' fuente='F2' size='8' x = '37' y = '673' x1='83' y1='12' modo='0'>Tipo de Expediente</texto> <texto ID='Etiqueta161' type='100' fuente='F2' size='8' x = '257' y = '738' x1='59' y1='11' modo='0'>Hora de Alta</texto> <texto ID='Etiqueta104' type='100' fuente='F2' size='8' x = '123' y = '710' x1='70' y1='11' modo='0'>Oficina de Alta</texto> <texto ID='Etiqueta102' type='100' fuente='F2' size='8' x = '123' y = '752' x1='50' y1='11' modo='0'>Organismo</texto> <texto ID='Etiqueta71' type='100' fuente='F2' size='8' x = '124' y = '767' x1='59' y1='11' modo='0'>Nº Expediente</texto> <texto ID='Etiqueta68' type='100' fuente='F2' size='8' x = '123' y = '738' x1='59' y1='11' modo='0'>Fecha de alta</texto> <texto ID='Etiqueta11' type='100' fuente='F2' size='8' x = '124' y = '696' x1='76' y1='12' modo='0'>Oficina de Destino</texto> <textobox ID='etiSP' type='100' fuente='F2' size='8' x = '35' y = '579' x1='428' y1='11' modo='2'>SUJETO PASIVO</textobox> <texto ID='Etiqueta31' type='100' fuente='F1' size='8' x = '44' y = '151' x1='85' y1='15' modo='0'>Firma del presentador</texto> <textobox ID='etiDoc' type='100' fuente='F2' size='8' x = '36' y = '375' x1='427' y1='12' modo='2'>DOCUMENTOS DEL EXPEDIENTE</textobox> <texto ID='Etiqueta100' type='100' fuente='F2' size='8' x = '304' y = '610' x1='59' y1='11' modo='0'>Relación:</texto> <texto ID='ampliOtros' type='100' fuente='F2' size='8' x = '38' y = '415' x1='63' y1='35' modo='0'>Ampliación de Información</texto> <texto ID='NFijoOtros' type='100' fuente='F2' size='8' x = '279' y = '452' x1='40' y1='11' modo='0'>Nº Fijo:</texto> <texto ID='Etiqueta85' type='100' fuente='F1' size='8' x = '274' y = '82' x1='36' y1='12' modo='0'>Firmado:</texto> <texto ID='cccTit' type='100' fuente='F2' size='8' x = '38' y = '486' x1='82' y1='12' modo='0'>Nº Cuenta Bancaria:</texto> <texto ID='fechaNotOtros' type='100' fuente='F2' size='8' x = '38' y = '435' x1='116' y1='12' modo='0'>Fecha Notif. acto Recurrido</texto> <texto ID='Etiqueta84' type='100' fuente='F1' size='8' x = '271' y = '151' x1='76' y1='15' modo='0'>Firma por la Oficina:</texto> <texto ID='entTit' type='100' fuente='F2' size='8' x = '217' y = '486' x1='73' y1='11' modo='0'>Entidad/Sucursal:</texto> <texto ID='Etiqueta148' type='100' fuente='F2' size='8' x = '38' y = '659' x1='96' y1='12' modo='0'>Subtipo de Expediente</texto> <texto ID='Etiqueta16' type='100' fuente='F1' size='8' x = '47' y = '82' x1='36' y1='12' modo='0'>Firmado:</texto> <cuadro ID='cuadroAmpli' type='101' x='35' y = '428' x1='428' y1='39'/> <cuadro ID='Cuadro1' type='101' x='35' y = '686' x1='427' y1='31'/> <cuadro ID='cuadroSP' type='101' x='35' y = '575' x1='428' y1='31'/> <cuadro ID='cuadroTit' type='101' x='35' y = '527' x1='428' y1='45'/> <cuadro ID='cuadroOtros' type='101' x='35' y = '464' x1='428' y1='33'/> <cuadro ID='cuadroNoAp' type='101' x='251' y = '357' x1='213' y1='87'/> <cuadro ID='cuadroAp' type='101' x='35' y = '357' x1='211' y1='87'/> <cuadro ID='Cuadro147' type='101' x='121' y = '779' x1='342' y1='90'/> <cuadro ID='Cuadro17' type='101' x='35' y = '637' x1='428' y1='45'/> <texto ID='Texto6' type='109' fuente='F1' size='8' x = '134' y = '659' x1='323' y1='12' modo='0'>Texto6</texto> <texto ID='Texto158' type='109' fuente='F1' size='8' x = '41' y = '211' x1='419' y1='31' modo='0'>Texto158</texto> <texto ID='DIR_TIT_COMP' type='109' fuente='F1' size='8' x = '214' y = '259' x1='85' y1='12' modo='0'>DIR_TIT_COMP</texto> <texto ID='Texto20' type='109' fuente='F1' size='8' x = '129' y = '625' x1='331' y1='12' modo='0'>Texto20</texto> <texto ID='plazomax' type='109' fuente='F1' size='8' x = '41' y = '234' x1='420' y1='22' modo='0'>plazomax</texto> <texto ID='Texto23' type='109' fuente='F1' size='8' x = '87' y = '596' x1='373' y1='12' modo='0'>Texto23</texto> <texto ID='Texto4' type='109' fuente='F1' size='8' x = '134' y = '673' x1='324' y1='12' modo='0'>Texto4</texto> <texto ID='Texto2' type='109' fuente='F1' size='8' x = '163' y = '627' x1='2' y1='0' modo='0'>Texto2</texto> <textobox ID='etiTexto' type='109' fuente='F1' size='8' x = '41' y = '256' x1='418' y1='21' modo='1'>etiTexto</textobox> <texto ID='NUMERO_NUME' type='109' fuente='F1' size='8' x = '376' y = '767' x1='85' y1='12' modo='0'>NUMERO_NUME</texto> <texto ID='etiFechaAlta' type='109' fuente='F2' size='8' x = '123' y = '724' x1='164' y1='12' modo='0'>etiFechaAlta</texto> <texto ID='fechaAlta' type='109' fuente='F1' size='8' x = '291' y = '724' x1='74' y1='12' modo='0'>fechaAlta</texto> <textobox ID='Texto103' type='109' fuente='F1' size='8' x = '203' y = '710' x1='256' y1='12' modo='1'>Texto103</textobox> <textobox ID='Texto101' type='109' fuente='F2' size='8' x = '182' y = '752' x1='279' y1='12' modo='1'>Texto101</textobox> <textobox ID='Texto70' type='109' fuente='F2' size='8' x = '191' y = '767' x1='111' y1='11' modo='1'>Texto70</textobox> <textobox ID='Texto67' type='109' fuente='F1' size='8' x = '183' y = '738' x1='70' y1='12' modo='1'>Texto67</textobox> <texto ID='Texto162' type='109' fuente='F1' size='8' x = '310' y = '82' x1='155' y1='13' modo='0'>Texto162</texto> <textobox ID='Texto10' type='109' fuente='F1' size='8' x = '203' y = '696' x1='256' y1='12' modo='1'>Texto10</textobox> <texto ID='Texto160' type='109' fuente='F1' size='8' x = '319' y = '738' x1='85' y1='12' modo='0'>Texto160</texto> <texto ID='d2NoAp' type='109' fuente='F1' size='8' x = '253' y = '330' x1='205' y1='11' modo='0'>d2NoAp</texto> <texto ID='d5Ap' type='109' fuente='F1' size='8' x = '38' y = '287' x1='202' y1='12' modo='0'>d5Ap</texto> <texto ID='d4Ap' type='109' fuente='F1' size='8' x = '38' y = '301' x1='202' y1='12' modo='0'>d4Ap</texto> <texto ID='d3Ap' type='109' fuente='F1' size='8' x = '38' y = '315' x1='202' y1='11' modo='0'>d3Ap</texto> <texto ID='d2Ap' type='109' fuente='F1' size='8' x = '38' y = '330' x1='202' y1='11' modo='0'>d2Ap</texto> <texto ID='d1Ap' type='109' fuente='F1' size='8' x = '38' y = '344' x1='202' y1='12' modo='0'>d1Ap</texto> <texto ID='tcccTit' type='109' fuente='F1' size='8' x = '122' y = '486' x1='94' y1='12' modo='0'>tcccTit</texto> <texto ID='tentTit' type='109' fuente='F1' size='8' x = '293' y = '486' x1='168' y1='12' modo='0'>tentTit</texto> <texto ID='trefOtros' type='109' fuente='F1' size='8' x = '370' y = '435' x1='91' y1='12' modo='0'>trefOtros</texto> <texto ID='tobjOtros' type='109' fuente='F1' size='8' x = '120' y = '451' x1='155' y1='12' modo='0'>tobjOtros</texto> <texto ID='d6NoAp' type='109' fuente='F1' size='8' x = '253' y = '273' x1='205' y1='12' modo='0'>d6NoAp</texto> <texto ID='d5NoAp' type='109' fuente='F1' size='8' x = '253' y = '287' x1='205' y1='12' modo='0'>d5NoAp</texto> <texto ID='tfechaNotOtros' type='109' fuente='F1' size='8' x = '157' y = '435' x1='85' y1='12' modo='0'>tfechaNotOtros</texto> <texto ID='d3NoAp' type='109' fuente='F1' size='8' x = '253' y = '315' x1='205' y1='11' modo='0'>d3NoAp</texto> <texto ID='Texto26' type='109' fuente='F1' size='8' x = '87' y = '610' x1='82' y1='12' modo='0'>Texto26</texto> <texto ID='d1NoAp' type='109' fuente='F1' size='8' x = '253' y = '344' x1='205' y1='12' modo='0'>d1NoAp</texto> <texto ID='Etiqueta15' type='109' fuente='F1' size='9' x = '44' y = '167' x1='340' y1='11' modo='0'>Etiqueta15</texto> <texto ID='Texto99' type='109' fuente='F1' size='8' x = '367' y = '610' x1='94' y1='12' modo='0'>Texto99</texto> <texto ID='tnifTit' type='109' fuente='F1' size='8' x = '86' y = '500' x1='96' y1='12' modo='0'>tnifTit</texto> <texto ID='tnomTit' type='109' fuente='F1' size='8' x = '129' y = '514' x1='332' y1='12' modo='0'>tnomTit</texto> <texto ID='tampliOtros' type='109' fuente='F1' size='8' x = '104' y = '415' x1='357' y1='34' modo='0'>tampliOtros</texto> <texto ID='tnifSP' type='109' fuente='F1' size='8' x = '89' y = '548' x1='85' y1='12' modo='0'>tnifSP</texto> <texto ID='d6Ap' type='109' fuente='F1' size='8' x = '38' y = '273' x1='202' y1='12' modo='0'>d6Ap</texto> <texto ID='tnomSP' type='109' fuente='F1' size='8' x = '129' y = '562' x1='332' y1='12' modo='0'>tnomSP</texto> <texto ID='ttelTit' type='109' fuente='F1' size='8' x = '293' y = '500' x1='85' y1='12' modo='0'>ttelTit</texto> <texto ID='Texto29' type='109' fuente='F1' size='8' x = '217' y = '610' x1='85' y1='12' modo='0'>Texto29</texto> <texto ID='tNFijoOtros' type='109' fuente='F1' size='8' x = '324' y = '452' x1='85' y1='12' modo='0'>tNFijoOtros</texto> <texto ID='d4NoAp' type='109' fuente='F1' size='8' x = '253' y = '301' x1='205' y1='12' modo='0'>d4NoAp</texto> </Pagina></Paginas> 2) A generic XSL to transform a DXT file to DXD 2.1) DXT (Template) -------------------------------------------------------------- <?xml version='1.0' encoding='ISO-8859-1'?> <Paginas> <Pagina Id="Id1"> <texto ID='Etiqueta12' type='100' fuente='F1' size='16' x = '211' y = '690' x1='25' y1='19' modo='0'>A</texto> <texto ID='Etiqueta9' type='100' fuente='F1' size='8' x = '483' y = '744' x1='54' y1='11' modo='0'>CL. OPERAC.</texto> <texto ID='Etiqueta6' type='100' fuente='F1' size='8' x = '483' y = '727' x1='30' y1='11' modo='0'>SIGNO</texto> <texto ID='Etiqueta4' type='100' fuente='F1' size='8' x = '483' y = '758' x1='16' y1='11' modo='0'>Ref</texto> <texto ID='Etiqueta3' type='100' fuente='F1' size='16' x = '231' y = '755' x1='15' y1='21' modo='0'>D</texto> <texto ID='Etiqueta2' type='100' fuente='F1' size='16' x = '200' y = '752' x1='25' y1='19' modo='0'>A</texto> <cuadro ID='Cuadro10' type='101' x='202' y = '711' x1='133' y1='42'/> <cuadro ID='Cuadro1' type='101' x='225' y = '762' x1='29' y1='20'/> <cuadro ID='Cuadro0' type='101' x='197' y = '762' x1='29' y1='20'/> <linea1 ID='Línea11' type='102' x='242' y = '712' x1='0' y1='0'/> <texto ID='ClOpe' type='109' fuente='F1' size='8' x = '540' y = '744' x1='85' y1='12' modo='0'>240</texto> </Pagina> </Paginas> 2.2) XML file with Real Data (DRD) to update the DXT file ------------------------------------------------------------ <?xml version='1.0' encoding='ISO-8859-1'?> <Paginas> <Pagina Id="Id1"> <texto ID='Etiqueta12' type='104'>AModificado2</texto> <texto ID='Etiqueta6' fuente='F2'>SIGNOModificado2</texto> <texto ID='Etiqueta2' >AMod1</texto> <texto ID='ClOpe' >243</texto> </Pagina> </Paginas> 2.3) XSL File. Generate DXD using the DXT and DRD -------------------------------------------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <!-- 2001-01-15. Update-002.XSL 2000-01-15. CGF """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -Un Fichero XML (New) actualiza los nodos de otro fichero XML (Old) .Solo se actualiza el texto,no los atributos -Se recorre el nodo Old y se accede al nodo New el mismo atributo .Si se encuentra el elemento el texto Old es actualizado con el texto New -No se ha intentado realizar un proceso óptimo. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="XmlNew" select="document('XmlUpdateElem-New.xml')" /> <xsl:template match="/"> <Pagina Id="Id1"> <xsl:apply-templates select="//Paginas" /> </Pagina> </xsl:template> <xsl:template match="Pagina"> <xsl:call-template name="Copia" /> </xsl:template> <xsl:template name="Copia"> <xsl:for-each select="node()"> <!-- Para cada nodo --> <!-- Obtengo el texto New asociado al texto Old --> <xsl:variable name="New"> <xsl:call-template name="GetNew"> <!-- No funcionó sin la call (?) --> <xsl:with-param name="ID" select="@ID" /> <!-- Paso el ID --> </xsl:call-template> </xsl:variable> <!-- (New=<xsl:value-of select="$New" />) --> <xsl:choose> <xsl:when test="$New=''"> <!-- No existe entrada en New (o texto()='') --> <xsl:copy> <!-- Copio Elemento,Atributos y Texto --> <xsl:copy-of select="*|@*|text()"/> </xsl:copy> </xsl:when> <xsl:otherwise> <!-- Si existe entrada en New (o texto()='') --> <xsl:copy> <!-- Copio Elemento,Atributos --> <xsl:copy-of select="*|@*"/> <xsl:value-of select="$New" /> <!-- Copio el Texto New --> <!-- Deberia funcionar con <xsl:value-of select="$XmlNew/Paginas/Pagina/*[@ID=@ID]" /> sin la call pero no la hace correctamente --> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> <!-- Accedo por el ID --> <xsl:template name="GetNew"> <xsl:param name="ID"/> <xsl:value-of select="$XmlNew/Paginas/Pagina/*[@ID=$ID]" /> <!-- Devuelve un valor --> <!-- Si no existe el elemento en New devuelve '' --> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xml to pdf or word, Joerg Pietschmann | Thread | [xsl] reordering output (Again), Eric Smith |
[xsl] Building attributes using ano, Manos Batsis | Date | RE: [xsl] counting characters in an, Michael Kay |
Month |