placementMatrix method

List<double> placementMatrix(
  1. PdfBox rect
)

The cm matrix that brings this appearance inside rect.

It is the PDFBox path (PDAcroForm.resolveTransformationMatrix): the transformed /BBox is scaled up to the size of the widget /Rect and then shifted to its lower-left corner. A zero dimension in the transformed box does not cause a division by zero: the scale stays at 1.

Implementation

List<double> placementMatrix(PdfBox rect) {
  final source = transformedBBox;
  final scaleX = source.width > 0 ? rect.width / source.width : 1.0;
  final scaleY = source.height > 0 ? rect.height / source.height : 1.0;
  return <double>[
    scaleX,
    0,
    0,
    scaleY,
    rect.left - source.left * scaleX,
    rect.bottom - source.bottom * scaleY,
  ];
}