I need to create PDF file with iText and write it directly to a MySQL database
I’m able to create the pdf with the needed data but at the moment I create a document at a certain location with a Pdfwriter.
I can then send this file it to the database as a blob with a prepared statement and then I delete the file.
Is there a better solution to do this directly?
You need to first create a PDF using itext and then you can write byte array to DB without creating file on disk.
Here is example of how you can do that, only thing is in this example shows how to send mail of PDF data created in memory and you need to write that into DB.
http://vangjee.wordpress.com/2010/11/02/how-to-create-an-in-memory-pdf-report-and-send-as-an-email-attachment-using-itext-and-java/