{"id":2295,"date":"2022-07-10T08:25:02","date_gmt":"2022-07-10T03:25:02","guid":{"rendered":"https:\/\/www.edopedia.com\/blog\/?p=2295"},"modified":"2022-07-10T08:25:04","modified_gmt":"2022-07-10T03:25:04","slug":"flutter-create-pdf-using-syncfusion-library","status":"publish","type":"post","link":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/","title":{"rendered":"Flutter Create PDF Using Syncfusion Library"},"content":{"rendered":"\n<p>Flutter Project to Create PDF Document Using Syncfusion Library and Add Text, Images &amp; Table inside it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">code.dart<\/h2>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;dart&quot;,&quot;mime&quot;:&quot;application\/dart&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Dart&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;dart&quot;}\">import 'dart:typed_data';\nimport 'package:flutter\/services.dart' show rootBundle;\n\nimport 'package:flutter\/material.dart';\nimport 'package:syncfusion_flutter_pdf\/pdf.dart';\n\nimport 'mobile.dart' if (dart.library.html) 'web.dart';\n\nvoid main() {\n  runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n  \/\/ This widget is the root of your application.\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      title: 'Flutter Demo',\n      theme: ThemeData(\n        \/\/ This is the theme of your application.\n        \/\/\n        \/\/ Try running your application with &quot;flutter run&quot;. You'll see the\n        \/\/ application has a blue toolbar. Then, without quitting the app, try\n        \/\/ changing the primarySwatch below to Colors.green and then invoke\n        \/\/ &quot;hot reload&quot; (press &quot;r&quot; in the console where you ran &quot;flutter run&quot;,\n        \/\/ or simply save your changes to &quot;hot reload&quot; in a Flutter IDE).\n        \/\/ Notice that the counter didn't reset back to zero; the application\n        \/\/ is not restarted.\n        primarySwatch: Colors.blue,\n      ),\n      home: MyHomePage(title: 'Flutter Demo Home Page'),\n    );\n  }\n}\n\nclass MyHomePage extends StatefulWidget {\n  MyHomePage({Key key, this.title}) : super(key: key);\n\n  \/\/ This widget is the home page of your application. It is stateful, meaning\n  \/\/ that it has a State object (defined below) that contains fields that affect\n  \/\/ how it looks.\n\n  \/\/ This class is the configuration for the state. It holds the values (in this\n  \/\/ case the title) provided by the parent (in this case the App widget) and\n  \/\/ used by the build method of the State. Fields in a Widget subclass are\n  \/\/ always marked &quot;final&quot;.\n\n  final String title;\n\n  @override\n  _MyHomePageState createState() =&gt; _MyHomePageState();\n}\n\nclass _MyHomePageState extends State&lt;MyHomePage&gt; {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      body: Center(\n        child: ElevatedButton(\n          child: Text('Create PDF'),\n          onPressed: _createPDF,\n        ),\n      ),\n    );\n  }\n\n  Future&lt;void&gt; _createPDF() async {\n    PdfDocument document = PdfDocument();\n    final page = document.pages.add();\n\n    page.graphics.drawString('Welcome to PDF Succinctly!',\n        PdfStandardFont(PdfFontFamily.helvetica, 30));\n\n    page.graphics.drawImage(\n        PdfBitmap(await _readImageData('Pdf_Succinctly.jpg')),\n        Rect.fromLTWH(0, 100, 440, 550));\n\n    PdfGrid grid = PdfGrid();\n    grid.style = PdfGridStyle(\n        font: PdfStandardFont(PdfFontFamily.helvetica, 30),\n        cellPadding: PdfPaddings(left: 5, right: 2, top: 2, bottom: 2));\n\n    grid.columns.add(count: 3);\n    grid.headers.add(1);\n\n    PdfGridRow header = grid.headers[0];\n    header.cells[0].value = 'Roll No';\n    header.cells[1].value = 'Name';\n    header.cells[2].value = 'Class';\n\n    PdfGridRow row = grid.rows.add();\n    row.cells[0].value = '1';\n    row.cells[1].value = 'Arya';\n    row.cells[2].value = '6';\n\n    row = grid.rows.add();\n    row.cells[0].value = '2';\n    row.cells[1].value = 'John';\n    row.cells[2].value = '9';\n\n    row = grid.rows.add();\n    row.cells[0].value = '3';\n    row.cells[1].value = 'Tony';\n    row.cells[2].value = '8';\n\n    grid.draw(\n        page: document.pages.add(), bounds: const Rect.fromLTWH(0, 0, 0, 0));\n\n    List&lt;int&gt; bytes = document.save();\n    document.dispose();\n\n    saveAndLaunchFile(bytes, 'Output.pdf');\n  }\n}\n\nFuture&lt;Uint8List&gt; _readImageData(String name) async {\n  final data = await rootBundle.load('images\/$name');\n  return data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);\n}<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Flutter Project to Create PDF Document Using Syncfusion Library and Add Text, Images &amp; Table inside it. code.dart<\/p>\n","protected":false},"author":1,"featured_media":1762,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112],"tags":[],"class_list":["post-2295","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Flutter Create PDF Using Syncfusion Library<\/title>\n<meta name=\"description\" content=\"Flutter Project to Create PDF Document Using Syncfusion Library and Add Text, Images &amp; Table inside it. code.dart import &#039;dart:typed_data&#039;; import\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Flutter Create PDF Using Syncfusion Library\" \/>\n<meta property=\"og:description\" content=\"Flutter Project to Create PDF Document Using Syncfusion Library and Add Text, Images &amp; Table inside it. code.dart import &#039;dart:typed_data&#039;; import\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/\" \/>\n<meta property=\"og:site_name\" content=\"Edopedia\" \/>\n<meta property=\"article:author\" content=\"trulyfurqan\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-10T03:25:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-10T03:25:04+00:00\" \/>\n<meta name=\"author\" content=\"Furqan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Furqan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Flutter Create PDF Using Syncfusion Library","description":"Flutter Project to Create PDF Document Using Syncfusion Library and Add Text, Images &amp; Table inside it. code.dart import 'dart:typed_data'; import","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/","og_locale":"en_US","og_type":"article","og_title":"Flutter Create PDF Using Syncfusion Library","og_description":"Flutter Project to Create PDF Document Using Syncfusion Library and Add Text, Images &amp; Table inside it. code.dart import 'dart:typed_data'; import","og_url":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/","og_site_name":"Edopedia","article_author":"trulyfurqan","article_published_time":"2022-07-10T03:25:02+00:00","article_modified_time":"2022-07-10T03:25:04+00:00","author":"Furqan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Furqan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/#article","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/"},"author":{"name":"Furqan","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339"},"headline":"Flutter Create PDF Using Syncfusion Library","datePublished":"2022-07-10T03:25:02+00:00","dateModified":"2022-07-10T03:25:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/"},"wordCount":25,"commentCount":0,"publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/02\/default_featured_image.jpg","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/","url":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/","name":"Flutter Create PDF Using Syncfusion Library","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/#primaryimage"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/02\/default_featured_image.jpg","datePublished":"2022-07-10T03:25:02+00:00","dateModified":"2022-07-10T03:25:04+00:00","description":"Flutter Project to Create PDF Document Using Syncfusion Library and Add Text, Images &amp; Table inside it. code.dart import 'dart:typed_data'; import","breadcrumb":{"@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/#primaryimage","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/02\/default_featured_image.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/02\/default_featured_image.jpg","width":880,"height":495,"caption":"Default Featured Image"},{"@type":"BreadcrumbList","@id":"https:\/\/www.edopedia.com\/blog\/flutter-create-pdf-using-syncfusion-library\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.edopedia.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Flutter Create PDF Using Syncfusion Library"}]},{"@type":"WebSite","@id":"https:\/\/www.edopedia.com\/blog\/#website","url":"https:\/\/www.edopedia.com\/blog\/","name":"Edopedia","description":"Coding\/Programming Blog","publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.edopedia.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.edopedia.com\/blog\/#organization","name":"Edopedia","url":"https:\/\/www.edopedia.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","width":400,"height":100,"caption":"Edopedia"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339","name":"Furqan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","caption":"Furqan"},"description":"Well. I've been working for the past three years as a web designer and developer. I have successfully created websites for small to medium sized companies as part of my freelance career. During that time I've also completed my bachelor's in Information Technology.","sameAs":["http:\/\/www.edopedia.com\/blog\/","trulyfurqan"],"url":"https:\/\/www.edopedia.com\/blog\/author\/furqan\/"}]}},"_links":{"self":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/comments?post=2295"}],"version-history":[{"count":0,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2295\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media\/1762"}],"wp:attachment":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media?parent=2295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/categories?post=2295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/tags?post=2295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}