mStream.ToArray() instead of mStream.GetBuffer().
Paulo
----- Original Message -----
From: Glen Hamel
To: 'Post all your questions about iText here'
Sent: Wednesday, May 26, 2010 5:32 PM
Subject: Re: [iText-questions] Open an existing PDF instead of creating blank
Technically this is not an iText issue but as I had the time to actually
respond this time, here it is..
You're doing that all wrong...
Create the PDF in a memory stream first.
Then use the following:
(do bear in mind that this is VB code but does lend to conversion to any
other language as I've done to C# myself).
HttpContext.Current.Response.Buffer = True
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ContentType =
"application/pdf"
HttpContext.Current.Response.AddHeader("Content-Disposition",
"attachment;filename=" & usrnm & ".pdf")
HttpContext.Current.Response.BinaryWrite(mStream.GetBuffer())
HttpContext.Current.Response.End()
Glen Hamel
Auric Networks Canada, Inc.
570 Orwell Street, Unit 1
Mississauga, Ontario
L5A 3V7
Phone : 905.361.7621 x 204
Fax : 905.274.3912
Email : [email protected]
http://www.auricnet.ca
-----Original Message-----
From: QuietRiot [mailto:[email protected]]
Sent: Wednesday, May 26, 2010 12:10 PM
To: [email protected]
Subject: [iText-questions] Open an existing PDF instead of creating blank
This should be easy but I'm having a hard time with it. I'm currently doing
the following:
// START OF DOCUMENT
response.setContentType("application/pdf");
Document document = new Document();
try{
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, buffer);
document.open();
PdfFormField field = PdfFormField.createSignature(writer);
field.setWidget(new Rectangle(218, 577, 285, 589),
PdfAnnotation.HIGHLIGHT_INVERT);
field.setFieldName("mySig");
field.setFlags(PdfAnnotation.FLAGS_PRINT);
writer.addAnnotation(field);
// END OF DOCUMENT
document.close();
DataOutput dataOutput = new DataOutputStream(response.getOutputStream());
byte[] bytes = buffer.toByteArray();
response.setContentLength(bytes.length);
for(int i = 0; i < bytes.length; i++) {
dataOutput.writeByte(bytes[i]);
}
}catch(DocumentException e){
e.printStackTrace();
}
but I need to open an existing PDF at this location below and do the above.
String rootPath = System.getProperty("catalina.home");
rootPath = rootPath + File.separator + "webapps" + File.separator + "ROOT" +
File.separator;
rootPath = rootPath + "test/reportjsps/MyForm.pdf";
how would I modify the above so that it opens this existing PDF?
thanks
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/Open-an-existing-PDF-instead-of-c
reating-blank-tp2231939p2231939.html
Sent from the iText - General mailing list archive at Nabble.com.
----------------------------------------------------------------------------
--
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
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/
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.819 / Virus Database: 271.1.1/2897 - Release Date: 05/26/10
02:25:00
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
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/------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
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/