icon

Table of Contents

How to generate PDF documents with Flutterflow

1. Introduction

In today’s fast-paced digital landscape, creating high-quality mobile and web applications efficiently is crucial. FlutterFlow, a powerful platform, caters to this need by offering a visual, drag-and-drop interface. This tool enables users, regardless of coding skills, to build fully functional apps quickly and easily.

One essential feature modern applications often require is the ability to generate PDF documents. Whether for invoices, reports, or contracts, having a reliable PDF generator integrated into your app is indispensable. This is where CraftMyPDF, a versatile PDF generation API, comes into play.

The purpose of this blog post is to provide a step-by-step guide on generating PDFs in FlutterFlow using CraftMyPDF.

By following this guide, you’ll learn how to seamlessly incorporate PDF generation capabilities to create Business Contracts within your FlutterFlow projects, enhancing your application’s functionality and user experience.

2. Introduction to FlutterFlow and CraftMyPDF

2.1 FlutterFlow

FlutterFlow is a robust platform designed for building mobile and web applications using a visual, drag-and-drop interface. It allows users to create fully functional apps without extensive coding knowledge. 

Home page of FlutterFlow

Key features include:

  • Visual Development: Over 65 pre-built widgets and 150 professionally designed screen templates.
  • Real-Time Collaboration: Teams can edit and design together in real-time.
  • Code Generation and Export: Automatically generates clean Flutter code.
  • Integrations: Supports Firebase, Stripe, Algolia, and external APIs.
  • Deployment Options: Direct deployment to App Store, Play Store, or web.
  • Design Consistency: Allows for design libraries and consistent styling across projects.
  • Advanced Features: Supports authentication, data management, custom actions, Google Maps integration, and more.
  • Testing and Feedback: Includes a testing mode for live data and feedback collection.

FlutterFlow aims to make app development accessible and efficient, providing all the necessary tools for creating professional-grade applications.

2.2 CraftMyPDF

CraftMyPDF is a user-friendly platform designed to simplify PDF generation and customization. It provides a web-based drag-and-drop interface, making it easy to create customizable PDF templates.

Home page of CraftMyPDF

Key features include:

  • Drag & Drop Editor: Customize PDF templates with labels, images, QR codes, barcodes, and charts.
  • Import Existing PDFs: Add new elements while preserving the original layout.
  • Expressions & Formatting: Supports date-time, currency, custom formatting, and JavaScript for complex calculations.
  • Regional API Endpoints: Available in the US, EU, Singapore, and Australia.
  • PDF Generation API: Efficiently generates PDF documents with our PDF Generation API or images (JPEG/PNG) at scale.
  • Integrations and Automation: Integrates with Zapier, Make.com, Bubble.io and REST API for easy automation.

CraftMyPDF streamlines the process of creating and managing PDF documents, offering a powerful PDF generation API that integrates seamlessly with various platforms.

By combining the capabilities of FlutterFlow and CraftMyPDF, developers can enhance their applications with robust PDF generation features, creating a more versatile and user-friendly experience.

3. Generate PDFs for FlutterFlow and CraftMyPDF

Here is our use case for this article: Whenever someone fills out the form on the application and clicks on the “Generate Business Contract” button, the details entered by the user will be used to create a Business contract PDF.

Step 1: Getting Started with FlutterFlow

The first step is to set up the FlutterFlow project. Here’s how to do that:

1. Register on FlutterFlow: Create an account.

Flutterflow registration

2. Sign in: Access the FlutterFlow dashboard.

3. Create New Project:

  • Click on the “Create New” button in the top right corner.
  • Name your project and select a template or create a blank project. For this article, I am creating a blank project.

4. Project Setup: Customize the theme and select necessary options if needed, but we’ll skip additional setup for this article.

Project setup step

5. Design Application:

  • Create a basic layout with input boxes and a button on the first page.
  • Add another page and add a PDFViewer widget on a second page to display the generated PDF.

Application first page

This completes the design part of our application.

Step 2: Designing the PDF Layout with CraftMyPDF

1. Register on CraftMyPDF: Sign in to your account.

2. Create PDF Template:

  • Click on “New PDF Template”.
  • Name the template and select “Business Contract”.

Create pdf template screen

3. Edit Template:

   – Use the WYSIWYG Editor to customize the content. Double click on text in the template to open the WYSIWYG Editor.

WYSIWYG editor
  • Add scope, duration, and terms of your contract.
  • Replace dynamic information with expressions. For this you need data fields to be added in the “Data” tab as JSON. Once they are in place, in editor you can use the insert expressions button to insert the right data field expression at the right place in your text.

WYSIWYG editor

4. Add Components: Insert images, QR codes, barcodes, etc., where needed.

5. Save Template: Click on Save to save the pdf template design.

Now our PDF template is ready.

Step 3: Implementing PDF Generation Logic in FlutterFlow

Now that we have application design and PDF template ready, the next step is to start connecting pieces together. Let’s first create an API call to generate PDFs from the template designed in CraftMyPDF using the data entered by the user in our application inputs.

i. Create an API Call

1. API Setup:

  • Click on “API Calls” in the side panel.
  • Click on “Add+” to add a new API Call named “Create PDF”.

2. Add Headers:

  • `x-api-key: [YOUR API KEY]`
  • `Content-Type: application/json`

   The API Key can be obtained from the API Integration tab in CraftMyPDF.

api call

3. Variables and Body:

  • Click on the Variables tab and add the necessary dynamic variables.

Variables in api call
  • Click on the Body tab to enter the template ID and data in the Body. You can use the dynamic variables that were added in the previous step.

Body of api call

4. Save API Call.

ii. Create a Data Schema

Now lets create a data schema for storing API responses.

1. Data Schema Setup:

  • In the “Data Types” tab, create a new schema named “CraftMyPDFResponse”.
  • Add the following fields to this schema: `file` and `status`.

Data schema

iii. Response and Test

Now that we have API call and Data Schema ready, lets connect the response of API call to Data Schema.

API response

1. Connect API to Data Schema:

  • In “API Calls”, select “Response & Test”  for the API Call created above.
  • Click on “Test API Call” to test the API Call and select “Parse as Data Type” to parse it as “CraftMyPDFResponse”.

Response data schema mapping
  • Then click on “Add JSON Path” for the fields that you want to map to the response, you may select $.file and $status

Now that we have created an API call, Data Schema and connected both together, lets configure our application to trigger this API call and once executed fetch the details to show the PDF generated.

iv. Integrating the PDF generation logic

  1. Click on the button “Generate Contract PDF” and go to Actions from the right side properties panel.

Actions panel
  1. Click on “Open” next to “Action Flow Editor
  1. In “On Tap” tab, click “Add Action
  1. Under “Select Action” choose “Navigate to” and then choose the second page we used for displaying PDF.
Navigate action config
  1. Now on the same action click on “Define” in “Parameters” section and then click on “Add Parameter” in the window you presented on the right panel.
  1. Give the parameter a name, select “Data Type” in Type and choose “CraftMyPDFResponse” in the next dropdown which is the data type we created while creating an API call above. And click on “Confirm.
Navigate action param defining
  1. Click on the “Pass” button that you will see now on navigate action’s parameter section to pass the created parameter to the second page while navigating.
  1. Expand the dropdown of the parameter being passed and set value as follows

Navigate action param config

Now your first action is set and ready to use. Let’s set a second action now on the same button.

  1. Click on the + icon at the bottom of the first action and select “Add Action”.
  1. In the Select Action search box, type “API” and select “API Call” as our action. This is because we have to make an API call to CraftMyPDF whenever someone clicks on this button to generate the PDF.
  1. Set variables for inputs on our form to be passed in order to replace values while PDF generation and set output variables of API call a name.

API call action config
  1. Now all our configurations are done for the first page. 

So let’s move on to the second page. Select our second page we created above from the page selector on the left panel.

Second page select
  1. Select the “PDFViewer” widget added on this page and in the right properties panel go to “Network Path” 

Set network path for pdfviewer

This completes all our configuration and application settings on flutterflow. Now we have to test this.

Step 4: Testing and Debugging the FlutterFlow App

Before going live and publishing your app, let’s test the application if it is working well. To do this, we have to start running our application in test mode of FlutterFlow.

Click on the button in the top right corner of your FlutterFlow window to start the test and debug mode.

Test mode

It takes some time to load the application in test mode and has the time limit of 12 minutes per session. After which you have to start a new test session.

In the test session, simply enter all your inputs on the form of the application we designed and then click on the button. This should generate the PDF with all those inputs which you have given in the PDF template we created on CraftMyPDF and then show you the business contract PDF on screen.

It also shows you what are the values being set in runtime, so that in case of any error, you can go and check where the error lies.

Debug panel

Step 5: Enhancing the PDF Generation Feature

In order to customize PDF templates further and add advanced tools such as Barcode, QR code, or charts, etc. you have relevant tools on CraftMyPDF’s component section.

You can drag them onto your pdf as per your requirement and configure them.

CraftMyPDF’s components

Here is the documentation that can help you learn more about adding these to PDF template-

https://support.craftmypdf.com/components-basic

Step 6: Deploying Your Application

Finally, deploy the application for live use.

1. Deploy:

  • Click the drop-down in the top right corner and select “Go to Settings”.
  • Switch on “Web (enables deep linking)”
  • Click on the Run arrow button to share a stable version.
  • Next, click the Upload button to publish your app to the web.

Deploy app options 1
Deploy app options 2

2. Share URL: Copy the URL from the same dropdown in the “Publish to the domain(s) below” section and share it with anyone to give access to your application.

Conclusion

Generating PDF documents with FlutterFlow and CraftMyPDF significantly enhances your app’s capabilities. By following the steps to set up, design, implement, test, and deploy, you can seamlessly integrate robust PDF generation features into your projects. 

To fully leverage the power of CraftMyPDF, we encourage you to sign up and experiment with its features. The platform offers a versatile PDF generation API that integrates seamlessly with FlutterFlow, making it an excellent choice for developers.

For further learning, check out these additional resources:

We hope this guide helps you integrate PDF generation into your FlutterFlow projects effortlessly. Sign up now to experience the features of CraftMyPDF. Happy coding!

Recent Posts
blog

How to generate PDF documents with Flutterflow

The purpose of this blog post is to provide a step-by-step guide on generating PDFs in FlutterFlow using CraftMyPDF.

By following this guide, you’ll learn how to seamlessly incorporate PDF generation capabilities to generate Business Contracts into your FlutterFlow projects, enhancing your application’s functionality and user experience.

Read More »
blog

What’s Canva API?

The Canva API is designed for plug-ins that enhance Canva’s features. Canva doesn’t provide an API for automating content creation or generation.

If you’re looking to create or generate content like PDFs or images from reusable templates, CraftMyPDF is the perfect solution.

Read More »
blog

How to Overlay Text on an Image in HTML and CSS

CraftMyPDF’s Image Generation API: Now, if coding isn’t really your thing or you just want a quicker solution, CraftMyPDF has got you covered. Their API is designed to make the process of generating images with text overlays a breeze.

Read More »
blog

Generate PDFs in C# with 8 Libraries (2024 Updated)

In this article, we will cover different options available, including using libraries such as iTextSharp and PdfSharp, cloud-based APIs such as CraftMyPDF, built-in classes in the .NET Framework like the PrintDocument class, and the Microsoft Office Interop library.

Read More »
blog

How to generate PDF documents with 4 Popular PHP Libraries (Updated 2024)

There are various libraries available to generate PDF documents with PHP such as FPDF, TCPDF, or DOMPDF. These libraries provide a wide range of features for creating PDF documents, such as setting page size, margins, fonts, and images.

In this article, I would briefly discuss some of these libraries along with some code snippets and show you how to generate a PDF document using PHP and CraftMyPDF.

Read More »
blog

How to Dynamically Create a Trackable QR Code in a PDF Without Coding

In this article, we’ll explore a range of topics including free QR code tools, tips and tricks for using QR codes effectively, and various use cases.

In addition, we will guide you through automating the generation of dynamic QR codes using Zapier, Airtable, and CraftMyPDF’s PDF or image generation APIs.

Read More »
blog

A Guide to Generate Barcodes and QRcodes

In this article, we’ll explore barcodes and QR codes, discussing their applications and how they’re used in various scenarios. I’ll guide you through the steps to create these codes using Python and Node.js. Additionally, we’ll look at how to generate barcodes and QR codes with CraftMyPDF, which supports REST API and integrates seamlessly with no-code platforms like Zapier, Make.com, and Bubble.

Read More »
Copyright ©2024 CraftMyPDF.com

Email us at [email protected] for support