sub add_object { my ( $self, $o, $x, $y, %options ) = @_; my $scale_x = $options{"xscale"} || $options{"scale"} || 1; my $scale_y = $options{"yscale"} || $options{"scale"} || $scale_x; my $va = $options{valign} // "bottom"; my $ha = $options{align} // "left"; my $gfx = $self->{pdfgfx}; my $w = $o->width * $scale_x; my $h = $o->height * $scale_y; if ( $va eq "top" ) { $y -= $h; } elsif ( $va eq "middle" ) { $y -= $h/2; } if ( $ha eq "right" ) { $x -= $w; } elsif ( $ha eq "center" ) { $x -= $w/2; } $gfx->save; if ( ref($o) =~ /::Resource::XObject::Image::/ ) { # Image wants width and height. $gfx->object( $o, $x, $y, $w, $h ); } else { # XO_Form wants xscale and yscale. $gfx->object( $o, $x, $y, $scale_x, $scale_y ); } if ( $options{border} ) { my $bc = $options{"bordercolor"} || $options{"color"}; $gfx->stroke_color($bc) if $bc; $gfx->rectangle( $x, $y, $x+$w, $y+$h ) ->line_width( $options{border} ) ->stroke; } $gfx->restore; }