Hi Moderators,
I found your mailing lists as an awesome source to PDF generation and
manipulation. Both the books
are fantastic. I read the books and couldnt find answer for my problem and I
need your advise in identifying
the right approach to encrypt (AES256) the contents of my zip file which are
usually a pdf and a csv
generated in memory. To achieve this i am zipping the files generated in the
following procedure but i have no clue
on how to encrypt it. I need something in the form of an output stream which
i can write to the response.
Please guide me
Thanks
King Goldman

public class Zip {

    public static void main (String[] args) throws IOException,
DocumentException {
    ZipOutputStream zip = new ZipOutputStream(new
FileOutputStream("C:\\result\\zip.zip"));
    zip.setLevel(ZipOutputStream.STORED);
    getPDF(zip);
    getCSV(zip);
    zip.close();
    }

    private static void getPDF(ZipOutputStream zip) throws IOException,
DocumentException {
     ZipEntry pdfEntry = new ZipEntry("SamplePDF.pdf");
     zip.putNextEntry(pdfEntry);
     Document document = new Document();
     PdfWriter writer = PdfWriter.getInstance(document, zip);
     writer.setCloseStream(false);
     document.open();
     for (int i = 0; i < 3 ; i ++) {
        document.add(new Paragraph("Hello " + i));
     }
     document.close();
     zip.closeEntry();
     }

    private static void getCSV(ZipOutputStream zip) throws IOException {
     ZipEntry csvEntry = new ZipEntry("SampleCSV.csv");
     zip.putNextEntry(csvEntry);
     StringBuilder csvBuilder = new StringBuilder();
    csvBuilder.append("This is a Sample CSV");
     String csv = csvBuilder.toString();
     zip.write(csv.getBytes());
     zip.closeEntry();
     }
}
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

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