Skip to content

Commit 466dad8

Browse files
author
Relorer
committed
Merge branch 'master' of https://github.com/Relorer/HTMLToQPDF
2 parents 1bbb270 + 1c81072 commit 466dad8

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,43 @@ HTMLToQPDF is an extension for QuestPDF that allows to generate PDF from HTML
22

33
[QuestPDF](https://github.com/QuestPDF/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.
44

5-
You can use [HTMLToQPDF.Example](https://github.com/Relorer/HTMLToQPDF/tree/master/HTMLToQPDF.Example) to try out the capabilities of this extension.
5+
The simplest example of use:
6+
```
7+
Document.Create(container =>
8+
{
9+
container.Page(page =>
10+
{
11+
page.HTML(handler =>
12+
{
13+
handler.SetHtml(html);
14+
});
15+
});
16+
}).GeneratePdf(path);
17+
```
18+
**I strongly recommend overloading the image upload method, because the outdated WebClient is used by default without using asynchronous.**
19+
To do this, you can use the OverloadImgReceivingFunc:
20+
```
21+
page.HTML(handler =>
22+
{
23+
handler.OverloadImgReceivingFunc(GetImgBySrc);
24+
handler.SetHtml(html);
25+
});
26+
```
27+
28+
You can customize the styles of text and containers for tags:
29+
```
30+
handler.SetTextStyleForHtmlElement("div", TextStyle.Default.FontColor(Colors.Grey.Medium));
31+
handler.SetTextStyleForHtmlElement("h1", TextStyle.Default.FontColor(Colors.DeepOrange.Accent4).FontSize(32).Bold());
32+
handler.SetContainerStyleForHtmlElement("table", c => c.Background(Colors.Pink.Lighten5));
33+
handler.SetContainerStyleForHtmlElement("ul", c => c.PaddingVertical(10));
34+
```
35+
36+
You can set the vertical padding size for lists. This padding will not apply to sub-lists:
37+
```
38+
handler.SetListVerticalPadding(40);
39+
```
40+
41+
You can use [HTMLToQPDF.Example](https://github.com/Relorer/HTMLToQPDF/releases/tag/1.0.0) to try out the capabilities of this extension.
642

743
<p align="center">
844
<img src="https://user-images.githubusercontent.com/26045342/195960914-1aef2f7e-f5bb-4c4b-bbe9-cd4770a0527f.png" />

0 commit comments

Comments
 (0)