DynamicPDF Generator for Java can output PDF documents to a file or any java.io.OutputStream object that supports writing. The draw and drawToWeb methods of the Document class handle all document output. These methods are overloaded and give many options for the output of the PDF document.
From the Servlets/JSP page call the Document's drawToWeb method and pass in the current page object along with a download file name.
[Java]
// Outputs the PDF document to the page object.
document.drawToWeb(request, response, outputStream, downloadAsFileName");
You can choose to have the document downloaded instead of being viewed in the browser.
[Java]
// Outputs the PDF document to the page object.
document.drawToWeb(request, response, outputStream, true);
Specify the file path and name for the file in the Document's draw method.
[Java]
// Outputs the PDF document to a file.
document.draw("[PhysicalPath]/MyDocument.pdf");
Specify the Stream object to receive the output in the Document's draw method.
[Java]
// Outputs the PDF document to a stream.
document.draw(stream);
When calling the draw method with no parameters, it will return the PDF data as a byte array. This is useful when storing the PDF in a database or returning it from a Web Service.
[Java]
// Outputs the PDF document to a byte array.
byte[] data;
data = document.draw();