Scryber.Core.Mvc
9.5.0
dotnet add package Scryber.Core.Mvc --version 9.5.0
NuGet\Install-Package Scryber.Core.Mvc -Version 9.5.0
<PackageReference Include="Scryber.Core.Mvc" Version="9.5.0" />
<PackageVersion Include="Scryber.Core.Mvc" Version="9.5.0" />
<PackageReference Include="Scryber.Core.Mvc" />
paket add Scryber.Core.Mvc --version 9.5.0
#r "nuget: Scryber.Core.Mvc, 9.5.0"
#:package Scryber.Core.Mvc@9.5.0
#addin nuget:?package=Scryber.Core.Mvc&version=9.5.0
#tool nuget:?package=Scryber.Core.Mvc&version=9.5.0
Scryber.Core PDF Engine
Scryber makes creating beautiful, dynamic documents easy.
The scryber engine is an advanced, complete, pdf creation library for dotnet (including support for Blazor WASM)
- Easy definition of document templates with, pages, content, shapes and images using html, and svg.
- Bring your data in from an api or object model.
- Bind with handlebars syntax and full complex expression support.
- Layout with styles including calculated and relative values, and binding to your data.
- Finally with a couple of lines of code, output the document to a stream or file.
With a styles based template layout, it is easy to create good looking, paginated and flowing documents, with dynamic content from your applications or sites.
Getting Started
The easiest way to begin is to use the Nuget Packages here
scryber.core package (Base libraries for GUI or console applications)
OR for asp.net mvc
scryber.core.mvc package (Which includes the scryber.core package).
Check out the documentation for more information on how to use the library.
getting started, a quick start article that gives a good overview of getting started and producing your first styles and bound template.
scryber.core learning guides, a full series for learning the main capabilities of the library.
scryber.core reference guides, a complete core library reference of all the supported elements, style and binding expressions.
Using Scryber
Content template
Use standard (x)html content to define the template with handlebar {{ }} notation for dynamic values.
<html lang='en' xmlns='http://www.w3.org/1999/xhtml' >
<head>
<meta charset='utf-8' name='author' content='{{meta.author}}' />
<title>Hello World</title>
<style>
</style>
<link href="/relative-stylesheet.css" type="text/css" />
</head>
<body class="name" style="border: solid 1pt #AAA">
<h1 style="font-size: calc(theme.titleSize);">Hello {{name ?? 'World'}}</h1>
</body>
</html>
https://paperwork.help/learning/01-getting-started/03_html_to_pdf.html
Loading the DOM
The document is parsed into a complete object graph from local file paths, streams or dynamically created content.
using Scryber.Components
using var doc1 = Document.ParseDocument("xhtml-template-path.html");
using var doc2 = Document.ParseDocument(myContentStream);
using var doc3 = Document.ParseHtmlDocument("non-formal-html-template-path.html");
using var doc4 = Document.ParseDocument(new StringReader("<html xmlns='http://www.w3.org/1999/xhtml' >....</html>"))
https://paperwork.help/learning/01-getting-started/02_first_document.html
Adding data for binding
Binding values are added using the documents' Params dictionary and can be set to any value, object graph, or json data.
//simple dynamic object
doc.Params["meta"] = new { author = "My Name", reportDate = DateTime.Now };
//structured object data
doc.Params["model"] = GetMyModelData();
//json data
doc.Params["json"] = System.Text.Json.JsonSerializer.Deserialize(remoteAPIResult);
//injected templated content
doc.Params["templates"] = new
{
innerContent = "<span class='header'>{{.title}}</span><br/><span class='desc'>{{.desc}}</span>"
};
https://paperwork.help/learning/02-data-binding/
Outputting the result
The final output can be saved either to a file or stream, synchronously or asynchronously.
//Simply save to a file
doc.SaveAsPDF("filePath.pdf");
//A standard IO stream
using var memory = new System.IO.MemoryStream();
doc.SaveAsPDF(memory);
//Or your own custom Stream
using var sourceStream = GetDataStream();
doc.SaveAsPDF(sourceStream);
//Also supports asyncromous operation
await doc.SaveAsPDFAsync("asyncfilepath.pdf");
https://paperwork.help/learning/01-getting-started/07_output_options.html
Using the Scryber.Components.MVC package extensions
public async IActionResult GetDocument()
{
.
.
return await this.PDFAsync(doc)
}
Other features
Binding to complex content
Handlebar support for dynamic content binding, and expressions
<div id="contentWrapper" class="wrapper">
{{#each model.items}}
<div>Item {{@index}}: {{.name}}
{{#if count(.nested)}}
<ul>{{#each .nested}}<li data-content="{{templates.innerContent}}"></li></ul>
{{#else}}<div class="muted">No inner items</div>
{{/if}}
</div>
{{/each}}
</div>
Add standard external templates using the embed element
<div class="tsCs" >
<embed src="./includes/termsAndConditions.html" />
</div>
Or create and inject compoments directly into the DOM
var table = this.BuildTableGrid(loadedData);
var container = doc.FindAComponentById("contentWrapper") as Div;
container.Contents.Add(table);
Page Sizes, headers and footers
The default page size is A4, but this can be changed to US specific letter or any standard size (or explicit). Inner pages can also have their own sizing.
<html lang='en' xmlns='http://www.w3.org/1999/xhtml' >
<head>
<style>
@page{
size: letter;
}
@page landscape{
size: letter landscape;
}
.wide{
page: landscape;
}
</style>
</head>
<body class="col2 landscape" style="border: solid 1pt #AAA">
<h1>Main page in letter sizing</h1>
<section class="wide">
Content is by default on a new page with a 'section', and this will use the 'letter landscape' size based on the 'wide' class
</section>
</body>
</html>
Column layout.
The engine fully supports columnar layout both at the page level and also within blocks.
<html lang='en' xmlns='http://www.w3.org/1999/xhtml' >
<head>
<style>
@page landscape{
size: A4 landscape;
}
@media print {
/* force a landscape page with 2 column layout on the body *only* when printing */
body {
page: landscape;
}
.col2{
column-count: 2;
column-rule: 1pt solid silver;
}
}
</style>
</head>
<body class="col2 landscape" style="border: solid 1pt #AAA">
<h1>Main page flow in 2 columns</h1>
<article class="col2">
Content will flow in the inner columns, then onto the next side of the page
</article>
</body>
</html>
Columns can also be used in footers, and a new column forced with break-before.
<footer style="column-count: 3">
<time datetime="{{meta.reportDate}}" data-format="dd MMM yyyy" />
<page data-format="Page {0} of {1}" style="break-before: column; text-align: center" />
<span style="break-before: column; text-align: right">{{meta.author}}</span>
</footer>
Graphic Support
Images are supported for png, jpeg, tiff, gif, svg and webP (v9.5+)
<img src="https://fullremoteurl.com/images/myimage.png" />
<img src="./relativeUrlFromTemplateBasePath/OrWorkingDirectory/myImage.jpg" />
<img src="./mySvgImage.svg" />
<img src="data:image/png;base64,iVBORw0KGgoAAAANS..." />
https://paperwork.help/learning/06-content/01_images.html
Images can also be used as backgrounds and patterns
.patterned{
background-repeat: repeat-x;
background-image: url("./localpath/diamond.png)";
}
https://paperwork.help/reference/cssproperties/properties/css_prop_background-image.html
SVG's can be included inline within the document or using the embed element, that allows the content to use dynamic binding.
<div class="logo" >
<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100pt' preserveAspectRatio="xMidYMid">
<rect x='10' y='10' width='{{length(meta.title) * 20' height='10' fill="#AAA" />
<text fill="#AA0" text-anchor="middle">{{meta.title}}</text>
</svg>
</div>
https://paperwork.help/learning/06-content/02_svg_basics.html
Font Support
The library includes 16 standard fonts that can be embedded. THe system fonts, and custom fonts can be configured and loaded at initial execution time
https://paperwork.help/configuration/font-configuration.html
Other fonts can also be defined through links or the @font-face rule
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet"/>
<style>
@font-face {
font-family: 'Roboto';
src: url('../fonts/Roboto-Regular.ttf') format('truetype');
font-weight: 400;
font-style: normal;
}
body{
font-family: 'Roboto', sans-serif;
}
</style>
https://paperwork.help/learning/05-typography/03_web_fonts.html
Modifying existing files
Scryber supports modification of existing pdfs using framesets for page insertion, overlays, or contractions.
<frameset xmlns='http://www.w3.org/1999/xhtml'>
<frame src="summary.html"></frame>
<frame src="large-document.pdf" data-page-start="0" data-page-count="3">
<h1 hidden="{{model.isProof ? '' : 'hidden'}}"
style="transform: rotate(45deg); opacity: 0.5; color: #444;">PROOF CONTENT</h1>
</frame>
</frameset>
https://www.paperwork.help/reference/htmltags/elements/html_frameset_frame_element.html
Adding security
Add restrictions and encryption mechanism to the document either through a template meta tag, or the documents RenderOptions.Permissions property.
<head>
<meta name="print-restrictions" content="printing, accessibility" />
<meta name="print-encryption" content="128bit"
</head>
doc.RenderOptions.Permissions.AllowCopying = true;
doc.RenderOptions.Permissions.AllowPrinting = true;
doc.RenderOptions.Permissions.AllowAccessiblity = true;
When using restrictions it is advisable that an owner password be set on the document output (in lax mode, a random value will be assigned)
using SecureString owner = CollectOwnerPassword();
doc.RenderOptions.PasswordProvider = new DocumentPasswordProvider(owner);
To force a password to be required to open a document, then set a user password (this can be the same as the owner password).
using SecureString owner = CollectOwnerPassword();
using SecureString user = CollectUserPassword();
doc.RenderOptions.PasswordProvider = new DocumentPasswordProvider(owner);
doc.RenderOptions.PasswordProvider = new DocumentPasswordProvider(owner, user);
https://paperwork.help/learning/07-configuration/05_security.html
Checking the output
To check the results, and what is happening underneath use the trace log support - either with the scryber/paperwork processing instructions at the very top of the template. This will add the processing log to the end of the resultant document, along with execution timing and any resources (fonts, images, etc) included.
<?scryber append-log=true log-level=messages ?>
or use code on the document itself.
doc.AppendTraceLog = true;
doc.TraceLog.SetRecordLevel(TraceRecordLevel.Verbose);
https://paperwork.help/configuration/processing-instructions.html
The engine also supports:
- standard html body, tables, lists, divs and spans and many newer html5 tags
- cascading styles: linked, embedded or inline using css syntax and priority.
- attaching of external files or streams.
- sizing and positioning of elements inline, block, relative or absolute.
- support for relative units and transformations.
- gradients and colours with text and shape fills, backgrounds and borders.
- multiple fonts, including google fonts, supporting text alignment; spacing; leading; decoration.
- Graphical binding support with SVG for drawings and charts and text.
- Full code support either as a whole document, or partial content, and controllers.
- Custom Component support for defining your own layouts or parts.
Getting Involved
We would love to hear your feedback. Feel free to get in touch. Issues, ideas, includes are all welcome.
If you would like to help with building, extending then happy to get contributions
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- HtmlAgilityPack (>= 1.12.4)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.9)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.3.9)
- Scryber.Core (>= 9.5.0)
- SixLabors.ImageSharp (>= 3.1.12)
- System.Security.Cryptography.Xml (>= 8.0.3)
-
net8.0
- HtmlAgilityPack (>= 1.12.4)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.9)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.3.9)
- Scryber.Core (>= 9.5.0)
- SixLabors.ImageSharp (>= 3.1.12)
- System.Security.Cryptography.Xml (>= 8.0.3)
-
net9.0
- HtmlAgilityPack (>= 1.12.4)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.9)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.3.9)
- Scryber.Core (>= 9.5.0)
- SixLabors.ImageSharp (>= 3.1.12)
- System.Security.Cryptography.Xml (>= 8.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.5.0 | 91 | 5/6/2026 |
| 9.3.1 | 145 | 4/26/2026 |
| 9.2.0.3 | 393 | 1/22/2026 |
| 9.2.0 | 508 | 11/6/2025 |
| 8.0.0.1-beta | 814 | 2/17/2025 |
| 6.0.1-beta | 24,360 | 3/24/2023 |
| 6.0.0.16-beta | 319 | 3/1/2023 |
| 6.0.0.14-beta | 8,668 | 1/1/2023 |
| 6.0.0.13-beta | 345 | 12/6/2022 |
| 6.0.0.11-beta | 360 | 12/6/2022 |
| 6.0.0.8-beta | 502 | 9/23/2022 |
| 5.1.0.2-beta | 684 | 8/31/2021 |
| 5.1.0-beta | 1,460 | 7/19/2021 |
| 5.0.7 | 22,014 | 6/16/2021 |
| 5.0.6.3 | 1,885 | 4/9/2021 |
| 5.0.6.1-beta | 449 | 4/6/2021 |
| 5.0.6 | 742 | 3/30/2021 |
| 5.0.5.4 | 725 | 3/30/2021 |
| 5.0.5.1 | 717 | 3/5/2021 |
| 5.0.5 | 756 | 2/26/2021 |
9.5.0.0
BREAKING RELEASE
Removed support for Net Standard 2.0, and Image Sharp updated to 3.1.2
All libraries updated to include dotnet 8/9/10
Added support image format webP
Clean up codebase to remove compiler warnings
9.3.1.0
Updated to the latest version of the Core Library
New features include @page with :first, :left and :right, cell rowSpan support, column-rule and column-fill
Initial support for display:flex, flex-grid and table(-xxx)
Fixed SVG image alignment, SVG image sizing, page sizing within a document, loading configuraion options in Web and exe improved.
9.2.0.3
Updated to match the release of the Scryber.Core library
9.2.0.0
Public release of the DotNet 9.0 version of the core library with extensive enhancements to HTML components, data binding and css and svg calculations.
9.1.0.7-beta
Add full support for HTML documents in .Net 6, 8 and 9 along with .net standard 2.0
6.0.2.0-beta
Updated to net8.0 sdk and dependencies updated to latest version.
6.0.1.0-beta
We now support html - in many of its flavours, through the HTMLAgilityPack
Added parsing non-formal html documents and components from local and remote files (using the ParseHtml and ParseHtmlDocument on the Document class)
Added the data-content and data-content-type attributes to visual components so that html and xhtml content can be data bound into pages.
Added support for the hyphens css property and it's use in hypenating long text.
6.0.0.16-beta
Some Big additions and fixes
Added support for the css counters (reset, increment and the counter(s) functions)
Added support for css content properties
Added support for css ::before and ::after selectors
Added support for relative units in styles e.g. 30% and 0.5em - not supported in calc() with multiple units e.g calc(50% - 5px) will not work.
A lot of layout tests to get everything working - precisely.
6.0.0.14-beta
Added support for transformations including css transform property.
6.0.0.13-beta
Changed the reference for ImageSharp to the 2.1.3 Nuget package, rather than the dll.
Checks added for support on thread culture in dates and numbers.
6.0.0.10-beta
Added support for Netwtonsoft.Json and the System.Text.Json objects in binding expressions and templates too.
Along with adding SoryBy, MaxOf, EachOf, SelectWhere collection functions.
6.0.0.8-beta
Added support for Netwtonsoft.Json and the System.Text.Json objects in binding expressions
Updated to the .net 6.0 sdk, now with support for running as a web assembly with asyncronous loads of stylesheets, images and fonts.
Some TTC and TTF font files do not render glyfs correctly, but working for many fonts.
5.1.0.2-beta
A major new release with support for expressions using the handlebars syntax {{...}}
5.0.7.0
Updates for linear and circular gradients and floating components within a block.
5.0.6.3
A fix for font character mappings on Windows and laying out mutliple spans on a single line
5.0.6
The April release is a bit of a catch up and fix with updates for:
Supporting parsed JSON objects in binding - along with std types and dynamic objects.
margin:value is applied to all margins even if explicit left, right etc. has been previously applied.
Conformance is now carried through to templates, so errors are not indavertantly raised inside the template.
Missing background images will not raise an error.
Support for data images (src='data:image/..') within content - thanks Dan Rusu!
Images are not duplicated within the output for the same source.
5.0.5
Multiple enhancements including
Embed and iFrame support.
Binding speed improvements for longer documents.
Support for border-left, border-right, etc
Support for encryption and restrictions
Support for base href in template files.
Classes and styles on templates are supported.
Added em, strong, strike, del, ins elements
Html column width and break inside
CSS and HTML Logging
Fixed application of multiple styles with the same word inside
Allow missing images on the document is now supported.
Contain fill style for background images.
See: https://scrybercore.readthedocs.io/en/latest/version_history.html for a full break down.