any further advise on this please? Thankx and Regards Vik Founder http://www.sakshum.org http://blog.sakshum.org
On Wed, May 18, 2011 at 12:03 PM, Vik <[email protected]> wrote: > Hie > > Even below code fails for the same exception > > ByteArrayOutputStream out = new ByteArrayOutputStream(); > PDF pdf; > try { > pdf = new PDF(out); > log.info("#1"); > pdf.setTitle("Using TextColumn and Paragraph classes"); > pdf.setSubject("Examples"); > pdf.setAuthor("Innovatics Inc."); > log.info("#2"); > > Page page = new Page(pdf, Letter.PORTRAIT); > pdf.flush(); > > Multipart mp = new MimeMultipart(); > MimeBodyPart htmlPart = new MimeBodyPart(); > htmlPart.setFileName("whatever.pdf"); > log.info("#7"); > htmlPart.setContent(out.toByteArray(), "application/pdf"); > mp.addBodyPart(htmlPart); > log.info("#8"); > Properties props = new Properties(); > Session session = Session.getDefaultInstance(props, null); > > Message msg = new MimeMessage(session); > msg.setContent(mp); > msg.setFrom(new InternetAddress("[email protected]")); > msg.addRecipient(Message.RecipientType.TO, > new InternetAddress("[email protected]")); > > > msg.setSubject("testing PDF system"); > Transport.send(msg); > Thankx and Regards > > Vik > Founder > http://www.sakshum.org > http://blog.sakshum.org > > > On Wed, May 18, 2011 at 10:25 AM, Stephen Johnson > <[email protected]>wrote: > >> Try not adding the image or the font. Just try to get as simple a PDF >> working as possible. >> >> On Tue, May 17, 2011 at 9:47 PM, Vik <[email protected]> wrote: >> > Hie >> > I am doing exact same. Here is the code: >> > log.info("start of PDFTest:::::::::::::"); >> > //OutputStream out = resp.getOutputStream(); >> > ByteArrayOutputStream out = new ByteArrayOutputStream(); >> > PDF pdf; >> > try { >> > pdf = new PDF(out); >> > log.info("#1"); >> > pdf.setTitle("Using TextColumn and Paragraph classes"); >> > pdf.setSubject("Examples"); >> > pdf.setAuthor("Innovatics Inc."); >> > log.info("#2"); >> > String fileName = "images/share_facebook.png"; >> > Image image1 = new Image(pdf, new BufferedInputStream( >> > getClass().getResourceAsStream(fileName)), >> ImageType.PNG); >> > log.info("#3"); >> > Font f1 = new Font(pdf, >> > new BufferedInputStream(getClass().getResourceAsStream( >> > "fonts/DroidFonts/DroidSerif-Regular.otf")), >> > CodePage.UNICODE, >> > Embed.YES); >> > >> > Page page = new Page(pdf, Letter.PORTRAIT); >> > f1.setSize(10); >> > image1.setPosition(90, 35); >> > image1.scaleBy(0.75); >> > image1.drawOn(page); >> > TextColumn column = new TextColumn(f1); >> > column.setLineBetweenParagraphs(false); >> > Paragraph p1 = new Paragraph(); >> > p1.setAlignment(Align.CENTER); >> > p1.add(new TextLine(f1, "Switzerland")); >> > Paragraph p2 = new Paragraph(); >> > p2.add(new TextLine(f1, "Introduction")); >> > >> > Paragraph p4 = new Paragraph(); >> > p4.add(new TextLine(f1, "Economy")); >> > Paragraph p5 = new Paragraph(); >> > p5.setAlignment(Align.JUSTIFY); >> > text = new TextLine(f1); >> > >> > column.setSize(470, 100); >> > Point point1 = new Point(90, 300); // TextColumn start point >> > Point point2 = column.sizeOn(page); // TextColumn end point >> > Line line = new Line( >> > point1.getX(), >> > point1.getY() + point2.getY(), >> > point1.getX() + point2.getX(), >> > point1.getY() + point2.getY()); >> > line.drawOn(page); >> > column.drawOn(page); >> > >> > pdf.flush(); >> > >> > >> > Multipart mp = new MimeMultipart(); >> > MimeBodyPart htmlPart = new MimeBodyPart(); >> > htmlPart.setFileName("whatever.pdf"); >> > log.info("#7"); >> > htmlPart.setContent(out.toByteArray(), "application/pdf"); >> > mp.addBodyPart(htmlPart); >> > log.info("#8"); >> > Properties props = new Properties(); >> > Session session = Session.getDefaultInstance(props, null); >> > Message msg = new MimeMessage(session); >> > msg.setContent(mp); >> > msg.setFrom(new InternetAddress("[email protected]")); >> > msg.addRecipient(Message.RecipientType.TO, >> > new InternetAddress("[email protected]")); >> > >> > >> > msg.setSubject("testing PDF system"); >> > Transport.send(msg); >> > System.out.println("Sucessfully Sent mail to All Users"); >> > Thankx and Regards >> > >> > Vik >> > Founder >> > http://www.sakshum.org >> > http://blog.sakshum.org >> > >> > >> > On Tue, May 17, 2011 at 9:30 PM, Stephen Johnson < >> [email protected]> >> > wrote: >> >> >> >> Vik, >> >> Post your code where you're creating the ByteArrayOutputStream and >> >> creating the PDF with it. It'll be more helpful then what you've >> >> posted. I'm a little concerned you still don't have this part correct >> >> since you're still using "out" as a variable name. You're code should >> >> be similar to: >> >> >> >> ByteArrayOutputStream baos = new ByteArrayOutputStream(); >> >> >> >> /* this part is from your previous email. I don't use PDFJet so I >> >> can't validate this code for you */ >> >> PDF pdf = new PDF(baos); >> >> some actual writing..... >> >> pdf.flush(); >> >> >> >> /* taken from docs */ >> >> Properties props = new Properties(); >> >> Session session = Session.getDefaultInstance(props, null); >> >> >> >> String msgBody = "..."; >> >> >> >> try { >> >> Message msg = new MimeMessage(session); >> >> msg.setFrom(new InternetAddress("[email protected]", >> >> "Example.com Admin")); >> >> msg.addRecipient(Message.RecipientType.TO, >> >> new InternetAddress("[email protected]", >> >> "Mr. User")); >> >> msg.setSubject("Your Example.com account has been >> activated"); >> >> msg.setText(msgBody); >> >> >> >> Multipart mp = new MimeMultipart(); >> >> >> >> // Get the PDF data >> >> byte[] attachmentData = baos.toByteArray(); >> >> >> >> MimeBodyPart attachment = new MimeBodyPart(); >> >> attachment.setFileName("manual.pdf"); >> >> attachment.setContent(attachmentData, "application/pdf"); >> >> mp.addBodyPart(attachment); >> >> >> >> message.setContent(mp); >> >> Transport.send(msg); >> >> >> >> } catch (AddressException e) { >> >> // .. >> >> } catch (MessagingException e) { >> >> // ... >> >> } >> >> >> >> >> >> On Tue, May 17, 2011 at 6:19 AM, Vik <[email protected]> wrote: >> >> > >> >> > I think the problem is not with pdfJet it about sending pdf as an >> >> > attachment via mail api on app engine >> >> > Thankx and Regards >> >> > >> >> > Vik >> >> > Founder >> >> > http://www.sakshum.org >> >> > http://blog.sakshum.org >> >> > >> >> > >> >> > On Tue, May 17, 2011 at 6:45 PM, Nichole <[email protected]> >> wrote: >> >> >> >> >> >> You could try iText: >> >> >> >> >> >> >> >> >> >> http://groups.google.com/group/google-appengine-java/browse_thread/thread/7dfdf19cfdd410d6/ee7024dd040ba6eb?lnk=gst&q=pdf#ee7024dd040ba6eb >> >> >> >> >> >> >> >> >> http://code.google.com/appengine/docs/java/mail/usingjavamail.html >> >> >> >> >> >> >> >> >> On May 16, 7:11 pm, Vik <[email protected]> wrote: >> >> >> > Hie >> >> >> > >> >> >> > Trying to send a pdf created using pdfJet throws the exception >> >> >> > >> >> >> > class javax.mail.SendFailedException:Send failure >> >> >> > (javax.mail.MessagingException: Converting attachment data failed) >> >> >> > >> >> >> > The code is like: >> >> >> > >> >> >> > MimeBodyPart htmlPart = new MimeBodyPart(); >> >> >> > htmlPart.setFileName("whatever.pdf"); >> >> >> > htmlPart.setContent(out.toByteArray(), >> >> >> > "application/pdf"); >> >> >> > mp.addBodyPart(htmlPart); >> >> >> > >> >> >> > logged >> >> >> > issuehttp:// >> code.google.com/p/googleappengine/issues/list?cursor=1764&upda... >> >> >> > does not seems to help. >> >> >> > >> >> >> > Please advise. >> >> >> > >> >> >> > Thankx and Regards >> >> >> > >> >> >> > Vik >> >> >> > Founderhttp://www.sakshum.orghttp://blog.sakshum.org >> >> >> > >> >> >> > >> >> >> > >> >> >> > On Sun, May 15, 2011 at 8:26 PM, Erick Fleming <[email protected]> >> >> >> > wrote: >> >> >> > > You can use ByteArrayOutputStream >> >> >> > > [1< >> http://download.oracle.com/javase/6/docs/api/java/io/ByteArrayOutputS.. >> .>], >> >> >> > > then attach that to your mail message. If you are using >> low-level >> >> >> > > api, then >> >> >> > > Attrachment >> >> >> > > [2< >> http://code.google.com/appengine/docs/java/javadoc/com/google/appengi.. >> .>] >> >> >> > > has >> >> >> > > a constructor for this. >> >> >> > >> >> >> > > [1] >> >> >> > >> >> >> > > > >> http://download.oracle.com/javase/6/docs/api/java/io/ByteArrayOutputS... >> >> >> > > [2] >> >> >> > >> >> >> > > > >> http://code.google.com/appengine/docs/java/javadoc/com/google/appengi... >> >> >> > >> >> >> > > On Sun, May 15, 2011 at 9:16 AM, Vik <[email protected]> wrote: >> >> >> > >> >> >> > >> Hie >> >> >> > >> >> >> > >> Just a little question. I am using this pdfJet thing. >> >> >> > >> The requirement for us is to create a pdf and then mail it to a >> >> >> > >> user. >> >> >> > >> >> >> > >> So i am done with pdf creation part and at then end i have the >> >> >> > >> code like: >> >> >> > >> >> >> > >> OutputStream out = resp.getOutputStream(); >> >> >> > >> PDF pdf = new PDF(out); >> >> >> > >> >> >> > >> some actual writing..... >> >> >> > >> >> >> > >> pdf.flush(); >> >> >> > >> out.close(); >> >> >> > >> >> >> > >> Now the question i have is after this step how do i actually >> get >> >> >> > >> handle to >> >> >> > >> the created pdf above and attach it to an email ? >> >> >> > >> >> >> > >> Thankx and Regards >> >> >> > >> >> >> > >> Vik >> >> >> > >> Founder >> >> >> > >>http://www.sakshum.org >> >> >> > >>http://blog.sakshum.org >> >> >> > >> >> >> > >> On Tue, Apr 20, 2010 at 1:52 PM, Patou >> >> >> > >> <[email protected]>wrote: >> >> >> > >> >> >> > >>> Hello >> >> >> > >> >> >> > >>> In App Engine, You can't write a file to the file system. >> >> >> > >>> Otherwise >> >> >> > >>> the save method can't be used in GAE. >> >> >> > >>> Use this code to send the pdf to the navigator : >> >> >> > >> >> >> > >>> pdf.wrap(); >> >> >> > >> >> >> > >>> String fileName = "Example_03.pdf"; >> >> >> > >> >> >> > >>> resp.setContentType("application/pdf"); >> >> >> > >>> resp.setHeader("Content-Disposition", "attachment; >> filename=\"" + >> >> >> > >>> fileName + "\""); >> >> >> > >>> ServletOutputStream outs = resp.getOutputStream(); >> >> >> > >>> pdf.getData().writeTo(outs); >> >> >> > >> >> >> > >>> Or to save to the datastore : >> >> >> > >>> new Blob(pdf.getData().toByteArray()); >> >> >> > >> >> >> > >>> Bests Regards >> >> >> > >> >> >> > >>> Patrice >> >> >> > >> >> >> > >>> On Apr 20, 4:18 am, jeno <[email protected]> wrote: >> >> >> > >>> > Hi François , >> >> >> > >> >> >> > >>> > Thanks for your help. I have used PDFjet (PDFJet.jar >> version >> >> >> > >>> > 2.72) >> >> >> > >>> > PDF class missing save method >> >> >> > >>> > So i cant call pdf.save("d.pdf") method. >> >> >> > >> >> >> > >>> > Cheers >> >> >> > >>> > jeno >> >> >> > >> >> >> > >>> > On Apr 19, 6:48 pm, François Masurel <[email protected]> >> wrote: >> >> >> > >> >> >> > >>> > > Hi Jeno, >> >> >> > >> >> >> > >>> > > You can try the PDFjet Open Source Edition : >> >> >> > >>>http://pdfjet.com/os/edition.html >> >> >> > >> >> >> > >>> > > François >> >> >> > >> >> >> > >>> > > On 19 avr, 01:55, jeno <[email protected]> wrote: >> >> >> > >> >> >> > >>> > > > Hi Guys, >> >> >> > >> >> >> > >>> > > > Anyone know open source java pdf engine for GAE. >> >> >> > >> >> >> > >>> > > > Thanks >> >> >> > >>> > > > Jeno >> >> >> > >> >> >> > >>> > > > -- >> >> >> > >>> > > > You received this message because you are subscribed to >> the >> >> >> > >>> > > > Google >> >> >> > >>> Groups "Google App Engine for Java" group. >> >> >> > >>> > > > To post to this group, send email to >> >> >> > >>> [email protected]. >> >> >> > >>> > > > To unsubscribe from this group, send email to >> >> >> > >>> [email protected]. >> >> >> > >>> > > > For more options, visit this group athttp:// >> >> >> > >>> groups.google.com/group/google-appengine-java?hl=en. >> >> >> > >> >> >> > >>> > > -- >> >> >> > >>> > > You received this message because you are subscribed to >> the >> >> >> > >>> > > Google >> >> >> > >>> Groups "Google App Engine for Java" group. >> >> >> > >>> > > To post to this group, send email to >> >> >> > >>> [email protected]. >> >> >> > >>> > > To unsubscribe from this group, send email to >> >> >> > >>> [email protected]. >> >> >> > >>> > > For more options, visit this group athttp:// >> >> >> > >>> groups.google.com/group/google-appengine-java?hl=en. >> >> >> > >> >> >> > >>> > -- >> >> >> > >>> > You received this message because you are subscribed to the >> >> >> > >>> > Google >> >> >> > >>> Groups "Google App Engine for Java" group. >> >> >> > >>> > To post to this group, send email to >> >> >> > >>> [email protected]. >> >> >> > >>> > To unsubscribe from this group, send email to >> >> >> > >>> [email protected]. >> >> >> > >>> > For more options, visit this group athttp:// >> >> >> > >>> groups.google.com/group/google-appengine-java?hl=en. >> >> >> > >> >> >> > >>> -- >> >> >> > >>> You received this message because you are subscribed to the >> >> >> > >>> Google Groups >> >> >> > >>> "Google App Engine for Java" group. >> >> >> > >>> To post to this group, send email to >> >> >> > >>> [email protected]. >> >> >> > >>> To unsubscribe from this group, send email to >> >> >> > >>> [email protected]. >> >> >> > >>> For more options, visit this group at >> >> >> > >>>http://groups.google.com/group/google-appengine-java?hl=en. >> >> >> > >> >> >> > >> -- >> >> >> > >> You received this message because you are subscribed to the >> Google >> >> >> > >> Groups >> >> >> > >> "Google App Engine for Java" group. >> >> >> > >> To post to this group, send email to >> >> >> > >> [email protected]. >> >> >> > >> To unsubscribe from this group, send email to >> >> >> > >> [email protected]. >> >> >> > >> For more options, visit this group at >> >> >> > >>http://groups.google.com/group/google-appengine-java?hl=en. >> >> >> > >> >> >> > > -- >> >> >> > > You received this message because you are subscribed to the >> Google >> >> >> > > Groups >> >> >> > > "Google App Engine for Java" group. >> >> >> > > To post to this group, send email to >> >> >> > > [email protected]. >> >> >> > > To unsubscribe from this group, send email to >> >> >> > > [email protected]. >> >> >> > > For more options, visit this group at >> >> >> > >http://groups.google.com/group/google-appengine-java?hl=en. >> >> >> >> >> >> -- >> >> >> You received this message because you are subscribed to the Google >> >> >> Groups "Google App Engine for Java" group. >> >> >> To post to this group, send email to >> >> >> [email protected]. >> >> >> To unsubscribe from this group, send email to >> >> >> [email protected]. >> >> >> For more options, visit this group at >> >> >> http://groups.google.com/group/google-appengine-java?hl=en. >> >> >> >> >> > >> >> > -- >> >> > You received this message because you are subscribed to the Google >> >> > Groups "Google App Engine for Java" group. >> >> > To post to this group, send email to >> >> > [email protected]. >> >> > To unsubscribe from this group, send email to >> >> > [email protected]. >> >> > For more options, visit this group at >> >> > http://groups.google.com/group/google-appengine-java?hl=en. >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups >> >> "Google App Engine for Java" group. >> >> To post to this group, send email to >> >> [email protected]. >> >> To unsubscribe from this group, send email to >> >> [email protected]. >> >> For more options, visit this group at >> >> http://groups.google.com/group/google-appengine-java?hl=en. >> >> >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Google App Engine for Java" group. >> > To post to this group, send email to >> [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group at >> > http://groups.google.com/group/google-appengine-java?hl=en. >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine for Java" group. >> To post to this group, send email to >> [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/google-appengine-java?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
