i need help with a Flutter project. I need to export a highly styled PDF. I have an HTML file the imports a JSON and converts a HTML page for printing, i need export this html page in PDF.
Is there any libary for HTML to PDF conversion? Or libary to redirect the HTML page to a browser,I use android and PC to export project.
import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String stringHtml = """
<html>
<body>
<h1>Hello, World!</h1></br>
<h2>sub Hello World</h2>
<button onclick="window.print()">Esse Botão Vai imprimir</button>
</body>
</html>
""";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
),
body: SingleChildScrollView(
child: Column(
children: [
HtmlWidget(
stringHtml
)
]
)
)
,
// floatingActionButton: FloatingActionButton(
// onPressed: _incrementCounter,
// tooltip: 'Increment',
// child: const Icon(Icons.add),
// ), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
1