![]() |
VOOZH | about |
dotnet add package HTMLToQPDF --version 1.2.0
NuGet\Install-Package HTMLToQPDF -Version 1.2.0
<PackageReference Include="HTMLToQPDF" Version="1.2.0" />
<PackageVersion Include="HTMLToQPDF" Version="1.2.0" />Directory.Packages.props
<PackageReference Include="HTMLToQPDF" />Project file
paket add HTMLToQPDF --version 1.2.0
#r "nuget: HTMLToQPDF, 1.2.0"
#:package HTMLToQPDF@1.2.0
#addin nuget:?package=HTMLToQPDF&version=1.2.0Install as a Cake Addin
#tool nuget:?package=HTMLToQPDF&version=1.2.0Install as a Cake Tool
Relorer.QuestPDF.HTML is an extension for QuestPDF that allows to generate PDF from HTML
QuestPDF currently does not support inserting html into a pdf document. So I wrote a small library for this. It doesn't support the full functionality of html and css, but I think it should be enough for most cases.
The simplest example of use:
Document.Create(container =>
{
container.Page(page =>
{
page.Content().Column(col =>
{
col.Item().HTML(handler =>
{
handler.SetHtml(html);
});
});
});
}).GeneratePdf(path);
I strongly recommend overloading the image upload method, because the outdated WebClient is used by default without using asynchronous. To do this, you can use the OverloadImgReceivingFunc:
col.Item().HTML(handler =>
{
handler.OverloadImgReceivingFunc(GetImgBySrc);
handler.SetHtml(html);
});
You can customize the styles of text and containers for tags:
handler.SetTextStyleForHtmlElement("div", TextStyle.Default.FontColor(Colors.Grey.Medium));
handler.SetTextStyleForHtmlElement("h1", TextStyle.Default.FontColor(Colors.DeepOrange.Accent4).FontSize(32).Bold());
handler.SetContainerStyleForHtmlElement("table", c => c.Background(Colors.Pink.Lighten5));
handler.SetContainerStyleForHtmlElement("ul", c => c.PaddingVertical(10));
You can set the vertical padding size for lists. This padding will not apply to sub-lists:
handler.SetListVerticalPadding(40);
You can use HTMLToQPDF.Example to try out the capabilities of this extension.
<p align="center"> <img src="https://user-images.githubusercontent.com/26045342/195960914-1aef2f7e-f5bb-4c4b-bbe9-cd4770a0527f.png" /> </p>
<table border="0"> <tr> <td><b style="font-size:30px">Default Styles</b></td> <td><b style="font-size:30px">Options for changing styles</b></td> </tr> <tr> <td><img src="https://user-images.githubusercontent.com/26045342/195960950-8bf101e9-c64e-482c-9993-39f9646d0e2f.png" /></td> <td><img src="https://user-images.githubusercontent.com/26045342/195960936-6f014456-a074-4672-aa39-03cdcdcc3afc.png" /></td> </tr> </table>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.