Hi All,

I am trying to email the PDF that I just created and  I am lost now as to
how to proceed.

 I am merging the PDFs and then writing it to a file. This newly created
file needs to be emailed,
if the merged.pdf page count is more than 20 pages.  here is the two piece
of code one for merging and one for email. Any input would be appreciated.. 


 OutputStream out = new FileOutputStream(new File("merged.pdf"));
        Document document = new Document();
        
        //PdfWriter writer = PdfWriter.getInstance(document, outputStream);
        PdfCopy copy = new PdfCopy(document, out);
         document.open(); 
 
 for (String in : files) {
            PdfReader reader = new PdfReader(in); 
              for (int i = 1; i <= reader.getNumberOfPages(); ++i) {
                 document.newPage();
                  
                 copy.addPage(copy.getImportedPage(reader,  i));

demo.email(out); //calling email part


email :

Session session = Session.getInstance( properties, null);
                Transport transport = session.getTransport();
 
        ByteArrayOutputStream outputStream = null;
         
        try {           
            //construct the text body part
            MimeBodyPart textBodyPart = new MimeBodyPart();
            textBodyPart.setText(content);
             
            
            //now write the PDF content to the output stream
            outputStream = new ByteArrayOutputStream();
           
            byte[] bytes =   out ;// outputStream.toByteArray(); -- can't
seem can do this
             ByteArrayInputStream(out.getBuf(), 0, out.getCount());             
           
            //construct the pdf body part
            DataSource dataSource = new ByteArrayDataSource(bytes,
"application/pdf");
            MimeBodyPart pdfBodyPart = new MimeBodyPart();
            pdfBodyPart.setDataHandler(new DataHandler(dataSource));
            pdfBodyPart.setFileName("); // need this?

 Thanks



--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Email-created-PDF-tp4659256.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to