Discussion:
[iText-questions] Reg: Conversion of byte array into PDF
Patricia Sandra Kagoo
2015-08-26 06:17:49 UTC
Permalink
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
Gunasekaran Velu
2015-08-26 06:52:00 UTC
Permalink
Hi

Refer this link

http://stackoverflow.com/questions/19455347/save-byte-array-to-file

Regards
Guna
Post by Patricia Sandra Kagoo
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
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/
http://itextpdf.com/themes/keywords.php
Patricia Sandra Kagoo
2015-08-27 06:29:48 UTC
Permalink
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 [***@imtac.com]
Sent: Wednesday, August 26, 2015 10:17 AM
To: itext-***@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
Iliadis Yannis
2015-08-27 08:58:45 UTC
Permalink
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
Post by Patricia Sandra Kagoo
Hi all,
Let me brief you my requirement.
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
------------------------------
*Sent:* Wednesday, August 26, 2015 10:17 AM
*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
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/
http://itextpdf.com/themes/keywords.php
Loading...