pixel_to_pdf

A comprehensive attachment picker and document scanner for Flutter. Supports camera, gallery, file picking, and native document scanning with cropping.

Features

  • Document Scanning: Native document scanning with automatic edge detection and cropping (via Google ML Kit).
  • Camera: Take photos directly from the app.
  • Gallery Picker: Pick images from the gallery (single or multi-select).
  • File Picker: Pick any file from the device storage.
  • Image Cropping: Integrated image cropping using image_cropper.
  • PDF Generation: Automatically converts scanned documents into PDF files.

Installation

Add pixel_to_pdf to your pubspec.yaml:

dependencies:
  pixel_to_pdf: ^1.0.0

Android Setup

  1. Min SDK: Requires at least API 21.
  2. Permissions: Add this to your AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
  1. Image Cropper: To support image cropping, you must register the UCropActivity in your AndroidManifest.xml:
<activity
    android:name="com.yalantis.ucrop.UCropActivity"
    android:screenOrientation="portrait"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

Note

The package handles FileProvider internally using the authority ${applicationId}.pixel_to_pdf.fileprovider. No manual FileProvider setup is required unless there is a naming conflict.

iOS Setup

  1. Deployment Target: Requires at least iOS 14.0.
  2. Permissions: Add the following keys to your Info.plist:
<key>NSCameraUsageDescription</key>
<string>We need access to your camera to scan documents and take photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library to select images.</string>

Usage

import 'package:pixel_to_pdf/pixel_to_pdf.dart';

final results = await PixelToPdf.show(
  context,
  config: AttachmentConfig(
    uiStyle: AttachmentUIStyle.bottomSheet,
    features: [
      AttachmentFeature.scanDoc,
      AttachmentFeature.takePhoto,
      AttachmentFeature.fromGallery,
      AttachmentFeature.fromFiles,
    ],
  ),
);

Libraries

core/attachment_service
models/attachment_config
models/attachment_models
pixel_to_pdf
A comprehensive attachment picker and document scanner for Flutter. Supports camera, gallery, file picking, and native document scanning.
ui/attachment_picker_shell
widgets/app_image_viewer
widgets/attachment_feature_button
widgets/attachment_thumbnail