Line data Source code
1 : part of '../worker.dart';
2 :
3 1 : Worker _buildPdfMerge({
4 : required List<String> inputPaths,
5 : required String outputPath,
6 : }) {
7 1 : if (inputPaths.isEmpty) {
8 1 : throw ArgumentError('inputPaths cannot be empty for pdfMerge');
9 : }
10 2 : for (final p in inputPaths) {
11 1 : NativeWorker._validateFilePath(p, 'inputPaths entry');
12 : }
13 1 : NativeWorker._validateFilePath(outputPath, 'outputPath');
14 1 : return PdfMergeWorker(inputPaths: inputPaths, outputPath: outputPath);
15 : }
16 :
17 1 : Worker _buildPdfCompress({
18 : required String inputPath,
19 : required String outputPath,
20 : int quality = 80,
21 : }) {
22 1 : NativeWorker._validateFilePath(inputPath, 'inputPath');
23 1 : NativeWorker._validateFilePath(outputPath, 'outputPath');
24 2 : if (quality < 1 || quality > 100) {
25 2 : throw ArgumentError('quality must be between 1 and 100, got $quality');
26 : }
27 1 : return PdfCompressWorker(
28 : inputPath: inputPath, outputPath: outputPath, quality: quality);
29 : }
30 :
31 1 : Worker _buildPdfFromImages({
32 : required List<String> imagePaths,
33 : required String outputPath,
34 : PdfPageSize pageSize = PdfPageSize.a4,
35 : int margin = 0,
36 : }) {
37 1 : if (imagePaths.isEmpty) {
38 1 : throw ArgumentError('imagePaths cannot be empty for pdfFromImages');
39 : }
40 2 : for (final p in imagePaths) {
41 1 : NativeWorker._validateFilePath(p, 'imagePaths entry');
42 : }
43 1 : NativeWorker._validateFilePath(outputPath, 'outputPath');
44 1 : return PdfFromImagesWorker(
45 : imagePaths: imagePaths,
46 : outputPath: outputPath,
47 : pageSize: pageSize,
48 : margin: margin,
49 : );
50 : }
|