This might help, here is some java code we use to write bytes to pdf
file
public void writeFinalOutputToFile() throws IOException
{
File outputFile = File.createTempFile("temp.pdf");
InputStream is = generateFinalPDF();
boolean haveNotClosedInput = true;
boolean haveNotClosedOutput = true;
OutputStream fos = null;
try
{
fos = new BufferedOutputStream(new FileOutputStream(outputFile,
false),
FileUtil.FILE_BLOCK_SIZE);
byte buf[] = new byte[FileUtil.FILE_BLOCK_SIZE];
do
{
int len = is.read(buf);
if (len != -1)
{
fos.write(buf, 0, len);
}
else
{
haveNotClosedOutput = false;
fos.close();
haveNotClosedInput = false;
is.close();
return;
}
} while (true);
}
catch (Throwable e)
{
try
{
if (fos != null && haveNotClosedOutput)
fos.close();
}
catch (Throwable ignore)
{
}
try
{
if (haveNotClosedInput)
is.close();
}
catch (Throwable ignore)
{
}
throw new PDFGeneratorCreationException("Problem occurred in
writing to a file", e);
}
}________________________________ From: [email protected] [mailto:[email protected]] Sent: Monday, July 27, 2009 9:49 AM To: Post all your questions about iText here Subject: Re: [iText-questions] How to write a byte array response from web service to a newly created pdf file That's not an iText question.. The how to will depend on the language you are using.. Check the corresponding forums for the language in question to get your answer there.. Glen Hamel Lead Programmer / Technician Auric Networks Canada, Inc. 570 Orwell Street, Unit 1 Mississauga, Ontario L5A 3V7 Phone 905.361.7621 Fax 905.274.3912 http://www.auricnet.ca <http://www.auricnet.ca/> From: Shailendra <[email protected]> To: [email protected] Date: 07/27/2009 10:42 AM Subject: [iText-questions] How to write a byte array response from web service to a newly created pdf file ________________________________ Hi, My requirement is to call a web service method which returns a byte array. After getting the byte array from the web service response, i need to create a PDF file and set the byte array as the content of the pdf file. I'm able to create the pdf file and write content to the pdf file. However, when i open the pdf file it contains alphabets, numbers as well as special characters. I want the pdf file to contain the actual data. Could you please let me know are there any decoding formats that needs to be used to get the actual information from the byte array? It would be greatly helpful if you provide me with sample code. Thanks. -- Regards, Shailendra Chandak----------------------------------------------------------------- ------------- _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions <https://lists.sourceforge.net/lists/listinfo/itext-questions> Buy the iText book: http://www.1t3xt.com/docs/book.php <http://www.1t3xt.com/docs/book.php> Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ <http://www.1t3xt.info/examples/> You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ <http://1t3xt.info/tutorials/keywords/> Email Confidentiality Notice: The information contained in this transmission is confidential, proprietary or privileged and may be subject to protection under the law, including the Health Insurance Portability and Accountability Act (HIPAA). The message is intended for the sole use of the individual or entity to whom it is addressed. If you are not the intended recipient, you are notified that any use, distribution or copying of the message is strictly prohibited and may subject you to criminal or civil penalties. If you received this transmission in error, please contact the sender immediately by replying to this email and delete the material from any computer.
<<ATT3153941.jpg>>
------------------------------------------------------------------------------
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
