Method Write
Namespace TallComponents.PDF.Layout
Class Document
Write PDF document to HttpResponse in Declaritive (push) or Event-Driven mode (pull).
Sets the following headers:
HeaderValueContentTypeapplication/pdfContentEncodingUTF8
Please check the turorial on differences in the Push (normal) and Pull (low resource, event driven) mode generation. There are some features that change behavior when using Pull-mode.
The following snippets demonstrate how to create a simple PDF document and stream it to a browser from the code-behind of an ASP.NET page (.aspx) using Event-Driven mode. See for an example of Declaritive mode. C# private void Page_Load(object sender, System.EventArgs e) { // Create a document Document doc = new Document(); Section section = new Section(); doc.Sections.Add( section ); // Setup an event handler for Section.Paragraphs.PrintParagraph section.Paragraphs.PrintParagraph += new ParagraphCollection.PrintParagraphEventHandler(PrintParagraph); try { // Write in Event-Driven mode doc.Write( Response, true ); } catch( Exception ex ) { // Do some logging or error reporting here ... } } private void PrintParagraph( ParagraphCollection sender, PrintParagraphEventArgs args ) { TextParagraph text = new TextParagraph(); text.Fragments.Add( new Fragment( "Hello world from ASP.NET!" ) ); args.Paragraph = text; } VB.NET Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Create a document Dim doc As New Document Dim section As New Section doc.Sections.Add(section) ' Setup an event handler for Section.Paragraphs.PrintParagraph AddHandler section.Paragraphs.PrintParagraph, AddressOf PrintParagraph Try ' Write in Event-Driven mode doc.Write(Response, True) Catch ex As Exception ' Do some logging or error reporting here ... End Try End Sub Private Sub PrintParagraph(ByVal sender As ParagraphCollection, ByVal e As PrintParagraphEventArgs) Dim text As New TextParagraph text.Fragments.Add(New Fragment("Hello world from ASP.NET!")) e.Paragraph = text End Sub
Syntax
public Void Write(HttpResponse response, Boolean eventDrivenMode)
Returns
Void
Parameters
HttpResponse
response
Boolean
eventDrivenMode