DynamicPDF™ Generator for .NET can output PDF documents to a file, web form, byte array or any System.IO.Stream 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.
Output to an ASPX page (WebForm)
From the On_Load event of the WebForm call the Document's DrawToWeb method and pass in the current page object along with a download file name.
[Visual Basic]
' Outputs the PDF document to the page object.
MyDocument.DrawToWeb( Me, "MyDocument.pdf" )
[C#]
// Outputs the PDF document to the page object.
document.DrawToWeb( this, "MyDocument.pdf" );
You can chose to have the document downloaded instead of being viewed in the browser.
[Visual Basic]
' Outputs the PDF document to the page object.
MyDocument.DrawToWeb( Me, "MyDocument.pdf", True )
[C#]
// Outputs the PDF document to the page object.
document.DrawToWeb( this, "MyDocument.pdf", true );
Output to a file
Specify the file path and name for the file in the Document's Draw method.
[Visual Basic]
' Outputs the PDF document to a file.
MyDocument.Draw( "C:\MyDocument.pdf" )
[C#]
// Outputs the PDF document to a file.
document.Draw( @"C:\MyDocument.pdf" );
Output to a System.IO.Stream object
Specify the Stream object to receive the output in the Document's Draw method.
[Visual Basic]
' Outputs the PDF document to a stream.
MyDocument.Draw( MyStream )
[C#]
// Outputs the PDF document to a stream.
document.Draw( stream );
Output to a byte array
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.
[Visual Basic]
' Outputs the PDF document to a byte array.
Dim MyData as Byte()
MyData = MyDocument.Draw()
[C#]
// Outputs the PDF document to a byte array.
byte[] data;
data = document.Draw();
| See Also |
Document Class | Document.Draw Method | Document.DrawToWeb Method | Programming with Generator for .NET

