Blazorise PDF API
Review the components, builders, services, and options used to define and generate PDF documents.
For setup instructions and examples, see the PDF documentation.
API
Parameters
PdfDocument
| Parameter | Description | Type | Default |
|---|---|---|---|
ChildContent |
PDF pages declared inside the document. |
RenderFragment | null |
Orientation |
Default page orientation used by pages that do not override it. Possible values: |
PdfOrientation | PdfOrientation.Portrait |
PageHeight |
Custom page height used when the page size is custom. |
double | 0 |
PageSize |
Default page size used by pages that do not override it. Possible values: |
PdfPageSize | PdfPageSize.A4 |
PageWidth |
Custom page width used when the page size is custom. |
double | 0 |
Title |
Document title stored in the document definition. |
string |
PdfPage
| Parameter | Description | Type | Default |
|---|---|---|---|
ChildContent |
PDF elements declared inside the page. |
RenderFragment | null |
Height |
Custom page height used when the page size is custom. |
double | 0 |
Orientation |
Page orientation for this page. If omitted, the document orientation is used. |
PdfOrientation? | null |
Size |
Page size for this page. Possible values: |
PdfPageSize | PdfPageSize.Custom |
Width |
Custom page width used when the page size is custom. |
double | 0 |
PdfText
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Background color in hexadecimal format. |
string | |
Bold |
Makes text bold. |
bool | false |
BorderColor |
Border color in hexadecimal format. |
string | "#000000" |
BorderStyle |
Border style. Possible values: |
PdfBorderStyle | PdfBorderStyle.Solid |
BorderWidth |
Border width. |
double | 0 |
ClipContent |
Indicates that content should be clipped to the element bounds. |
bool | true |
FontFamily |
Font family used by the text. The built-in renderer maps the family to the closest PDF standard font (Helvetica, Times, or Courier). |
string | "Helvetica" |
FontSize |
Font size used by the text. |
double | 12 |
Height |
Element height. |
double | 0 |
Italic |
Makes text italic. |
bool | false |
Text |
Text rendered by the element. |
string | |
TextAlignment |
Text alignment inside the element bounds. Possible values: RemarksDefault and Start align to the start. Justified distributes words across wrapped non-final paragraph lines. |
TextAlignment | Default |
TextColor |
Text color in hexadecimal format. |
string | "#000000" |
VerticalAlignment |
Text vertical alignment inside the element bounds. Possible values: RemarksDefault, Baseline, Top, and TextTop align to the top. Middle centers the text, while Bottom and TextBottom align to the bottom. |
VerticalAlignment | Default |
Width |
Element width. |
double | 0 |
Wrap |
Indicates that text should wrap inside the element bounds. |
bool | true |
X |
Horizontal element position. |
double | 0 |
Y |
Vertical element position. |
double | 0 |
PdfImage
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Background color in hexadecimal format. |
string | |
BorderColor |
Border color in hexadecimal format. |
string | "#000000" |
BorderStyle |
Border style. Possible values: |
PdfBorderStyle | PdfBorderStyle.Solid |
BorderWidth |
Border width. |
double | 0 |
ClipContent |
Indicates that content should be clipped to the element bounds. |
bool | true |
Fit |
Defines how the image should fit inside the element bounds. Possible values: |
PdfImageFit | PdfImageFit.Fill |
Height |
Element height. |
double | 0 |
Source |
Image source resolved by IPdfResourceResolver. The default resolver accepts base64 data URIs. |
string | |
Width |
Element width. |
double | 0 |
X |
Horizontal element position. |
double | 0 |
Y |
Vertical element position. |
double | 0 |
PdfFont
| Parameter | Description | Type | Default |
|---|---|---|---|
Bold |
Bold font source. |
FontSource | null |
BoldItalic |
Bold italic font source. |
FontSource | null |
CssFamily |
CSS font-family value used by browser-based rendering. |
string | |
DisplayName |
User-facing font family name. |
string | |
Font |
Complete font family registration resolved through IPdfResourceResolver. |
FontFamily | null |
Italic |
Italic font source. |
FontSource | null |
Name |
Font family name used by PDF elements. |
string | |
Regular |
Regular font source. |
FontSource | null |
Visible |
Indicates whether the font is visible in UI selectors. |
bool | true |
PdfLine
| Parameter | Description | Type | Default |
|---|---|---|---|
BorderColor |
Border color in hexadecimal format. |
string | "#000000" |
BorderStyle |
Border style. Possible values: |
PdfBorderStyle | PdfBorderStyle.Solid |
BorderWidth |
Border width. |
double | 0 |
Height |
Element height. |
double | 0 |
Orientation |
Line orientation within the element bounds. Possible values: |
Orientation | Horizontal |
Width |
Element width. |
double | 0 |
X |
Horizontal element position. |
double | 0 |
Y |
Vertical element position. |
double | 0 |
PdfRectangle
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Background color in hexadecimal format. |
string | |
BorderColor |
Border color in hexadecimal format. |
string | "#000000" |
BorderStyle |
Border style. Possible values: |
PdfBorderStyle | PdfBorderStyle.Solid |
BorderWidth |
Border width. |
double | 0 |
Height |
Element height. |
double | 0 |
Width |
Element width. |
double | 0 |
X |
Horizontal element position. |
double | 0 |
Y |
Vertical element position. |
double | 0 |
PdfTable
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Background color in hexadecimal format. |
string | |
BorderColor |
Border color in hexadecimal format. |
string | "#000000" |
BorderStyle |
Border style. Possible values: |
PdfBorderStyle | PdfBorderStyle.Solid |
BorderWidth |
Border width. |
double | 0 |
ChildContent |
Rows declared inside the table. |
RenderFragment | null |
ClipContent |
Indicates that content should be clipped to the element bounds. |
bool | true |
Height |
Element height. |
double | 0 |
Width |
Element width. |
double | 0 |
X |
Horizontal element position. |
double | 0 |
Y |
Vertical element position. |
double | 0 |
PdfTableRow
| Parameter | Description | Type | Default |
|---|---|---|---|
ChildContent |
Cells declared inside the row. |
RenderFragment | null |
Height |
Row height. |
double | 24 |
PdfTableCell
| Parameter | Description | Type | Default |
|---|---|---|---|
ChildContent |
Elements declared inside the cell. |
RenderFragment | null |
Width |
Cell width. |
double | 90 |
PdfGenerationOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
FileName |
Suggested output file name. |
string | "document.pdf" |
MaxDefinitionNodes |
Maximum number of definition nodes allowed in one document. |
int | DefaultMaxDefinitionNodes |
MaxImagePixels |
Maximum number of pixels allowed in one image. |
long | DefaultMaxImagePixels |
MaxPages |
Maximum number of pages allowed in one document. |
int | DefaultMaxPages |
MaxResourceSize |
Maximum number of bytes allowed for one image or font. |
long | DefaultMaxResourceSize |
MaxTextLength |
Maximum combined number of text characters allowed in one document. |
long | DefaultMaxTextLength |
MaxTotalResourceSize |
Maximum combined number of image and font bytes allowed in one document. |
long | DefaultMaxTotalResourceSize |
PdfHttpResourceOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
MaxResourceSize |
Maximum number of bytes allowed for one resource. Defaults to 20 MB. |
long | 0 |
Events
PdfGenerationOptions
| Event | Description | Type |
|---|---|---|
Progress |
Callback invoked when PDF generation progress changes. |
Func<PdfGenerationProgress, Task> |
PdfHttpResourceOptions
| Event | Description | Type |
|---|---|---|
ResourceAllowed |
Determines whether the requested absolute HTTP resource URI is allowed. A null value allows every HTTP and HTTPS URI. Redirects are rejected by the built-in resolver. |
Func<Uri, bool> |
PdfDocumentBuilder
Methods
| Method | Description | Return | Parameters |
|---|---|---|---|
Create |
Creates a new fluent PDF document builder. | PdfDocumentBuilder | |
Title |
Sets the document title. | PdfDocumentBuilder | string title |
AddFont |
Adds a document-scoped font family. | PdfDocumentBuilder | FontFamily font, or a name and font sources |
PageSetup |
Sets the default size and orientation for document pages. | PdfDocumentBuilder | PdfPageSize size, PdfOrientation orientation = Portrait, double width = 0, double height = 0 |
Page |
Adds and configures a page. Overloads can set the page size, orientation, width, and height. | PdfDocumentBuilder | Action<PdfPageBuilder> configure |
Build |
Builds the document definition used by the PDF generator. | PdfDocumentDefinition |
IPdfGenerator
Methods
| Method | Description | Return | Parameters |
|---|---|---|---|
GenerateAsync |
Generates a complete PDF document in memory. | Task<PdfGenerationResult> | PdfDocumentDefinition document, PdfGenerationOptions options = null, CancellationToken cancellationToken = default |
GenerateToStreamAsync |
Generates a PDF directly into the supplied stream and leaves the stream open. | Task | PdfDocumentDefinition document, Stream stream, PdfGenerationOptions options = null, CancellationToken cancellationToken = default |