Render to PDF using package:pdf/widgets.dart #1424
hadjiprocopis
started this conversation in
Ideas
Replies: 2 comments
-
Can you build a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My problem is that I need to display HTML in a widget and also print it (to PDF). Here is my case in detail: https://stackoverflow.com/questions/79484742/render-widget-content-to-pdf-or-render-html-to-widget-and-pdf-consistently
HtmlWidget
works well (thank you!) with my simple HTML (which contains lists and paragraphs and colored text as<span>
with different css classes). The css classes are handled well withcustomStylesBuilder: (element) { ...}
.However,
HTMLToPdf()
from packagehtmltopdfwidgets
renders the same HTML to PDF but it looks different thanHtmlWidget
contents. Additionally, I have not found a way to handle css classes like I do withHtmlWidget
.The first thing in mind when pressing the print icon on a GUI is that what you see inside the widget is what it will come out in the printer. Consistent rendering. But I fail to see that with my flutter app. (Apropos, that was very easy with rendering
div
contents to PDF in HTML).The
pdf
flutter package takes a list of widgets which then it renders to PDF. AndHTMLToPdf()
(from packagehtmltopdfwidgets
) returns a list of such widgets. These widgets are AFAICS a mirror of the common flutter widgets under their own namespace (in below code, that'spw
).My question is, can
HtmlWidget
made to return a list ofpdf
widgets instead? Then its content can be rendered to PDF.Where do I start?
Beta Was this translation helpful? Give feedback.
All reactions