I forward your mail to the mailinglist.
At first sight I don't see anything wrong with it.
I see this code is part of a Servlet.
What does the result look like if you open the file
in NOTEPAD? Maybe it's plain HTML with some error
message (404, 500,...).
Quoting isac coelho <[EMAIL PROTECTED]>:
>
> Hello Bruno ,
>
> when i try open file by Adobe a get this message :
>
> There was an error opening this document. The file is damaged and
> could
> not be repaired
>
> my code is :
>
> {
> System.out.println("Creating PDF ... 1.1 ");
> Document doc = new Document();
>
> ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
> PdfWriter docWriter = null;
>
> try
> {
>
docWriter = PdfWriter.getInstance(doc, baosPDF);
>
>
doc.addAuthor(this.getClass().getName());
>
doc.addCreationDate();
>
doc.addProducer();
>
doc.addCreator(this.getClass().getName());
>
doc.addTitle("This is a title.");
>
doc.addKeywords("pdf, itext, Java, open source,
> http");
>
doc.setPageSize(PageSize.LETTER);
>
>
HeaderFooter footer = new HeaderFooter(
>
new Phrase("This is
> a footer."),
>
false);
>
doc.setFooter(footer);
>
doc.open();
>
>
>
// ************************************
>
for (int page=0; page<100; page++) {
>
>
>
doc.add(new Paragraph(
>
"This document was created
> by a class named: "
>
+
> this.getClass().getName()));
>
>
doc.add(new Paragraph("This document was
> created on " + new java.util.Date()));
>
>
String strServerInfo = ctx.getServerInfo();
>
>
if (strServerInfo != null)
>
{
>
doc.add(new Paragraph("Servlet
> engine: " + strServerInfo));
>
}
>
>
doc.add(new Paragraph("This is a multi-page
> document."));
>
> doc.newPage();
>
>
}
>
> }
> catch (Exception dex)
> {
>
baosPDF.reset();
>
throw dex;
> }
> finally
> {
>
if (doc != null)
>
{
>
doc.close();
>
}
>
if (docWriter != null)
>
{
>
docWriter.close();
>
}
> }
>
> if (baosPDF.size() < 1)
> {
>
throw new Exception(
>
"document has "
>
+ baosPDF.size()
>
+ " bytes");
> }
> return baosPDF;
>
>
> ________________________
> Isac Aguiar Coelho
>
>
--
Try this useful extra toolbar for your browser:
http://download.alexa.com/?amzn_id=itisacatalofwebp
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions