htmltopdfwidgets 0.0.8+2
htmltopdfwidgets: ^0.0.8+2 copied to clipboard
Htmlt to pdf widgets library convert html text to pdf widgets
example/lib/main.dart
import 'dart:io';
import 'package:htmltopdfwidgets/htmltopdfwidgets.dart';
void main() {
createDocument();
}
const htmlText = ''' <h1>Heading Example</h1>
<p>This is a paragraph.</p>
<img src="image.jpg" alt="Example Image" />
<blockquote>This is a quote.</blockquote>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
''';
createDocument() async {
var filePath = 'example.pdf';
var file = File(filePath);
final newpdf = Document();
List<Widget> widgets = await HTMLToPdf().convert(htmlText);
newpdf.addPage(MultiPage(
maxPages: 200,
build: (context) {
return widgets;
}));
await file.writeAsBytes(await newpdf.save());
}