ciao a tutti.. ho un'applicazione ke mi crea un file pdf con varie voci tipo nome: , cognome: ...... come un form. il mio problema è riempire il form... uso il package iText ke ho visto è già stato citato in questo forum. Questo è il codice x creare il file:
così mi crea il file pdf correttamente. Quando lo voglio riempire mi crea un altro file (e fin qui ok) ke xò è identico all'altro, quindi non riempito... posto il codice anke del metodo x il riempimento:codice:Document document = new Document(); // setto i margini del documento document.setMargins(50,50,20,10); boolean errore = false; try { // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.getInstance(document, new FileOutputStream("Scheda.pdf")); // step 3: we open the document document.open(); // step 4: we add a paragraph to the document Image im = Image.getInstance("logojpeg.jpg"); document.add(im); document.add(new Paragraph("Numero scheda: ",FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); document.add(new Paragraph("Data: ",FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); document.add(new Paragraph("Codice cliente: ",FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); document.add(new Paragraph("Nome: ",FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); document.add(new Paragraph("Cognome: ",FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); //ECCETERA ECCETERA..... } catch (DocumentException de) { errore = true; } catch (IOException ioe) { errore = true; } if(errore==true){ throw new Exception(); } // step 5: we close the document document.close();
il problema sembra essere il fatto che non riconosce il nome del field... bohcodice:PdfReader reader = new PdfReader("Scheda.pdf"); int n = reader.getNumberOfPages(); // filling in the form PdfStamper stamp1 = new PdfStamper(reader, new FileOutputStream("SchedaPiena.pdf")); AcroFields form1 = stamp1.getAcroFields(); form1.setField("Numero scheda", numeroSchT.getText(), numeroSchT.getText()); form1.setField("Data", dat); form1.setField("Codice cliente", codiceT.getText()); form1.setField("Nome", nomeT.getText()); form1.setField("Cognome", cognT.getText()); //ECCETERA ECCETERA... stamp1.close();![]()
![]()
![]()
Se qualcuno conosce questo package e vuole aiutarmi gliene sarei grato...vanno bene anke metodi alternativi a questo package, basta ke mi permettano di riempire il form... grazie
ciao![]()


Rispondi quotando