Skip to content

Commit 2127a16

Browse files
authored
Merge pull request #54 from Prezentor/main
Add configurable bulletIconContainerDimension to BulletedListIcon
2 parents a2d57a5 + 99a24dd commit 2127a16

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

lib/src/html_to_widgets.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import 'pdfwidgets/quote_widget.dart';
1919
////html deocoder that deocde html and convert it into pdf widgets
2020
class WidgetsHTMLDecoder {
2121
final double defaultFontSize;
22+
final double defaultFontHeight;
2223
final String defaultFontFamily;
2324

2425
/// Resolve the font for the PDF based on (font family, bold, italic)
@@ -39,6 +40,7 @@ class WidgetsHTMLDecoder {
3940
this.defaultFontFamily = "Roboto",
4041
this.wrapInParagraph = false,
4142
this.defaultFontSize = 12.0,
43+
this.defaultFontHeight = 1.2,
4244
});
4345

4446
//// The class takes an HTML string as input and returns a list of Widgets. The Widgets
@@ -63,6 +65,7 @@ class WidgetsHTMLDecoder {
6365
await fontResolver?.call(defaultFontFamily, true, true);
6466
final baseTextStyle = TextStyle(
6567
fontSize: defaultFontSize,
68+
height: defaultFontHeight,
6669
font: font,
6770
fontNormal: font,
6871
fontBold: fontBold,

lib/src/html_to_widgets_codec.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class HTMLToPdf extends HtmlCodec {
2020
FutureOr<Font> Function(String, bool, bool)? fontResolver,
2121
String defaultFontFamily = "Roboto",
2222
double defaultFontSize = 12.0,
23+
double defaultFontHeight = 1.2,
2324
//custom html tag styles
2425
HtmlTagStyle tagStyle = const HtmlTagStyle()}) async {
2526
//decode that handle all html tags logic
@@ -30,6 +31,7 @@ class HTMLToPdf extends HtmlCodec {
3031
defaultFontFamily: defaultFontFamily,
3132
wrapInParagraph: wrapInParagraph,
3233
defaultFontSize: defaultFontSize,
34+
defaultFontHeight: defaultFontHeight,
3335
//custom html tags style
3436
customStyles: tagStyle);
3537
//convert function that convert string to dom nodes that that dom nodes will be converted
@@ -43,6 +45,7 @@ class HTMLToPdf extends HtmlCodec {
4345
FutureOr<Font> Function(String, bool, bool)? fontResolver,
4446
String defaultFontFamily = "Roboto",
4547
double defaultFontSize = 12.0,
48+
double defaultFontHeight = 1.2,
4649
bool wrapInParagraph = false,
4750
Iterable<BlockSyntax> blockSyntaxes = const [],
4851
Iterable<InlineSyntax> inlineSyntaxes = const [],
@@ -64,6 +67,7 @@ class HTMLToPdf extends HtmlCodec {
6467
wrapInParagraph: wrapInParagraph,
6568
defaultFontFamily: defaultFontFamily,
6669
defaultFontSize: defaultFontSize,
70+
defaultFontHeight: defaultFontHeight,
6771
//custom html tags style
6872
customStyles: tagStyle);
6973
final html = markdownToHtml(

lib/src/htmltagstyles.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class HtmlTagStyle {
3939
/// The color of the bullet list icon in a PDF document.
4040
final PdfColor? bulletListIconColor;
4141

42+
/// This provides consistent spacing and alignment for bullet points
43+
final double? bulletIconContainerDimension;
44+
4245
/// The color of the divider in a PDF document.
4346
final PdfColor dividerColor;
4447

@@ -83,6 +86,7 @@ class HtmlTagStyle {
8386
this.linkStyle,
8487
this.quoteBarColor,
8588
this.bulletListIconColor,
89+
this.bulletIconContainerDimension = 22,
8690
this.dividerBorderStyle,
8791
this.dividerHight = 0.5,
8892
this.codeBlockBackgroundColor = PdfColors.red,

lib/src/pdfwidgets/bullet_list.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class _BulletedListIcon extends StatelessWidget {
3030
@override
3131
Widget build(Context context) {
3232
return SizedBox(
33-
width: 22,
34-
height: 22,
33+
width: style.bulletIconContainerDimension,
34+
height: style.bulletIconContainerDimension,
3535
child: Padding(
3636
padding: const EdgeInsets.only(right: 5.0),
3737
child: Center(

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: htmltopdfwidgets
22
description: A Dart package that converts HTML and Markdown rich text content into high-quality PDF widgets. Simplify the creation of PDF documents by seamlessly transforming your structured text content into printable, professional PDFs. Perfect for generating reports, invoices, and more!
3-
version: 1.1.3
3+
version: 1.1.4
44
homepage: https://github.com/alihassan143/htmltopdfwidgets
55

66
environment:

0 commit comments

Comments
 (0)