how can i make an image extraction from pdf file in flutter mobile app
(knowing that the file can contains text and images )
Future<void> _sendMediaMessage() async {
String Extraction_text = "";
FilePickerResult? pickedFile = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['pdf'],
);
if (pickedFile != null) {
file = File(pickedFile.files.single.path!);
try {
Uint8List fileBytes = await _readDocumentData(file!.path);
PdfDocument document = PdfDocument(inputBytes: fileBytes);
PdfTextExtractor extractor = PdfTextExtractor(document);
Extraction_text = extractor.extractText();
// _showResult(Extraction_text);
} catch (e) {
_showErrorDialog('Error', 'Failed to load the PDF document.');
}
} else {
_showErrorDialog(
'No File Selected', 'Please select a PDF file to upload.');
}
//add the text to the firebase
if (Extraction_text != "")
fileService.addFileText(FileTextModel(text: Extraction_text));
//here i want to make image extraction
//
if (file != null) {
ChatMessage chatMessage = ChatMessage(
user: currentUser,
createdAt: DateTime.now(),
text: "Explain this text for men" + Extraction_text,
// medias: [
// ChatMedia(url: //here, fileName: "", type: MediaType.image)
// ]
//and all the images extracted from the pdf file should be used here in the url above
);
_sendMessage(chatMessage);
}
}
i want to know how to make images extraction from pdf
(knowing that the file can contains text and images )
i find how to make text extraction and now i want the same for the images
and I’m looking for answer
New contributor
Eylemsam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.