Document Output

DynamicPDF Core Suite for .NET can output PDF documents to a file, web form, byte array or any System.IO.Stream object that supports writing. A Document class's Draw and DrawToWeb methods handle all document output. These methods are overloaded and have many options for customizing a PDF document's output.

Output to an ASPX page (WebForm)

When creating a PDF document using the ASPX WebForm element, you use the Document.DrawToWeb method in the WebForm's On_Load event. The DrawToWeb method supports outputting a generated PDF to an end-user's browser or saving to an end-user's file system.

DrawToWeb to Browser

From the On_Load event of a WebForm, a Document's DrawToWeb method can be called and passed to a download file name which is then displayed in the end-user's browser.

// Outputs the PDF document to the page object.
document.DrawToWeb( pdfFilePath );    
' Outputs the PDF document to the page object.
MyDocument.DrawToWeb( pdfFilePath ) 

DrawToWeb to File System

You can customize the DrawToWeb's download behavior and force documents to be saved to the end user's machine rather than displayed in an user's browser by specifying true in the DrawToWeb class constructor.

// Outputs the PDF document to the page object.
document.DrawToWeb( pdfFilePath, true );   
' Outputs the PDF document to the page object.
MyDocument.DrawToWeb( pdfFilePath, True )

Output to a file

Use the Document's Draw method to save a PDF to a file path. Specify the file path and name in the Document's Draw method.

// Outputs the PDF document to a file.
String pdfFilePath = "./documents/my-saved-pdf-document.pdf"
document.Draw( pdfFilePath );  
' Outputs the PDF document to a file.
MyDocument.Draw( pdfFilePath )

Output to a System.IO.Stream object

The Document.Draw method also supports streaming a byte array as a stream. Specify the Stream object to receive the output in the Document's Draw method.

// Outputs the PDF document to a stream.
document.Draw( stream );  
' Outputs the PDF document to a byte array.
Dim MyData As Byte()
MyData = MyDocument.Draw()

In this topic