Unable to merge image to vertical alignment and sharing that file. In this case the last image file will only added to the end of the mergeImage. Please see this code:
import 'package:image/image.dart' as im;
final path = (await getTemporaryDirectory()).path;
var i = 0;
List<String> paths = [];
await for (final page in Printing.raster(pdf, dpi: 72)) {
final png = await page.toPng();
final file = File('$path/page-${i.toString().padLeft(3, '0')}.png');
await file.writeAsBytes(png);
print('Saved to ${file.absolute.path}');
paths.add(file.absolute.path);
i++;
print('object');
}
int height = 0;
int width = im.decodeImage(File(paths.first).readAsBytesSync()).width;
for (var item in paths) {
final image = im.decodeImage(File(item).readAsBytesSync());
height += image.height + 10;
}
im.Image fullMergeImage;
int pos = 0;
for (var item in paths) {
print('object');
fullMergeImage = im.Image(width, height);
final image = im.decodeImage(File(item).readAsBytesSync());
im.copyInto(fullMergeImage, image, dstY: pos, blend: false);
pos += image.height + 10;
}
final documentDirectory = await getTemporaryDirectory();
final file = new File(documentDirectory.path + '.png');
file.writeAsBytesSync(im.encodeJpg(fullMergeImage));
await Share.shareFiles([file.absolute.path], text: 'Great picture');
Issue with fullMergeImage declaration.