addPage method
Implementation
Future<int?> addPage(UPdfDocument source, int index, {Rect? crop, int? rotate}) async {
final UPdfPage? page = await source.page(index);
if (page == null) return null;
final Map<int, int> map = _maps.putIfAbsent(source, () => <int, int>{});
final UPdfDict dict = page.dict.copy();
dict["Type"] = const UPdfName("Page");
dict["MediaBox"] = <Object?>[page.mediaBox.left, page.mediaBox.top, page.mediaBox.right, page.mediaBox.bottom];
final Rect box = crop ?? page.cropBox;
dict["CropBox"] = <Object?>[box.left, box.top, box.right, box.bottom];
dict["Rotate"] = rotate ?? page.rotation;
if (page.resources != null) dict["Resources"] = page.resources;
dict.entries.remove("Parent");
final int number = allocate();
_objects[number] = await _copyValue(source, dict, map, 0);
_pages.add(number);
return number;
}