Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richard-scryber/scryber.core
Scryber.Core is a dotnet 6 html to pdf engine written entirely in C# for creating beautiful flowing documents from html templates including css styles, object data binding and svg drawing.
https://github.com/richard-scryber/scryber.core
csharp dotnet-core html-template pdf pdf-document pdf-generation
Last synced: 1 day ago
JSON representation
Scryber.Core is a dotnet 6 html to pdf engine written entirely in C# for creating beautiful flowing documents from html templates including css styles, object data binding and svg drawing.
- Host: GitHub
- URL: https://github.com/richard-scryber/scryber.core
- Owner: richard-scryber
- License: other
- Created: 2020-05-23T09:55:38.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-12T10:52:27.000Z (9 days ago)
- Last Synced: 2025-02-12T11:47:35.882Z (9 days ago)
- Topics: csharp, dotnet-core, html-template, pdf, pdf-document, pdf-generation
- Language: C#
- Homepage:
- Size: 62.5 MB
- Stars: 199
- Watchers: 10
- Forks: 33
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![]()
scryber.core pdf engine## Scryber makes creating beautiful documents easy.
The scryber engine is an advanced, complete, pdf creation library for dotnet core.
It supports the easy definition of document templates with, pages, content, shapes and images using xhtml and/or code.
With a styles based template layout, it is easy to create good looking, paginated and flowing documents.
With dynamic content from you applications or sites it is easy to add dynamic data, and repeaters.
**Now** uncludes support for expressions in both templates and css styles.
## scryber supports:
- standard [html body, tables, lists, divs and spans](https://scrybercore.readthedocs.io/en/latest/document_components.html) and many newer html5 [tags](https://scrybercore.readthedocs.io/en/latest/document_components.html)
- flowing and flexible layout with multiple [pages in css sizes](https://scrybercore.readthedocs.io/en/latest/document_pages.html), along with page [headers, footers and breaks](https://scrybercore.readthedocs.io/en/latest/document_pages.html), and [page numbering](https://scrybercore.readthedocs.io/en/latest/document_pagenumbering.html)
- cascading styles: linked, embedded or inline using [css syntax and priority](https://scrybercore.readthedocs.io/en/latest/document_styles.html).
- databinding for [dynamic content or style](https://scrybercore.readthedocs.io/en/latest/binding_model.html) on simple and complex object models with [repeating templates](https://scrybercore.readthedocs.io/en/latest/binding_model.html#using-objects).
- [embedding](https://scrybercore.readthedocs.io/en/latest/document_references.html) of external content,
- [sizing](https://scrybercore.readthedocs.io/en/latest/component_sizing.html) and [positioning](https://scrybercore.readthedocs.io/en/latest/component_positioning.html) of elements inline, block, relative or absolute.
- [images](https://scrybercore.readthedocs.io/en/latest/drawing_images.html) and colours with text and shape [fills, backgrounds](https://scrybercore.readthedocs.io/en/latest/drawing_image_backgrounds.html) and borders.
- [multiple fonts](https://scrybercore.readthedocs.io/en/latest/drawing_fonts.html), including google fonts, supporting text [alignment; spacing; leading; decoration](https://scrybercore.readthedocs.io/en/latest/document_textlayout.html) and breaking.
- Graphics support for [drawing and paths](https://scrybercore.readthedocs.io/en/latest/drawing_paths.html) and text.
- Password [security and restrictions](https://scrybercore.readthedocs.io/en/latest/document_security.html) on pdf files.
- [Full code](https://scrybercore.readthedocs.io/en/latest/document_code_vs_xml.html) support either as a whole document, or partial content, and controllers, along with the html/css templates.
- Document [controllers](https://scrybercore.readthedocs.io/en/latest/document_controllers.html) for complete control of the layout## Getting Started
The easiest way to begin is to use the Nuget Packages here
[scryber.core package](https://www.nuget.org/packages/scryber.core/)
(Base libraries for GUI or console applications)OR for asp.net mvc
[scryber.core.mvc package](https://www.nuget.org/packages/scryber.core.mvc/)
(Which includes the scryber.core package).Check out Read the Docs for more information on how to use the library.
[scryber.core documentation](https://scrybercore.readthedocs.io/en/latest/)
## Example Template
Create a new html template file with your content.
```html
Hello World
/* use of css variables that can be changed at generation time */
:root{
--head-bg: #FFF;
--head-txt: #000;
--head-logo: url('../html/images/ScyberLogo2_alpha_small.png');
--head-space: 20px;
}body{
font-family: sans-serif;
font-size: 14pt;
}p.header {
color: var(--head-txt);
background-color: var(--head-bg);
background-image: var(--head-logo);
background-repeat: no-repeat;
background-position: var(--head-space) var(--head-space);
background-size: 20pt 20pt;
margin-top: 0pt;
padding: var(--head-space);
padding-bottom: calc(--head-space + 25pt); /* full calc support */
}.foot td {
border: none;
text-align: center;
font-size: 10pt;
margin-bottom: 10pt;
}
Scryber document creation
{{model.title}}
We hope you like it.
- {{.name}}
{{author}}
Hello World Sample
```
### From your application code.
```cs
//using Scryber.Components
static void Main(string[] args)
{
//Load your template from a
var path = System.Environment.CurrentDirectory;
path = System.IO.Path.Combine(path, "../../../Content/HTML/READMESample.html");//create our sample model data.
var model = new
{
titlestyle = "color:#ff6347",
title = "Hello from scryber",
items = new[]
{
new { name = "First item" },
new { name = "Second item" },
new { name = "Third item" },
}
};using (var doc = Document.ParseDocument(path))
{
//pass values to the document, including css using paramsdoc.Params["author"] = "Scryber Engine";
doc.Params["--head-bg"] = "#333"; //Override for the header background
doc.Params["--head-txt"] = "#FFF";
//pass data paramters as needed, supporting simple values, arrays or complex classes.doc.Params["model"] = model;
//And save it to a file or a stream
using (var stream = new System.IO.FileStream("READMESample.pdf", System.IO.FileMode.Create))
{
doc.SaveAsPDF(stream);
}}
}
```### Or from an MVC web application
```cs
//using Scryber.Components
//using Scryber.Components.Mvcpublic async IActionResult HelloWorld(string title = "This is the title")
{
using(var doc = Document.ParseDocument("[input template]"))
{
doc.Params["author"] = "Scryber Engine";
doc.Params["--head-bg"] = "#333"; //Override for the header background
doc.Params["--head-txt"] = "#FFF";doc.Params["model"] = GetMyParameters(title);
//This will output to the response inline.
return await this.PDFAsync(doc); // inline:false, outputFileName:"HelloWorld.pdf"
}
}
```### And the output

Check out Read the Docs for more information on how to use the library.
[scryber.core documentation](https://scrybercore.readthedocs.io/en/latest/)
## 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