Hi there Rob yeah it actually work!!!! Thanks the only thing that left its
the images that has the have the pdf but it great jejeje, do you know what
can i do about that??  

Rob Sargent-4 wrote:
> 
> Not at all certain if this is your problem, but what about changing
>      Source src = new StreamSource(args[4]); //I think you have opened 
> two streams on args[4]
> to
>      Source src = new JDOMSource(jdomDocument); //Are you making 
> multiple files in that for loop?
> 
> 
> On 06/02/2011 04:43 PM, Oscar.Flores wrote:
>> Hi thanks for the quick answer Rob i do some testing with the program
>> EditiX
>> to see if the stylesheet transform the xml to the pdf that i want and it
>> does so i dont now if it is my code that is bad or something i post the
>> code
>> can you see it please later i will put the fo file
>>
>>
>> public final class Main {
>>      public static void main(String[] args) throws Exception {
>>          try {
>>
>>              File file = new File(args[0]);
>>              Comprobante comp = CFDv2.newComprobante(new
>> FileInputStream(file));
>>              CFDv2 cfd = new CFDv2(comp);
>>              PrivateKey key = KeyLoader.loadPKCS8PrivateKey(new
>> FileInputStream(args[1]),(args[2]));
>>              X509Certificate cert = KeyLoader.loadX509Certificate(new
>> FileInputStream(args[3]));
>>              Comprobante sellado = cfd.sellarComprobante(key, cert);
>>              String cadena = cfd.getCadenaOriginal();
>>              String sello = sellado.getSello();
>>              //System.out.println(sello);
>>              //System.out.println(cadena);
>>
>>              //OutputStream archivo = new
>> FileOutputStream("C:/F0008556FA.xml");
>>              //cfd.validar();
>>              //cfd.verificar();
>>              //cfd.guardar();
>>
>>              // Creamos el builder basado en SAX
>>              SAXBuilder builder = new SAXBuilder();
>>              // Construimos el arbol DOM a partir del fichero xml
>>              Document documentJDOM = builder.build(new
>> FileInputStream(args[0]));
>>
>>
>>              Element raiz = documentJDOM.getRootElement();//toma el nodo
>> raiz
>> del documento.
>>              raiz.setAttribute("sello", sello);
>>              raiz.setAttribute("certificado", sellado.getCertificado());
>>              //System.out.println(raiz.getAttributeValue("sello"));
>>              //System.out.println(raiz.getAttributeValue("certificado"));
>>              // Recorremos los hijos de la etiqueta raĆ­z
>>              List<Element>  hijosRaiz = raiz.getChildren();
>>              boolean Bandera=false;
>>              for(Element hijo: hijosRaiz)
>>              {
>>                  // Obtenemos el nombre y su contenido de tipo texto
>>                  String nombre = hijo.getName();
>>
>>                  if (nombre.equals("Addenda"))
>>                  {   List<Element>  subHijo = hijo.getChildren();
>>                      for(Element hij: subHijo)
>>                          {
>>                          hij.setAttribute("CadenaOriginal", cadena);
>>                          //System.out.println("CadenaOriginal:
>> "+hij.getAttributeValue("CadenaOriginal"));
>>                          Bandera=true;
>>                          break;
>>                          }
>>                  }
>>                  if (Bandera)
>>                  {
>>                      XMLOutputter out = new
>> XMLOutputter(Format.getPrettyFormat());
>>                      File nuevoXML = new File(args[0]);
>>                      try{
>>                          FileOutputStream archivoXML= new
>> FileOutputStream
>> (nuevoXML);
>>                          out.output(documentJDOM, archivoXML);
>>
>>                         }
>>                      catch (Exception
>> ex){System.out.println(ex.getMessage());}
>>                      // Para generar el pdf a partir de un archivo.xsl y
>> un
>>                      // archivo.xml
>>                  }
>>                }
>>            FopFactory fopFactory = FopFactory.newInstance();
>>            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
>>           File pdffile = new File(args[5]);
>>
>>           OutputStream out = new java.io.FileOutputStream(pdffile);
>>           out = new java.io.BufferedOutputStream(out);
>>           try {
>>                   Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,
>> foUserAgent, out);
>>                  TransformerFactory factory =
>> TransformerFactory.newInstance();
>>                  Transformer transformer = factory.newTransformer(new
>> StreamSource(args[4]));
>>                  transformer.setParameter("versionParam", "2.0");
>>                  Source src = new StreamSource(args[4]);
>>                  Result res = new SAXResult(fop.getDefaultHandler());
>>                  System.setProperty("java.awt.headless", "true");
>>                  transformer.transform(src, res);
>>                  } finally {
>>                   out.close();
>>              }
>>            System.out.println("Success!");
>>           } catch (Exception e) {
>>            e.printStackTrace(System.err);
>>            System.exit(-1);
>>         }
>>       }
>>    }
>>
>>
>>
>> Rob Sargent-4 wrote:
>>> Oscar,
>>>
>>> I think it might be more useful to post the fo file generated by the
>>> xslt transformation of you source xml file, often called the fo file.
>>> Given that you do get a pdf file with _some_ content, I suspect your
>>> stylesheet isn't doing what you want it to do.  This should be evident
>>> in the fo file.
>>>
>>> On 06/02/2011 03:14 PM, Oscar.Flores wrote:
>>>> Hi there i am working in a proyect with Fop and Java to tranform xml to
>>>> pdf
>>>> this with a .xls file, when i make the pdf it seems that everything is
>>>> fine
>>>> except that is empty well only makes a table and some letters but the
>>>> information its gone, the version of Fop is 1.0, xml graphics 1.5svn, i
>>>> hope
>>>> you can help me, i attach the xml and the xsl
>>>>
>>>> Thanks!!
>>>> http://old.nabble.com/file/p31761083/F_0008556FA.xml F_0008556FA.xml
>>>> http://old.nabble.com/file/p31761083/FacturasOMF.xsl FacturasOMF.xsl
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/FOP-EMPTY-PDF-tp31761083p31765581.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to