libbesign 1.0.4
SDKflutter
Platformandroidioswindowslinuxmacos
This is a library for digital signature on PDF.
libbesign
libbesign is a Dart package that allows you to process PDF files by adding signatures, seals, and images. It provides functions to read and manipulate PDF documents, process images, and add custom signatures to specific pages in the document.
Features
- Read and manipulate PDF documents
- Add images or QR codes as signatures
- Customize the position and size of the signatures or seals on PDF pages
- Easily integrate with existing PDF workflows
Installation
Add the following to your pubspec.yaml file:
dependencies:
libbesign: ^1.0.4
Usage
Here is an example of how to use libbesign to sign a PDF file. This package allows you to place a signature on a PDF page by specifying the position and size of the signature. Here's a sample function to sign a PDF file:
import 'dart:io';
import 'package:libbesign/libbesign.dart';
Future<void> main() async {
// Specify the PDF file path and other parameters
final pdfFilePath = '${Directory.current.path}/example/sample.pdf'; // Replace with your actual PDF file path
final page = 1; // The page number where the signature will be placed
final type = 0; // The type of content (e.g., 0 for invisible signature, 1 for signature with image, 2 for signature with QR code)
final character = "#"; // Position of visualization will place to this character
final imageorUrl = 'https://example.com'; // Path to the image or QR code URL
double x = 100; // X-coordinate where the signature will be placed
double y = 100; // Y-coordinate where the signature will be placed
double width = 50; // Width of the signature or image
double height = 50; // Height of the signature or image
final isSeal = 0; // 0 if it's signature, 1 if it is seal
// Create a Besign object with the specified parameters
final besign = Besign(pdfFilePath, imageorUrl, type, isSeal, page, character, x, y, width, height);
// Call the getParameter() method to process the PDF
Map<String, dynamic> parameters = await besign.getParameter();
String digest = parameters['digest']; // base64 format
// Continue to sign the digest
}
Example: sign() Function
This is a function to input CMS to PDF.
// Save the processed PDF to a new file
String outputPath = '${Directory.current.path}/example/output.pdf'; // Output file path
// Call the sign() method to process the PDF
await besign.sign(parameter, signature_base64, outputPath);
This function accepts:
- pdfParameter: The parameters from getParameter() function.
- signature_base64: A string that represents the signature of digest (base64 format) on from paramters.
- filePath: The file path where the signed PDF will be saved.