Reputation: 562
Is there a way I can parse the contents of PDF
files into widgets or something more understandable or perhaps into something that can be modified and again converted to PDF format?
Upvotes: 6
Views: 1886
Reputation: 76
Adding to @alok-dubey's answer. The pdf package has a paid tier for $250 which includes:
This is very hard to find, but if you scroll to the bottom of the pub.dev page you will see a link to this page with more information: https://pub.nfet.net/pdf_crypto/
But looking at the OPs question, this is what they want.
The same publisher (nfet.net) also wrote the printing package which can be used to preview PDFs using the PdfPreview class.
Upvotes: 0
Reputation: 901
You can use pdf library to achieve this task
import 'dart:io';
import 'package:pdf/pdf.dart' as pw;
Import like this and then use following method to extract text from pdf
String loadPdf({required String pdfPath}) {
String text = "";
// Load the PDF file
var file = File(pdfPath);
var bytes = file.readAsBytesSync();
// Decode the PDF file
var pdf = pw.PdfDocument.fromBytes(bytes);
// Extract the text from the PDF
for (var page in pdf.pages) {
var pageText = page.getText();
text += pageText;
}
return text;
}
Upvotes: -2