Our.Umbraco.TemplateToPdf
2.2.0
dotnet add package Our.Umbraco.TemplateToPdf --version 2.2.0
NuGet\Install-Package Our.Umbraco.TemplateToPdf -Version 2.2.0
<PackageReference Include="Our.Umbraco.TemplateToPdf" Version="2.2.0" />
paket add Our.Umbraco.TemplateToPdf --version 2.2.0
#r "nuget: Our.Umbraco.TemplateToPdf, 2.2.0"
// Install Our.Umbraco.TemplateToPdf as a Cake Addin #addin nuget:?package=Our.Umbraco.TemplateToPdf&version=2.2.0 // Install Our.Umbraco.TemplateToPdf as a Cake Tool #tool nuget:?package=Our.Umbraco.TemplateToPdf&version=2.2.0
TemplateToPdf.Demo
This is a demo applciation for Umbraco Template to Pdf
Backoffice Log in :
Username :admin@demo.com PassWord: Admin12345
What is this package for?
This package is desgined to convert Umbraco Content into a Pdf while you have full control of what the pdf will look like using the Umbraco back office!
Getting Started
2.1 First Thing First:
Download the package using:
dotnet add package Our.Umbraco.TemplateToPdf
2.2 Add The Core file:
You need to add a file called: wkhtmltopdf.exe. This file is responsible for converting the Html inside of the template to Pdf. You can download it here :
https://github.com/uppercuut/TemplateToPdf.Demo/tree/master/TemplateToPdf.Demo/wwwroot/TemplateToPdf
The live folder location must be:
**“<YourApplicationName>/wwwroot/TemplateToPdf/wkhtmltopdf.exe” ** if the folder “TemplateToPdf” is not there then create it.
2.3 Configuring Startup.cs:
Add this line to the startup file and you are ready to go!
builder.AddTemplateToPdf();
like the image below:
Usage
This package is so simple to use. All you have to do is create a Url and let the browser redirect to it. You can use a builder from the Package that will help you a lot:
var pdfUrl = new PdfUrlBuilder().UsingGetByIdMethod(<yourNodeId>).WithTemplateAlias("<yourTemplateAlias>").AddPdfFileName("<pdf file name>").Url(); this line will generate a url to be imbeded in any page or any where !
And this is what the Template looks like :
and @model IPublishedContent to bind the page to a loose model
Thats it!
Example:
Let me give an exmaple of how this package works and one of its uses! (we will walk through a scenario from A to Z)
Using Umbraco Starter-kit, I added a button to the bottom of each one of those cool people to download thier resumes:
Now! When you click on the button it will open up a pdf file, take its content from UmbracoCms and the structure/style from a Template also in Umbraco!
This is the template used ⇒
Now let's see the content : Here we see the details for each Person :
Now let's check the Pdf! :
Now! Let's say we want to make his name a different color and change a few lines of the Objective text
Those are our changes, we saved and published them:
Now to see the new pdf. All you have to do is refresh !!
This is pretty much the TemplateToPdf Package.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
-
net9.0
- Rotativa.AspNetCore (>= 1.3.2)
- Umbraco.Cms.Web.Common (>= 15.0.0-rc1)
- Umbraco.Cms.Web.Website (>= 15.0.0-rc1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.