title: Create a PDF file from Firebase Firestore collection in flutter
body: <p>I have various collections in Firestore,I want to create a button which saves the data fetched from specific collection into a PDF file.
  I don't know how to use <a href="https://pub.dev/packages/pdf" rel="nofollow noreferrer">PDF</a> package for saving the data fetched via query into a PDF file.</p>
  <p>I have a demo code which fetch data from Firestore collection and show it in list view, now I want to create a button over there which will allow the user to download that fetched data into a PDF and save that PDF to device.</p>
  <p>below is the code which shows list view of data fetched from that collection</p>
  <pre><code> Container buildUserPosts() {
    Future&lt;List&lt;NewsPost&gt;&gt; getPosts() async {
      List&lt;NewsPost&gt; posts = [];
      var snap = await FirebaseFirestore.instance
          .collection('News')
          .orderBy(&quot;timestamp&quot;)
          .get();
  
      for (var doc in snap.docs) {
         posts.add(NewsPost.fromDocument(doc));
      }
  
      return posts.reversed.toList();
    }
    return Container(
        child: FutureBuilder&lt;List&lt;NewsPost&gt;&gt;(
      future: getPosts(),
      builder: (context, snapshot) {
        if (!snapshot.hasData) {
          return Container(
              alignment: FractionalOffset.center,
              padding: const EdgeInsets.only(top: 10.0),
              child: CircularProgressIndicator());
        } else {
          return Column(
              children: snapshot.data!.map((NewsPost imagePost) {
            return imagePost;
          }).toList());
        }
      },
    ));
  </code></pre>
  <p>Now I want this data to be saved in a PDF but unable to figure how to achieve it. Please suggest how it can be done?</p>