Bangla PDF Fixer 🔧

Stand With Palestine

Bangla PDF Fixer is a Flutter package designed to fix broken Bangla fonts in PDFs, ensuring accurate rendering of Bangla characters with 22+ high-quality custom fonts.

A lightweight, focused solution for Bangla font issues—nothing more, nothing less.

Note: This package focuses exclusively on Bangla font correction. For advanced PDF generation features, consider pdf_maker.

Bangla PDF Fixer


Features

  • 22+ Bangla fonts for effortless customization of PDF text.
  • Automatically rearranges complex Bangla characters for correct display.
  • Seamless integration with Flutter PDF generation workflows.
  • Ready-to-use Bangla widgets: text, headers, paragraphs, tables, and bullet lists.

Installation

Add to your pubspec.yaml:

dependencies:
  bangla_pdf_fixer: ^2.0.0

Install packages:

flutter pub get

Usage ✨

Note BanglaFontType: 🎨 The BanglaFontType class is a centralized enum of 22+ Bangla fonts for PDF generation. It simplifies working with Bangla text in Flutter by providing ready-to-use pw.TextStyle and pw.Text widgets, making font assignment seamless and reducing boilerplate.


Step 1: Initialize Fonts

Before using any widgets, initialize the font manager:

await BanglaFontManager().initialize();

This ensures all fonts are loaded and ready for use.


Step 2: Fix Bangla Text in PDFs

Use the .fix extension to automatically correct broken Bangla text:

BanglaText(
  'āĻŦāĻžāĻ‚āϞāĻž āϏāĻžāϧāĻžāϰāĻŖ āĻŸā§‡āĻ•ā§āϏāϟ',
  fontType: BanglaFontType.kalpurush,
  fontSize: 20,
),
pw.SizedBox(height: 10),
pw.Text(
  'āĻŦ⧇āρāĻšā§‡ āĻĨāĻžāĻ•āĻžāϰ āĻŽāϤ āφāύāĻ¨ā§āĻĻ āφāϰ āĻ•āĻŋāϛ⧁āχ āύ⧇āχāĨ¤'.fix,
  style: BanglaFontType.july.ts(
    fontSize: 24,
    fontWeight: pw.FontWeight.bold,
    color: PdfColors.red,
  ),
),

Most widgets apply .fix internally, so manual usage is optional.


Example: Generate a PDF in Flutter

import 'package:bangla_pdf_fixer/bangla_pdf_fixer.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:path_provider/path_provider.dart';
import 'package:open_file/open_file.dart';
import 'dart:io';

Future<void> generateAndOpenPdf() async {
  await BanglaFontManager().initialize();

  final pdf = pw.Document();

  pdf.addPage(
    pw.Page(
      build: (context) => pw.Column(
        crossAxisAlignment: pw.CrossAxisAlignment.start,
        children: [
          BanglaText(
            'āĻŦāĻžāĻ‚āϞāĻž āϏāĻžāϧāĻžāϰāĻŖ āĻŸā§‡āĻ•ā§āϏāϟ',
            fontType: BanglaFontType.kalpurush,
            fontSize: 20,
          ),
          pw.SizedBox(height: 10),
          pw.Text(
            'āĻŦ⧇āρāĻšā§‡ āĻĨāĻžāĻ•āĻžāϰ āĻŽāϤ āφāύāĻ¨ā§āĻĻ āφāϰ āĻ•āĻŋāϛ⧁āχ āύ⧇āχāĨ¤'.fix,
            style: BanglaFontType.july.ts(
              fontSize: 24,
              fontWeight: pw.FontWeight.bold,
              color: PdfColors.red,
            ),
          ),
        ],
      ),
    ),
  );

  final dir = await getApplicationDocumentsDirectory();
  final file = File("${dir.path}/example.pdf");
  await file.writeAsBytes(await pdf.save());
  await OpenFile.open(file.path);
}

Step 3: Use PDF Fixer Widgets

Bangla PDF Fixer provides ready-to-use widgets that automatically handle font corrections:

These widgets integrate seamlessly with the pdf package, allowing you to focus on content while the package handles Bangla text corrections.


1. BanglaText

BanglaText(
  'āĻŦāĻžāĻ‚āϞāĻž āϏāĻžāϧāĻžāϰāĻŖ āĻŸā§‡āĻ•ā§āϏāϟ',
  fontType: BanglaFontType.kalpurush,
  fontSize: 18,
);

2. BanglaRichText

BanglaRichText(
  spans: [
    BanglaTextSpan('āĻŦāĻžāĻ‚āϞāĻž āĻŦā§‹āĻ˛ā§āĻĄ ', fontWeight: pw.FontWeight.bold),
    BanglaTextSpan('āĻāĻŦāĻ‚ āχāϟāĻžāϞāĻŋāĻ•', fontType: BanglaFontType.julyItalic),
  ],
);

3. BanglaHeader

BanglaHeader('āĻŦāĻžāĻ‚āϞāĻž āĻļāĻŋāϰ⧋āύāĻžāĻŽ');

4. BanglaParagraph

BanglaParagraph('āĻŦāĻžāĻ‚āϞāĻž āĻ…āύ⧁āĻšā§āϛ⧇āĻĻ āĻāĻ–āĻžāύ⧇ āϞ⧇āĻ–āĻž āĻšāĻŦ⧇āĨ¤');

5. BanglaBulletList

BanglaBulletList(
  items: ['āĻĒā§āϰāĻĨāĻŽ āφāχāĻŸā§‡āĻŽ', 'āĻĻā§āĻŦāĻŋāϤ⧀āϝāĻŧ āφāχāĻŸā§‡āĻŽ', 'āϤ⧃āϤ⧀āϝāĻŧ āφāχāĻŸā§‡āĻŽ'],
  bullet: '>',
);

6. BanglaTable

BanglaTable(
  data: [
    ['āύāĻžāĻŽ', 'āĻŦ⧟āϏ', 'āĻļāĻšāϰ'],
    ['āφāĻšāĻŽā§‡āĻĻ', '⧍ā§Ģ', 'āĻĸāĻžāĻ•āĻž'],
    ['āϏāĻžāϰāĻž', 'ā§Šā§Ļ', 'āϚāĻŸā§āϟāĻ—ā§āϰāĻžāĻŽ'],
    ['āϰāĻžāĻšā§āϞ', 'ā§¨ā§Ž', 'āϏāĻŋāϞ⧇āϟ'],
  ],
  fontType: BanglaFontType.tomalicca,
  fontSize: 16,
  fontWeight: pw.FontWeight.normal,
);

Step 4: TextStyle & Widget Shortcuts

// TextStyle shortcut
pw.Text(
  'āĻŦāĻžāĻ‚āϞāĻž āĻļāĻŋāϰ⧋āύāĻžāĻŽ'.fix,
  style: BanglaFontType.july.ts(
    fontSize: 24,
    fontWeight: pw.FontWeight.bold,
    color: PdfColors.red,
  ),
);

// Text widget shortcut
BanglaFontType.kalpurush.text(
  'āĻŦāĻžāĻ‚āϞāĻž āϞ⧇āĻ–āĻž',
  fontSize: 18,
  color: PdfColors.black,
);

Demo Preview đŸ“Ĩ

View a sample PDF output:

Click here to check the demo PDF


Contributing 🚀

Contributions are welcome! Whether you want to:

  • Report a bug
  • Suggest a feature
  • Improve widgets or documentation

Fork the repository, make changes, and submit a Pull Request. Together, we can enhance Bangla PDF Fixer! 💡


License

This project is licensed under the Apache License 2.0. Read the full license here.


Author

Maintained by AR Rahman Contact: arrahman.dev@outlook.com


Special Thanks 🙏✨

A big thank you to all Bangla font creators and contributors. Your efforts make high-quality, beautiful Bangla PDFs possible. 💖


⭐ If you find Bangla PDF Fixer helpful, please star the repository!

Libraries

bangla_pdf_fixer