Populate .PDF with a .mrt template Java

Stimulsoft Reports.JAVA discussion
Post Reply
LuisRamirez-
Posts: 5
Joined: Tue Aug 11, 2020 5:37 pm

Populate .PDF with a .mrt template Java

Post by LuisRamirez- »

Hello, i'm starting a project using Stimulsoft and i'm trying to use it on a webservice that will receive an XML and a MRT to generate a PDF wich the user will receive as a Base64 String. I'm using Java, and i want to make an .mrt template (Just the template, i don't want an .mrt with pre-loaded info), based on the info from an XML to map the nodes from it. Then, when i have the .mrt template with nodes mapped apply it to multiple other XML which share the same nodes/structure (Names on the nodes) to populate a report and export it to a .PDF. I have seen the already existing documentation, but i don't find something that describes what i want to do or if it's even supported.

For now Stimulsoft works as spected using the assets from the demo and the demo project, but when i create my own .mrt using my own .XML with the desktop software, (Which i have to edit once i generate it before use it, because the .mrt tries to reference the pathData .XML that i used to generate the report template and generates a Null Pointer Exception as the resource file doesn't exists in the program path) the only way i can populate the report is through the desktop Stimulsoft tool, otherwise i get an empty report when i try to map it on code once i run the program . i'll post my project as an attachment (Is my debugging code, which i took from the demo projects).

Something that i think might be causing this problem, is the format of the .XML i use (The part that contains "cfdi:" on nodes seems to cause problems when reading the .XML):

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3"
    xmlns:cce11="http://www.sat.gob.mx/CE" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Certificado="AAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCDDDDDDDDDDDD" Fecha="2019-01-28T18:56:07" Folio="115" FormaPago="01" LugarExpedicion="83630" MetodoPago="PUE" Moneda="MXN" NoCertificado="00000000000000000001" Sello="AAAAAAAAABBBBBBBBBBBCCCCCCCCCCCDDDDDDDDDDDDDDEEEEEEEEEEEEFFFFFF" SubTotal="0.80" TipoDeComprobante="I" Total="0.93" Version="3.3" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd">
    <cfdi:Emisor Nombre="JOHN DOE" RegimenFiscal="123" Rfc="XAXX010101000"/>
    <cfdi:Receptor Nombre="PUBLICO GENERAL" NumRegIdTrib="123456789" ResidenciaFiscal="USA" Rfc="XAXX010101000" UsoCFDI="P01"/>
    <cfdi:Conceptos>
        <cfdi:Concepto Cantidad="1.0" ClaveProdServ="00000001" ClaveUnidad="E48" Descripcion="Bread" Importe="0.80" NoIdentificacion="P01" Unidad="1" ValorUnitario="0.8">
            <cfdi:Impuestos>
                <cfdi:Traslados>
                    <cfdi:Traslado Base="0.80" Importe="0.13" Impuesto="002" TasaOCuota="0.160000" TipoFactor="Tasa"/>
                </cfdi:Traslados>
            </cfdi:Impuestos>
        </cfdi:Concepto>
    </cfdi:Conceptos>
    <cfdi:Impuestos TotalImpuestosTrasladados="0.13">
        <cfdi:Traslados>
            <cfdi:Traslado Importe="0.13" Impuesto="002" TasaOCuota="0.160000" TipoFactor="Tasa"/>
        </cfdi:Traslados>
    </cfdi:Impuestos>
    <cfdi:Complemento>
        <cce11:ComercioExterior CertificadoOrigen="0" ClaveDePedimento="A1" Incoterm="ABC" Subdivision="0" TipoCambioUSD="19.04" TipoOperacion="2" TotalUSD="0.04" Version="1.1">
            <cce11:Emisor Curp="XAXX010101000">
                <cce11:Domicilio Calle="Street" CodigoPostal="83630" Estado="SON" Localidad="07" Municipio="030" NumeroExterior="21" Pais="MEX"/>
            </cce11:Emisor>
            <cce11:Receptor>
                <cce11:Domicilio Calle="Street" CodigoPostal="83630" Estado="SON" Localidad="07" Municipio="030" NumeroExterior="21" Pais="MEX"/>
            </cce11:Receptor>
            <cce11:Mercancias>
                <cce11:Mercancia CantidadAduana="1.000" FraccionArancelaria="00000001" NoIdentificacion="P01" UnidadAduana="07" ValorDolares="0.04" ValorUnitarioAduana="0.04"/>
            </cce11:Mercancias>
        </cce11:ComercioExterior>
        <tfd:TimbreFiscalDigital FechaTimbrado="2019-01-28T19:56:07" NoCertificadoSAT="00000000000000000001" RfcProvCertif="XAXX010101000" SelloCFD="AAAAAAAABBBBBBBBBBBBCCCCCCCCCCDDDDDDDDDDDDDD" SelloSAT="AAAAAABBBBBBBBCCCCCCCCCDDDDDDDDDD" UUID="AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE" Version="1.1" xsi:schemaLocation="http://genericurl/tomy.xsd"
            xmlns:tfd="http://www.sat.gob.mx/TFD"/>
    </cfdi:Complemento>
</cfdi:Comprobante>
Already checked:
viewtopic.php?f=19&t=58631&sid=d78256f2 ... 0734585d99
viewtopic.php?f=19&t=40003
viewtopic.php?f=19&t=56568
viewtopic.php?t=55555
https://www.stimulsoft.com/en/samples/j ... e-designer
https://www.stimulsoft.com/en/samples/j ... -from-code
https://www.stimulsoft.com/en/samples/j ... t-creation
Vadim
Posts: 362
Joined: Tue Apr 23, 2013 11:23 am

Re: Populate .PDF with a .mrt template Java

Post by Vadim »

Hello.

You can use Java Web Designer to create report templates
https://www.stimulsoft.com/en/samples/j ... b-designer
LuisRamirez-
Posts: 5
Joined: Tue Aug 11, 2020 5:37 pm

Re: Populate .PDF with a .mrt template Java

Post by LuisRamirez- »

Vadim wrote: Wed Aug 26, 2020 12:22 pm Hello.

You can use Java Web Designer to create report templates
https://www.stimulsoft.com/en/samples/j ... b-designer
There is no other way to fix my project?

While working with Stimulsoft i faced some problems with .XML containing colons ":" on nodes: Are there any known issues with Stimulsoft with files containing this?

As an alternative, i'm trying to figure out how that web designer project works, but in order to do that i have to run that project, but as it's and Eclipse project i can't make that project run on the IDE's i work with (IntelliJ and NetBeans): The projects you guys offer are only runnable on Eclipse or they can be adapted? (I can't use Eclipse because i want to attach this to other projects i work with that are really big and already running on those IDE)
Vadim
Posts: 362
Joined: Tue Apr 23, 2013 11:23 am

Re: Populate .PDF with a .mrt template Java

Post by Vadim »

Hello.

You can create your own project in IntelliJ and NetBeans similarly as for Eclipse by this tutorial https://www.stimulsoft.com/en/samples/j ... b-designer
Post Reply