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 TypeDefault
ChildContent

PDF pages declared inside the document.

RenderFragmentnull
Orientation

Default page orientation used by pages that do not override it.

Possible values:Portrait, Landscape

PdfOrientationPdfOrientation.Portrait
PageHeight

Custom page height used when the page size is custom.

double0
PageSize

Default page size used by pages that do not override it.

Possible values:Custom, A4, Letter

PdfPageSizePdfPageSize.A4
PageWidth

Custom page width used when the page size is custom.

double0
Title

Document title stored in the document definition.

string

PdfPage

Parameter Description TypeDefault
ChildContent

PDF elements declared inside the page.

RenderFragmentnull
Height

Custom page height used when the page size is custom.

double0
Orientation

Page orientation for this page. If omitted, the document orientation is used.

PdfOrientation?null
Size

Page size for this page.

Possible values:Custom, A4, Letter

PdfPageSizePdfPageSize.Custom
Width

Custom page width used when the page size is custom.

double0

PdfText

Parameter Description TypeDefault
BackgroundColor

Background color in hexadecimal format.

string
Bold

Makes text bold.

boolfalse
BorderColor

Border color in hexadecimal format.

string"#000000"
BorderStyle

Border style.

Possible values:Solid, Dashed, Dotted

PdfBorderStylePdfBorderStyle.Solid
BorderWidth

Border width.

double0
ClipContent

Indicates that content should be clipped to the element bounds.

booltrue
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.

double12
Height

Element height.

double0
Italic

Makes text italic.

boolfalse
Text

Text rendered by the element.

string
TextAlignment

Text alignment inside the element bounds.

Possible values:Default, Start, End, Center, Justified

Remarks

Default and Start align to the start. Justified distributes words across wrapped non-final paragraph lines.

TextAlignmentDefault
TextColor

Text color in hexadecimal format.

string"#000000"
VerticalAlignment

Text vertical alignment inside the element bounds.

Possible values:Default, Baseline, Top, Middle, Bottom, TextTop, TextBottom

Remarks

Default, Baseline, Top, and TextTop align to the top. Middle centers the text, while Bottom and TextBottom align to the bottom.

VerticalAlignmentDefault
Width

Element width.

double0
Wrap

Indicates that text should wrap inside the element bounds.

booltrue
X

Horizontal element position.

double0
Y

Vertical element position.

double0

PdfImage

Parameter Description TypeDefault
BackgroundColor

Background color in hexadecimal format.

string
BorderColor

Border color in hexadecimal format.

string"#000000"
BorderStyle

Border style.

Possible values:Solid, Dashed, Dotted

PdfBorderStylePdfBorderStyle.Solid
BorderWidth

Border width.

double0
ClipContent

Indicates that content should be clipped to the element bounds.

booltrue
Fit

Defines how the image should fit inside the element bounds.

Possible values:Default, Contain, Cover, Fill, None, Scale

PdfImageFitPdfImageFit.Fill
Height

Element height.

double0
Source

Image source resolved by IPdfResourceResolver. The default resolver accepts base64 data URIs.

string
Width

Element width.

double0
X

Horizontal element position.

double0
Y

Vertical element position.

double0

PdfFont

Parameter Description TypeDefault
Bold

Bold font source.

FontSourcenull
BoldItalic

Bold italic font source.

FontSourcenull
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.

FontFamilynull
Italic

Italic font source.

FontSourcenull
Name

Font family name used by PDF elements.

string
Regular

Regular font source.

FontSourcenull
Visible

Indicates whether the font is visible in UI selectors.

booltrue

PdfLine

Parameter Description TypeDefault
BorderColor

Border color in hexadecimal format.

string"#000000"
BorderStyle

Border style.

Possible values:Solid, Dashed, Dotted

PdfBorderStylePdfBorderStyle.Solid
BorderWidth

Border width.

double0
Height

Element height.

double0
Orientation

Line orientation within the element bounds.

Possible values:Horizontal, Vertical

OrientationHorizontal
Width

Element width.

double0
X

Horizontal element position.

double0
Y

Vertical element position.

double0

PdfRectangle

Parameter Description TypeDefault
BackgroundColor

Background color in hexadecimal format.

string
BorderColor

Border color in hexadecimal format.

string"#000000"
BorderStyle

Border style.

Possible values:Solid, Dashed, Dotted

PdfBorderStylePdfBorderStyle.Solid
BorderWidth

Border width.

double0
Height

Element height.

double0
Width

Element width.

double0
X

Horizontal element position.

double0
Y

Vertical element position.

double0

PdfTable

Parameter Description TypeDefault
BackgroundColor

Background color in hexadecimal format.

string
BorderColor

Border color in hexadecimal format.

string"#000000"
BorderStyle

Border style.

Possible values:Solid, Dashed, Dotted

PdfBorderStylePdfBorderStyle.Solid
BorderWidth

Border width.

double0
ChildContent

Rows declared inside the table.

RenderFragmentnull
ClipContent

Indicates that content should be clipped to the element bounds.

booltrue
Height

Element height.

double0
Width

Element width.

double0
X

Horizontal element position.

double0
Y

Vertical element position.

double0

PdfTableRow

Parameter Description TypeDefault
ChildContent

Cells declared inside the row.

RenderFragmentnull
Height

Row height.

double24

PdfTableCell

Parameter Description TypeDefault
ChildContent

Elements declared inside the cell.

RenderFragmentnull
Width

Cell width.

double90

PdfGenerationOptions

Parameter Description TypeDefault
FileName

Suggested output file name.

string"document.pdf"
MaxDefinitionNodes

Maximum number of definition nodes allowed in one document.

intDefaultMaxDefinitionNodes
MaxImagePixels

Maximum number of pixels allowed in one image.

longDefaultMaxImagePixels
MaxPages

Maximum number of pages allowed in one document.

intDefaultMaxPages
MaxResourceSize

Maximum number of bytes allowed for one image or font.

longDefaultMaxResourceSize
MaxTextLength

Maximum combined number of text characters allowed in one document.

longDefaultMaxTextLength
MaxTotalResourceSize

Maximum combined number of image and font bytes allowed in one document.

longDefaultMaxTotalResourceSize

PdfHttpResourceOptions

Parameter Description TypeDefault
MaxResourceSize

Maximum number of bytes allowed for one resource. Defaults to 20 MB.

long0

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 DescriptionReturnParameters
Create Creates a new fluent PDF document builder. PdfDocumentBuilder
Title Sets the document title. PdfDocumentBuilderstring title
AddFont Adds a document-scoped font family. PdfDocumentBuilderFontFamily font, or a name and font sources
PageSetup Sets the default size and orientation for document pages. PdfDocumentBuilderPdfPageSize 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. PdfDocumentBuilderAction<PdfPageBuilder> configure
Build Builds the document definition used by the PDF generator. PdfDocumentDefinition

IPdfGenerator

Methods

Method DescriptionReturnParameters
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. TaskPdfDocumentDefinition document, Stream stream, PdfGenerationOptions options = null, CancellationToken cancellationToken = default
On this page