• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Read PDF, Modify and Email Solution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Read PDF, Modify and Email Solution


  • Subject: Read PDF, Modify and Email Solution
  • From: Calven Eggert <email@hidden>
  • Date: Thu, 22 Nov 2007 10:41:52 -0500

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@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Need help on 'Backtracking too far' error, when Framesets are involved...
  • Next by Date: Re: WOLips Howto? have a plist file copy to build when it's changed...
  • Previous by thread: Re: Need help on 'Backtracking too far' error, when Framesets are involved...
  • Next by thread: Deadlock - restoreSessionWithID holding on to the lock ?
  • Index(es):
    • Date
    • Thread