PdfPageStreamWriter
The PdfPageStreamWriter class provides an API that allows you to write and position content in the current page.
Using PdfPageStreamWriter
Create a PdfPageStreamWriter Instance
Obtain an instance of the PdfPageStreamWriter class by using the BeginPage() method of PdfStreamWriter.
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 of how to use the
PdfPageStreamWriterclass in the Manipulate Pages example in the XAML SDK repository on GitHub.
PdfStreamWriter also exposes an additional overload that allows you to keep the stream open after disposing the writer instance. Pass true as the value for the second constructor parameter (leaveStreamOpen).
PdfPageStreamWriterinherits from IDisposable. Ensure the object is disposed when you are done with it. The best way to handle this is to wrap it in ausingstatement.
PdfPageStreamWriter Members
The members of the class allow you to set several properties of the document page and write new content:
| Member | Description |
|---|---|
Rotation | A read-only property of type Rotation. Keeps the rotation of the current page. |
Size | A read-only property of type Size. Keeps the size of the current page. |
WriteContent() | Writes content to the current PDF page stream. Overloads accept content from PdfPageSource or RadFixedPage. |
ContentPosition | A property of type IPosition that specifies the position of the next page content written with WriteContent(). |
SaveContentPosition() | Saves the current IPosition values. Returns an IDisposable that restores the position when disposed. |