Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
for(int i-=0; i<firstitems.size();>{
    table.addCell(String.valueOf(firstItems.get(z)));
    document.add(table);
    document.close();
    response.addHeader("Content-Disposition", "attachment; filename="test.pdf");
    OutputStream out = response.getOutputStream();
    baos.writeTo(out);
    out.flush();
}


Hi I got an error stating the document has been closed. You can't add any Elements.
Posted
Updated 12-Nov-14 5:43am
v3
Comments
Sergey Alexandrovich Kryukov 12-Nov-14 11:12am    
Not clear. Are you really writing "document.close();" and then asking why it's closed?! :-)
Not a question, anyway.
—SA

1 solution

What could possibly unclear in the error "stating the document has been closed", if you explicitly close it yourself?

Moreover, you close the document in loop. You add something, close it, do something else inside the loop. On second iteration, you try to add to a closed document.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900