open_pdf_annotation_engine 0.4.0 copy "open_pdf_annotation_engine: ^0.4.0" to clipboard
open_pdf_annotation_engine: ^0.4.0 copied to clipboard

PlatformAndroid

Android-first Flutter plugin for editable PDF annotations, sidecar persistence, notes export, flattened export, and open PDF write-back without a commercial SDK.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:open_pdf_annotation_engine/open_pdf_annotation_engine.dart';

void main() {
  runApp(const DemoApp());
}

class DemoApp extends StatelessWidget {
  const DemoApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Open PDF Annotation Engine v4')),
        body: const Padding(
          padding: EdgeInsets.all(16),
          child: DemoBody(),
        ),
      ),
    );
  }
}

class DemoBody extends StatelessWidget {
  const DemoBody({super.key});

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<String>(
      future: _demo(),
      builder: (context, snapshot) {
        return SelectableText(snapshot.data ?? 'Running example...');
      },
    );
  }

  Future<String> _demo() async {
    final engine = OpenPdfAnnotationEngine();
    final annotation = PdfAnnotation(
      type: AnnotationType.freeText,
      pageNumber: 1,
      color: const AnnotationColor(r: 220, g: 0, b: 0, opacity: 1),
      createdAtIso: DateTime.now().toUtc().toIso8601String(),
      rect: const PdfRect(left: 40, top: 80, right: 250, bottom: 120),
      text: 'Hello from v4',
      fontSize: 16,
      tool: DrawTool.text,
    );

    try {
      final result = await engine.saveAnnotations(
        pdfPath: '/path/to/input.pdf',
        documentId: 'sample',
        annotations: [annotation],
        mode: SaveMode.saveAsCopy,
        outputPdfPath: '/path/to/input_annotated.pdf',
        notesPdfPath: '/path/to/input+notes.pdf',
        flatten: false,
      );

      return [
        'success=${result.success}',
        'output=${result.outputPdfPath}',
        'notes=${result.notesPdfPath}',
        'message=${result.message}',
      ].join('\n');
    } catch (e) {
      return 'Replace the placeholder file paths in the example before running.\n$e';
    }
  }
}
0
likes
130
points
9
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Android-first Flutter plugin for editable PDF annotations, sidecar persistence, notes export, flattened export, and open PDF write-back without a commercial SDK.

Repository (GitHub)
View/report issues

Topics

#pdf #annotations #android #flutter-plugin

License

unknown (license)

Dependencies

collection, flutter, plugin_platform_interface, uuid

More

Packages that depend on open_pdf_annotation_engine

Packages that implement open_pdf_annotation_engine