Juan Delgado
Committed by GitHub

Adds example on how to add an SVG from embedded assets (#1200)

@@ -83,6 +83,21 @@ pdf.addPage(pw.Page(build: (pw.Context context) { @@ -83,6 +83,21 @@ pdf.addPage(pw.Page(build: (pw.Context context) {
83 })); // Page 83 })); // Page
84 ``` 84 ```
85 85
  86 +To load an SVG from assets:
  87 +
  88 +```dart
  89 +String svgRaw =
  90 + await rootBundle.loadString('assets/path/to/file.svg');
  91 +
  92 +final svgImage = pw.SvgImage(svg: svgRaw);
  93 +
  94 +pdf.addPage(pw.Page(build: (pw.Context context) {
  95 + return pw.Center(
  96 + child: svgImage,
  97 + ); // Center
  98 +})); // Page
  99 +```
  100 +
86 To use a TrueType font: 101 To use a TrueType font:
87 102
88 ```dart 103 ```dart