Hi Sandra,
Gunasekaran Velu gave you hint about saving byte arrays to file.

You can use the FileOutputStream.write(byte[]) method to save it into a
file.

Eg.

FileOutputStream fos = new FileOutputStream(path+"out.pdf");

fos.write(createReportPdfGeneration());

fos.close();


As you can see this is very trivial.


Regards

Yannis


2015-08-27 9:29 GMT+03:00 Patricia Sandra Kagoo <patric...@imtac.com>:

> Hi all,
>
>    Let me brief you my requirement.
>
> I wrote java code using itext to generate pdf and convert it into byte
> array as follows:
>
> I took simple Hello world program to generate the pdf and convert it into
> byte array
>
>
>
>  *public byte[] createReportPdfGeneration()throws DocumentException,
> IOException* {
>
>   ByteArrayOutputStream baos = new ByteArrayOutputStream();
>   try {
>        // step 1: creation of a document-object
>
>     Document document = new Document(PageSize.A4);
>
>     // step 2: CREATING WRITER
>
>    // we'll create the file in memory
>   PdfWriter writer = PdfWriter.getInstance(document, baos);
>
>   // step 3
>    document.open();
>
>    // step 4
>         document.add(new Paragraph("Hello World!"));
>
>   // step 5
>         document.close();
>
>
>    }catch (Exception e) {
>             System.out.println("error="+e);
>             e.printStackTrace();
>      }
>    return baos.toByteArray();
>   }
>
>
>
>
>
> The output of this program is a byte array. I am in need of the code in
> which i *input this byte array and get the required pdf output*. Can
> anyone help me to sort this issue as it is very urgent.
>
>
>
> Regards,
>
> Sandra
>
>
> ------------------------------
> *From:* Patricia Sandra Kagoo [patric...@imtac.com]
> *Sent:* Wednesday, August 26, 2015 10:17 AM
> *To:* itext-questions@lists.sourceforge.net
> *Subject:* [iText-questions] Reg: Conversion of byte array into PDF
>
> Hi,
>
>   My requirement is ,I have an itext generated pdf file and is converted
> into byte array to pass into my application.* I want this byte array to
> be converted again into itext pdf file* . Could you provide me with
> sample of how to do it.
>
>
>
>
>
> Thanks and Regards,
>
> Sandra
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> 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
>
------------------------------------------------------------------------------
_______________________________________________
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