Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Silverlight | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

Overview

The PdfPageStreamWriter class provides API allowing you to write and position content in the currently written page.

Using PdfPageStreamWriter

Create a PdfPageStreamWriter Instance

An instance of the PdfPageStreamWriter class can be obtained using the BeginPage() method of PdfSteamWriter.

Example 1: Instantiate PdfPageStreamWriter

using (PdfStreamWriter writer = new PdfStreamWriter(File.OpenWrite(resultDocument))) 
{ 
    Size size = new Size(700,1200); 
    Rotation rotation = Rotation.Rotate270; 
 
    using (PdfPageStreamWriter pageWriter = writer.BeginPage(size, rotation)) 
    { 
        // Use the pageWriter object to fill the content of the page. 
    } 
} 

You can find an example on how to use the PdfPageStreamWriter class in the Manipulate Pages example in the XAML SDK repository on GitHub.

PdfStreamWriter exposes also an additional overload, which allows you to keep the stream you are working with open after disposing the writer instance by passing true as a value for the second constructor parameter (leaveStreamOpen).

PdfPageStreamWriter inherits from IDisposable. Make sure the object is disposed when you are done with it. The best way to ensure this is handled properly is to wrap it in a using statement.

PdfPageStreamWriter Members

The members of the class allow you to set several properties of the document page you are working with as well as write new content.

  • Rotation: A read-only property of type Rotation. Keeps the information about the rotation of the currently generated page.

  • Size: A read-only property of type Size. Keeps the information about the size of the currently generated page.

  • WriteContent(): This method enables you to write content to the currently written PDF page Stream. There are two overloads allowing to add content either from PdfPageSource or RadFixedPage.

  • ContentPosition: A property of type IPosition allowing you to specify the position of the next page content written with WriteContent() method.

  • SaveContentPosition(): With this method you can save current IPosition values. The method returns IDisposable object that restores the current position when disposed.

See Also

In this article