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

ParameterDefaultType
ChildContentnullRenderFragment

PDF pages declared inside the document.
OrientationPortraitPdfOrientation

Default page orientation used by pages that do not override it.
Possible values:PortraitLandscape
PageHeight0double

Custom page height used when the page size is custom.
PageSizeA4PdfPageSize

Default page size used by pages that do not override it.
Possible values:CustomA4Letter
PageWidth0double

Custom page width used when the page size is custom.
Title—string

Document title stored in the document definition.

PdfPage

ParameterDefaultType
ChildContentnullRenderFragment

PDF elements declared inside the page.
HeightDocument.PageHeightdouble

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.
OrientationPortraitPdfOrientation?

Page orientation for this page. If omitted, the document orientation is used.
When omitted, uses the parent document's orientation.
SizeA4PdfPageSize

Page size for this page.
Possible values:CustomA4Letter
When Size is Custom and neither dimension is positive, uses the parent document's page size.
WidthDocument.PageWidthdouble

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

ParameterDefaultType
BackgroundColor—string

Background color in hexadecimal format.
Boldfalsebool

Makes text bold.
BorderColor"#000000"string

Border color in hexadecimal format.
BorderStylePdfBorderStyle.SolidPdfBorderStyle

Border style.
Possible values:SolidDashedDotted
BorderWidth0double

Border width.
ClipContenttruebool

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).
FontSize12double

Font size used by the text.
Height0double

Element height.
Italicfalsebool

Makes text italic.
Text—string

Text rendered by the element.
TextAlignmentDefaultTextAlignment

Text alignment inside the element bounds.
Possible values:DefaultStartEndCenterJustified
Default and Start align to the start. Justified distributes words across wrapped non-final paragraph lines.
TextColor"#000000"string

Text color in hexadecimal format.
VerticalAlignmentDefaultVerticalAlignment

Text vertical alignment inside the element bounds.
Possible values:DefaultBaselineTopMiddleBottomTextTopTextBottom
Default, Baseline, Top, and TextTop align to the top. Middle centers the text, while Bottom and TextBottom align to the bottom.
Width0double

Element width.
Wraptruebool

Indicates that text should wrap inside the element bounds.
X0double

Horizontal element position.
Y0double

Vertical element position.

PdfImage

ParameterDefaultType
BackgroundColor—string

Background color in hexadecimal format.
BorderColor"#000000"string

Border color in hexadecimal format.
BorderStylePdfBorderStyle.SolidPdfBorderStyle

Border style.
Possible values:SolidDashedDotted
BorderWidth0double

Border width.
ClipContenttruebool

Indicates that content should be clipped to the element bounds.
FitFillPdfImageFit

Defines how the image should fit inside the element bounds.
Possible values:DefaultContainCoverFillNoneScale
Height0double

Element height.
Source—string

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

Element width.
X0double

Horizontal element position.
Y0double

Vertical element position.

PdfFont

ParameterDefaultType
BoldnullFontSource

Bold font source.
BoldItalicnullFontSource

Bold italic font source.
CssFamily—string

CSS font-family value used by browser-based rendering.
DisplayName—string

User-facing font family name.
FontnullFontFamily

Complete font family registration resolved through IPdfResourceResolver.
ItalicnullFontSource

Italic font source.
Name—string

Font family name used by PDF elements.
RegularnullFontSource

Regular font source.
Visibletruebool

Indicates whether the font is visible in UI selectors.

PdfLine

ParameterDefaultType
BorderColor"#000000"string

Border color in hexadecimal format.
BorderStylePdfBorderStyle.SolidPdfBorderStyle

Border style.
Possible values:SolidDashedDotted
BorderWidth0double

Border width.
Height0double

Element height.
OrientationHorizontalOrientation

Line orientation within the element bounds.
Possible values:HorizontalVertical
Width0double

Element width.
X0double

Horizontal element position.
Y0double

Vertical element position.

PdfRectangle

ParameterDefaultType
BackgroundColor—string

Background color in hexadecimal format.
BorderColor"#000000"string

Border color in hexadecimal format.
BorderStylePdfBorderStyle.SolidPdfBorderStyle

Border style.
Possible values:SolidDashedDotted
BorderWidth0double

Border width.
Height0double

Element height.
Width0double

Element width.
X0double

Horizontal element position.
Y0double

Vertical element position.

PdfTable

ParameterDefaultType
BackgroundColor—string

Background color in hexadecimal format.
BorderColor"#000000"string

Border color in hexadecimal format.
BorderStylePdfBorderStyle.SolidPdfBorderStyle

Border style.
Possible values:SolidDashedDotted
BorderWidth0double

Border width.
ChildContentnullRenderFragment

Rows declared inside the table.
ClipContenttruebool

Indicates that content should be clipped to the element bounds.
Height0double

Element height.
Width0double

Element width.
X0double

Horizontal element position.
Y0double

Vertical element position.

PdfTableRow

ParameterDefaultType
ChildContentnullRenderFragment

Cells declared inside the row.
Height24double

Row height.

PdfTableCell

ParameterDefaultType
ChildContentnullRenderFragment

Elements declared inside the cell.
Width90double

Cell width.

PdfGenerationOptions

ParameterDefaultType
FileName"document.pdf"string

Suggested output file name.
MaxDefinitionNodesDefaultMaxDefinitionNodesint

Maximum number of definition nodes allowed in one document.
MaxImagePixelsDefaultMaxImagePixelslong

Maximum number of pixels allowed in one image.
MaxPagesDefaultMaxPagesint

Maximum number of pages allowed in one document.
MaxResourceSizeDefaultMaxResourceSizelong

Maximum number of bytes allowed for one image or font.
MaxTextLengthDefaultMaxTextLengthlong

Maximum combined number of text characters allowed in one document.
MaxTotalResourceSizeDefaultMaxTotalResourceSizelong

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

PdfHttpResourceOptions

ParameterDefaultType
MaxResourceSize0long

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

Events

PdfGenerationOptions

EventType
ProgressFunc<PdfGenerationProgress, Task>

Callback invoked when PDF generation progress changes.

PdfHttpResourceOptions

EventType
ResourceAllowedFunc<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

MethodReturnParameters
CreatePdfDocumentBuilder—

Creates a new fluent PDF document builder.
TitlePdfDocumentBuilderstring title

Sets the document title.
AddFontPdfDocumentBuilderFontFamily font, or a name and font sources

Adds a document-scoped font family.
PageSetupPdfDocumentBuilderPdfPageSize size, PdfOrientation orientation = Portrait, double width = 0, double height = 0

Sets the default size and orientation for document pages.
PagePdfDocumentBuilderAction<PdfPageBuilder> configure

Adds and configures a page. Overloads can set the page size, orientation, width, and height.
BuildPdfDocumentDefinition—

Builds the document definition used by the PDF generator.

IPdfGenerator

Methods

MethodReturnParameters
GenerateAsyncTask<PdfGenerationResult>PdfDocumentDefinition document, PdfGenerationOptions options = null, CancellationToken cancellationToken = default

Generates a complete PDF document in memory.
GenerateToStreamAsyncTaskPdfDocumentDefinition document, Stream stream, PdfGenerationOptions options = null, CancellationToken cancellationToken = default

Generates a PDF directly into the supplied stream and leaves the stream open.