-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how can i add margin or padding(for bottom and top) in page?? is there any option for page format (A4,letter,a3,a5,legal)? #82
Comments
This PR has support for page format. or you can use my fork. Margin and padding does not have support. |
is there any logic for padding margin? apply on html content? |
This package does not support header/footer or paddings on html content. Instead you can Add your own Header and Footer on the html itself. apply the padding and margin to the html itself, that should work |
i am new to flutter ! |
add this to your pubspec.yaml file flutter_html_to_pdf:
git:
url: https://github.com/raister21/flutter_html_to_pdf After that you can use the Updated version of this package. Which I am currently hosting through my GitHub, you can look into forking if you want to have a copy of my version of this package.
In your Project, final String htmlContent = """
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td, p {
padding: 5px;
text-align: left;
}
</style>
</head>
<body>
<h2>PDF Generated with flutter_html_to_pdf plugin</h2>
<table style="width:100%">
<caption>Sample HTML Table</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>100</td>
</tr>
<tr>
<td>February</td>
<td>50</td>
</tr>
</table>
<p>Image loaded from web</p>
<img src="https://i.imgur.com/wxaJsXF.png" alt="web-img">
</body>
</html>
""";
Directory appDocDir = await getApplicationDocumentsDirectory();
final targetPath = appDocDir.path;
final targetFileName = "example-pdf";
final generatedPdfFile = await FlutterHtmlToPdf.convertFromHtmlContent(
htmlContent: htmlContent,
printPdfConfiguration: PrintPdfConfiguration(
targetDirectory: targetPath,
targetName: targetFileName,
printSize: PrintSize.A4,
printOrientation: PrintOrientation.Portrait,
),
); The htmlContent is what you will be printing. Whatever renders when you open the htmlContent on a web browser should be your expected results in pdf (generatedPdfFile). |
all those changes have been merged into this repo |
No description provided.
The text was updated successfully, but these errors were encountered: