Hi, 

 

Thsi is my problem:

 

I have create a pdf my adobe livecycle and I put it in a specific
folder. I have build the function 

 "copiaFileParam(String nomeFile,String pathSorge,String pathDest,String
new_nomeFile, String cordX,String cordY)"

That create a copy of my pdf setting a value field with the parameter
cordX,cordY.

 

//I compose the name of the source pdf and the pdf of destination 

  inputFile = pathS + nomeFile;

  outputFile = pathD + new_nomeFile;  

  

//get a pdf reader    

  pdfr = new PdfReader(inputFile);

  Node n =  pdfr.getAcroFields().getXfa().getDatasetsNode();

  Xml2SomDatasets som = new Xml2SomDatasets(n); 

  Set<HashMap>  map=  som.getName2Node().keySet();

  XfaForm xfa = pdfr.getAcroFields().getXfa();

 

  try

  {

  //Create a new pdf  

   stamper =  new PdfStamper(pdfr, new FileOutputStream(outputFile));  

   xfaForm = new XfaForm(stamper.getReader()); 

 //Setting the value 

   GestioneSchede.setValore(map,"ppc_cordx",xfaForm,cordX);

   GestioneSchede.setValore(map,"ppc_cordy",xfaForm,cordY);  

 //Set the datasetsSom   

   stamper.getAcroFields().getXfa().setDatasetsSom(som);

 //Set xfa

   xfaForm.setChanged(true);

   XfaForm.setXfa( XfaForm.serializeDoc(xfaForm.getDomDocument()),
stamper.getReader(), stamper.getWriter() );

   stamper.close();

   pdfr.close();

  } 

  catch (DocumentException f)

  {

   . . . . . . . . . . . 

 

 

Up to here it's all ok.

I open the pdf (and the field is populate) I can insert or modify a
value fields and save.

Then I have create another function that read all value from the pdf

 

//Questa funzione setta gli attributi della geometria prendendo i valori
dal pdf

  public static String getAttributi(String nomefile,String campo_ric)

  {

  //Dichiarazione variabili

    PdfReader    pdfr;

    Set<HashMap> map;

    XfaForm      xfa;

    String campo = "";

    String valore = "";

 

    try 

    {

    //get the pdf reader      

      pdfr = new PdfReader(nomefile);

      Node n = pdfr.getAcroFields().getXfa().getDatasetsNode();

      Xml2SomDatasets som = new Xml2SomDatasets(n);

      map = som.getName2Node().keySet();

      xfa = pdfr.getAcroFields().getXfa();   

     

     for (Iterator it2 =  map.iterator(); it2.hasNext();) 

     {

       campo = it2.next().toString();

       if (campo.indexOf(campo_ric) >= 0)

       {

        valore = xfa.getNodeText(xfa.findDatasetsNode(campo));

       } 

     } 

   }

   catch (IOException e) 

   {

      //TO DO

  }     

   return valore;

 

}

 

Node n = pdfr.getAcroFields().getXfa().getDatasetsNode(); is null why?

Why the in PdfStamper getDatasetsNode() is null what I must do?

 

Please help me

 

Thanks

 

Regards 

 

Giovanni Virdis

 

 

 

 

 

 

 

 

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to