dart_pdf_reader 1.0.1 copy "dart_pdf_reader: ^1.0.1" to clipboard
dart_pdf_reader: ^1.0.1 copied to clipboard

Small pure-dart library for parsing PDF files. Supports reading all pdf structures

example/example.dart

import 'dart:io';

import 'package:dart_pdf_reader/dart_pdf_reader.dart';
import 'package:dart_pdf_reader/src/model/pdf_page.dart';

Future<void> main(List<String> args) async {
  final inputFile = args[0];

  final stopWatch = Stopwatch()..start();
  final stream = ByteStream(File(inputFile).readAsBytesSync());
  // or stream = BufferedRandomAccessStream(FileStream(await File(inputFile).open()));
  print('Read in ${stopWatch.elapsedMilliseconds}ms');

  stopWatch.reset();
  final doc = await PDFParser(stream).parse();
  print('Parsed in ${stopWatch.elapsedMilliseconds}ms');

  stopWatch.reset();
  final catalog = await doc.catalog;
  print('Got catalog in ${stopWatch.elapsedMilliseconds}ms');

  stopWatch.reset();
  final pages = await catalog.getPages();
  print('Got pages in ${stopWatch.elapsedMilliseconds}ms');

  stopWatch.reset();
  final outlines = await catalog.getOutlines();
  print('Got outlines in ${stopWatch.elapsedMilliseconds}ms');

  stopWatch.reset();
  final firstPage = pages.getPageAtIndex(0);
  print('Got first page in ${stopWatch.elapsedMilliseconds}ms');

  print(outlines);
  print(firstPage);

  print('Walking page tree bottom to top');
  PDFPageNode? node = firstPage;
  while (node != null) {
    print(await node.resources);
    node = node.parent;
  }
  stopWatch.stop();
}
13
likes
140
pub points
77%
popularity

Publisher

verified publisherchimerapps.com

Small pure-dart library for parsing PDF files. Supports reading all pdf structures

Repository (GitHub)
View/report issues

Topics

#pdf #parser

Documentation

API reference

Funding

Consider supporting this project:

buymeacoffee.com
ko-fi.com

License

Apache-2.0 (LICENSE)

Dependencies

archive, charset, collection, meta

More

Packages that depend on dart_pdf_reader