CPDFImageAnnotation.fromPath constructor

CPDFImageAnnotation.fromPath({
  1. String? title,
  2. String? content,
  3. DateTime? createDate,
  4. required int page,
  5. String uuid = '',
  6. required CPDFRectF rect,
  7. required String filePath,
})

Creates an image annotation from a local file path.

Use this when the image already exists on the device file system, such as a cached export or a user-selected file.

Example:

final annotation = CPDFImageAnnotation.fromPath(
  page: 1,
  rect: const CPDFRectF(
    left: 60,
    top: 100,
    right: 240,
    bottom: 280,
  ),
  filePath: '/data/user/0/com.example.app/cache/signature.png',
);

Implementation

factory CPDFImageAnnotation.fromPath({
  String? title,
  String? content,
  DateTime? createDate,
  required int page,
  String uuid = '',
  required CPDFRectF rect,
  required String filePath,
}) {
  return CPDFImageAnnotation(
    title: title ?? '',
    content: content ?? '',
    createDate: createDate,
    page: page,
    uuid: uuid,
    rect: rect,
    imageData: CPDFImageData.fromPath(filePath),
  );
}