Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending mail/fax with PDF attachments in J2EE  RSS feed

 
Archanaa Panda
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I currently have to design for a requirement as follows-
1. Send report data to a middleware server from a client.
2. Middleware server formats the report data and creates PDF/RTF/plain text documents.
3. Documents need to be sent via Mail or Fax to the desired destination.

The process of creating PDF or RTF document seems pretty clear - I could use FOP or similar open source APIs for the same.

However, I have a design issue here-
There can be two ways of sending the PDF document as attachment.
a) Temporarily write the PDF document to a temporary .pdf file in the middleware server and then send the attachment using FileDataSource and DataHandler.
b) Use ByteArrayOutputStream to write the PDF document as a byte[] array in the middleware server and then send the attachment using DataHandler directly.

What are the pros and cons of each approach and which would be the preferred solution? Personally I would prefer solution 2 since there might issues in doing file I/O from EJBs, for example. Please remember that the PDF/ RTF document creation takes place in the middleware server itself. The client does not upload these documents to the server.

Regards,
Archanaa
 
Mahesh Trikannad
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this posting , while doing a search for pdf attachments.

I have the exact same predicament.

I prefer to use the ByteArrayOutputStream directly.

Iam trying to figure out, what to put in the mime type, for the second parameter to the DataHandler to get this to work correctly.

ANy ideas

Regards
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!