Originariamente inviato da andbin
Innanzitutto precisa quale API/libreria stai usando per generare il PDF. Noi non lo possiamo sapere ... e non è una cosa scontata.
Sparo .... iText?
Document document = new Document();

try {
// step 2:
// we create a writer that listens to the document
PdfWriter.getInstance(document, new FileOutputStream("C:/Documents and Settings/c102344/Desktop/Manu/file_pdf/Registrazione.pdf"));
// step 3: we open the document
document.open();
// step 4:
//qua in questo frangete aggiungiamo un immagine al nostro documento
Image jpg = Image.getInstance("C:/Documents and Settings/c102344/Desktop/Manu/Progetto/StampareFilePdf/WebContent/img/images.jpeg" );
document.add(jpg);

//paragrafo uno
Paragraph p1 = new Paragraph(new Phrase("CLIENTE", FontFactory.getFont(
FontFactory.HELVETICA, 16)));
p1.add("\n");


//parargrafo 2
Paragraph p2 = new Paragraph("",FontFactory.getFont("Verdana", 10));
Paragraph p3 = new Paragraph("",FontFactory.getFont("Verdana", 10));
p2.add("USERNAME: " + utente.getUser());
p3.setAlignment("center");
p3.add("PASSWORD: " + utente.getPsw() + " pass: " + utente.getPsw() + "\n");
Paragraph p4 = new Paragraph("",FontFactory.getFont("Verdana", 10));
p4.setAlignment("right");
p4.add("QUALIFICHE: " + utente.getQualifica() + "\n");
p4.add("ESPERIENZE: " + utente.getEsperienza() + "\n");
p4.add("INSEGNAMENTI: " + utente.getInsegnamento() + "\n");
p4.add("\n\n");
document.add(p1);
document.add(p2);
document.add(p3);
document.add(p4);

Paragraph p7 = new Paragraph("Prova Paragrafo",FontFactory.getFont(FontFactory.TIMES_I TALIC));
p7.add("\n");

Paragraph p8 = new Paragraph("",FontFactory.getFont(FontFactory.HELVE TICA,10));
p8.add("\n");
PdfPTable table = new PdfPTable(7);
PdfPCell cell = new PdfPCell(new Paragraph("ordini"));
cell.setColspan(7);

table.addCell(cell);
UtenteDAo ute = new UtenteDAo();
ArrayList list = ute.select();
for(int x=0; x < list.size(); x++){
Utente utente1 = (Utente)list.get(x);
table.addCell(utente1.getUser());
table.addCell(utente1.getPsw());
table.addCell(utente1.getQualifica());
table.addCell(utente1.getEsperienza());
table.addCell(utente1.getInsegnamento());
table.addCell(utente1.getTipo_diploma());
table.addCell(Integer.toString(utente1.getVoto())) ;

}
document.add(p7);
document.add(p8);
document.add(table);


} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
}


questo è il codice che ho fatto per costruire il mio file pdf.... è solo un esercizio semplice per capire bene come fare... solo che appunto mi chiedevo come potessi formattare il testo uno in fila all'altro....