Write PDF document to stream in Declaritive mode.
Namespace: TallComponents.PDF.LayoutAssembly: TallComponents.PDF.Layout (in TallComponents.PDF.Layout.dll) Version: 3.0.63.0
Syntax
Parameters
- stream
- Type: System.IO..::..Stream
Write to this stream.
Remarks
It is the responsibility of the client (caller) to Flush and Close the stream.
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.
Examples
The following snippets demonstrate how to create a simple PDF document and save it to
a file using Declaritive mode.
CopyC#
CopyC#
C#
// Create a document Document doc = new Document(); Section section = new Section(); doc.Sections.Add( section ); // Add some content TextParagraph text = new TextParagraph(); text.Fragments.Add( new Fragment( "Hello world!" ) ); section.Paragraphs.Add( text ); using( FileStream fs = new FileStream( "out.pdf", FileMode.Create, FileAccess.ReadWrite ) ) { // Write the document in Declaritive mode <b>doc.Write</b>( fs ); }
VB.NET
' Create a new document Dim doc As New Document Dim section As New Section doc.Sections.Add(section) ' Add some content Dim text As New TextParagraph text.Fragments.Add(New Fragment("Hello world!")) section.Paragraphs.Add(text) Dim fs As FileStream = Nothing Try fs = New FileStream("out.pdf", FileMode.Create, FileAccess.ReadWrite) ' Write in Declaritive mode <b>doc.Write</b>(fs) Finally If Not fs Is Nothing Then fs.Close() End If End Try
Exceptions
| Exception | Condition |
|---|---|
| System..::..ArgumentException | Thrown when the Stream is not writeable. |
| System..::..ArgumentNullException | Thrown when the Stream is nullNothingnullptra null reference (Nothing in Visual Basic). |