AlessioLuciani / flutter-pdf-text

A plugin for Flutter that allows you to read the text content of PDF documents and convert it into strings.
MIT License
18 stars 45 forks source link

bangla join font breaking #35

Open refayet21 opened 6 months ago

refayet21 commented 6 months ago

This is my source code I have attached a pdf file where my Bangla font are breaking I didn't fiend any solution app_flutterMY_PDF.pdf

import 'dart:io'; import 'dart:typed_data';

import 'package:flutter/services.dart'; import 'package:open_file/open_file.dart'; import 'package:path_provider/path_provider.dart'; import 'package:pdf/pdf.dart'; import 'package:pdf/widgets.dart';

import 'pdf_to_img_conveter.dart';

class PdfGenerator { static late Font arFont;

static init() async { arFont = Font.ttf( (await rootBundle.load("assets/fonts/NotoSerifBengaliRegular.ttf"))); }

static createPdf() async { String path = (await getApplicationDocumentsDirectory()).path; File file = File(path + "MY_PDF.pdf");

Document pdf = Document();
pdf.addPage(_createPage());

Uint8List bytes = await pdf.save();
await file.writeAsBytes(bytes);
// createImg(file.path);
await OpenFile.open(file.path);

}

static Page _createPage() { return Page( // textDirection: TextDirection.rtl, theme: ThemeData.withFont( base: arFont, ), pageFormat: PdfPageFormat.a4, build: (context) { return Center( child: Container( child: Text( textDirection: TextDirection.ltr, "জ্বীন জাতি বিকল্প হলো ইসলাম ধর্মের মূল গ্রন্থ কুরআনে বর্ণিত একটি জীব সৃষ্টি। প্রাক ইসলামী যুগেও জ্বীন জাতি ", style: TextStyle(font: arFont, wordSpacing: 1), tightBounds: true, softWrap: true))); }); }

}