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