Document construction
Create a PDF from scratch
Enter a heading. The server creates a new document, formats the heading, adds a repeating page header, and exports the result directly as Adobe PDF.
Output pipelineWhat the server creates
No source template or temporary PDF file is required.
SourceNew document
ContentText + header
ProcessingIn memory
OutputAdobe PDF
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Generate PDF documents server-side
A PDF does not require an existing template. ServerTextControl exposes the same document model used for rich-text editing, allowing applications to construct text, formatting, headers, tables, images, and other content entirely in code.
The finished document is saved directly into a byte array, so no temporary file is required before the result is returned to the browser.
API used
ServerTextControl.Save
Key members
The document is assembled in memory with ServerTextControl, formatted through Selection, and exported directly as PDF bytes.
using var textControl = new ServerTextControl();
textControl.Create();
textControl.Selection = new Selection(-1, 0)
{
Text = documentText,
FontSize = 600,
Bold = true
};
textControl.Save(out byte[] pdf, BinaryStreamType.AdobePDF);
How it works
The controller creates a temporary ServerTextControl, inserts and formats text through Selection, adds a section header, and calls Save with BinaryStreamType.AdobePDF. The Base64 response is loaded directly into the Document Viewer.
Source files
See the implementation
Inspect the client request, Razor view, and server-side PDF creation endpoint.