read_pdf_text 0.0.5 copy "read_pdf_text: ^0.0.5" to clipboard
read_pdf_text: ^0.0.5 copied to clipboard

outdated

This is a plugin that parses string out of pdf documents. It uses apache PDFbox to parse the pdf document. There is only one function so it is easy to use.

read_pdf_text #

This package parses text out of pdf documents and returns it as a string. The plugin uses PDFbox open source library.

Getting Started #

The package only has one function getPDFtext(path). Path being the file path to the pdf file you want to parse. I used file_picker package in the example to get the path of a pdf file. Check the example.

      class PDFreaderExample extends StatefulWidget {
		@override
		_PDFreaderExampleState createState() => _PDFreaderExampleState();
		}
		class _PDFreaderExampleState extends State<PDFreaderExample> {
		String _pdfText = '';
		bool _loading = false;

		@override
		Widget build(BuildContext context) {
			return Scaffold(
			floatingActionButton: FloatingActionButton(
				child: Icon(Icons.folder_open),
				onPressed: () {
				FilePicker.getFile().then((File file) async {
					if (file.path.isNotEmpty) {
					setState(() {
						_loading = true;
					});
				
					getPDFtext(file.path).then((pdfText) {
						final text = pdfText.replaceAll("\n", " ");
						setState(() {
						_pdfText = text;
						_loading = false;
						});
					});
					}
				});
				},
			),
			appBar: AppBar(
				title: const Text('Pdf plugin example app'),
			),
			body: SingleChildScrollView(
				child: _loading
					? Center(
						child: CircularProgressIndicator(),
					)
					: Text(_pdfText),
			),
			);
		}

			Future<String> getPDFtext(String path) async {
			String text = "";
				try {
					text = await ReadPdfText.getPDFtext(path);
				} on PlatformException {
					text = 'Failed to get pdf text.';
				}
				return text;
			}
		}  
36
likes
0
pub points
87%
popularity

Publisher

unverified uploader

This is a plugin that parses string out of pdf documents. It uses apache PDFbox to parse the pdf document. There is only one function so it is easy to use.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on read_pdf_text