Hi All,

I had help from some of the great people here on the list and so I thought I'd post a solution to reading in a PDF document, changing text on a form field and then emailing it. I used iText to deal with the pdf and ERMailer to email the document. Here is my solution:

public WOComponent modifyAndEmailPDFDocument() {
        String myDocumentName = "Template.pdf";
        try {
                ByteArrayOutputStream myOutputStream = new 
ByteArrayOutputStream();
InputStream myInputStream = WOApplication.application ().resourceManager().inputStreamForResourceNamed(myDocumentName, null, NSArray.EmptyArray);
                PdfReader reader = new PdfReader(myInputStream);
        PdfStamper stamp1 = new PdfStamper(reader, myOutputStream);
        AcroFields form1 = stamp1.getAcroFields();
form1.setField("NameOfFormField", "text to put into form field");
        stamp1.close();

                NSData content = new NSData(myOutputStream.toByteArray());
                ERJavaMail.sharedInstance().finishInitialization();
                ERMailDeliveryPlainText message = new ERMailDeliveryPlainText();
                message.setTextContent("content of email");
                message.setSubject("email subject");
message.addAttachment(new ERMailDataAttachment("myattachment.pdf", null, content));
                message.setToAddress("toemail");
                message.setFromAddress("fromemail");
                message.sendMail();     
        } catch (Exception ex) {
                System.err.println("ERROR: " + ex.getMessage());
        }
        return context().page();
}





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to