1Text::Layout::PDFAPI2::UIsmeargeCEolnetmreinbtu(t3e)d PeTrelxtD:o:cLuamyeonutta:t:iPoDnFAPI2::ImageElement(3)
2
3
4

NAME

6       Text::Layout::PDFAPI2::ImageElement - <img> element for PDF images
7

DESCRIPTION

9       This class implements support for an "<img>" element. It can be used to
10       include inline images in marked-up texts.
11
12       The class provides the three mandatory methods according to the
13       requirements of Text::Layout::ElementRole.
14
15       parse
16           To parse the "<img>" tag in marked-up text.
17
18       bbox
19           To provide the augmented bounding box for the image.
20
21       render
22           To render the image using one of the PDF::API2 compatible
23           libraries.
24
25       An additional, overridable method getimage() is provided to actually
26       produce the desired image object. See "IMAGE PRODUCER"
27

THE "<img>" ELEMENT

29           <img attributes />
30
31       Note that the "<img>" element must be self-closed, i.e., end with "/>".
32
33       The image is placed at the current location in the text and aligned on
34       the baseline of the text. The image dimensions contribute to the
35       resultant bounding box of the formatted text. See "dx" and "dy" below.
36
37       All attributes are key=value pairs. The value should (but need not) be
38       enclosed in quotes.
39
40       Dimensional values may be a (fractional) number optionally postfixed by
41       "em" or "ex", or a percentage.  A number indicates points.  "em" values
42       are multiplied by the current font size and "ex" values are multiplied
43       by half the font size.
44
45       "src="IMAGE
46           Provides the source of the image. This can be the filename of a
47           jpg, png or gif image.
48
49       "width="NNN
50           The desired width for the image.  Dimensional.  The image is scaled
51           if necessary.
52
53       "height="NNN
54           The desired height for the image.  Dimensional.  The image is
55           scaled if necessary.
56
57       "dx="NNN
58           A horizontal offset for the image, wrt. the current location in the
59           text.  Dimensional.
60
61       "dy="NNN
62           Same, but vertical. Positive amounts move up.
63
64           Note the direction is opposite to the Pango "rise".
65
66       "scale="NNN
67           A scaling factor, to be applied after width/height scaling.  The
68           value may be expressed as a percentage.
69
70       "align="XXX
71           Align the image in the width given by "w="NNN.
72
73           Possible alignments are "left", "center", and "right".
74
75       "bbox="N
76           If true, the actual bounding box of an object is used for
77           placement.
78
79           By default the bounding box is only used to obtain the width and
80           height.
81
82           This attribute has no effect on image objects.
83
84       "w="NNN
85           The advance width of the image.  Dimensional.  Default advance is
86           the image width plus horizontal offset.  This overrides the advance
87           and may be zero.
88
89       "h="NNN
90           The advance height of the image.  Dimensional.  Default advance is
91           the image height plus vertical offset.  This overrides the advance
92           and may be zero.
93

CONSTRUCTOR

95       This class is usually instanciated in a Text::Layout register_element
96       call:
97
98           $layout->register_element
99             ( Text::Layout::PDFAPI2::ImageElement->new( pdf => $pdf ) );
100

IMAGE PRODUCER

102       The image object is produced with a call to method getimage(), that can
103       be overridden in a subclass.  The method gets a hash ref as argument.
104       This hash contains all the attributes and may be used for cacheing
105       purposes.
106
107       For example,
108
109           method getimage ($fragment) {
110               $fragment->{_img} //= $self->pdf->image($fragment->{src});
111           }
112
113       An overridden getimage() may produce a PDF XObject instead of an image
114       object. An XObject is treated similar to an image object, but is
115       aligned according to its bounding box if attribute "bbox" is set to a
116       true value, i.e., not zero.
117

SEE ALSO

119       Text::Layout, PDF::API2, PDF::Builder.
120

AUTHOR

122       Johan Vromans, "<JV at CPAN dot org>"
123

SUPPORT

125       This class is part of <Text::Layout>.
126
127       Development takes place on GitHub:
128       <https://github.com/sciurius/perl-Text-Layout>.
129
130       Please report any bugs or feature requests using the issue tracker for
131       Text::Layout on GitHub.
132

LICENSE

134       See Text::Layout.
135
136
137
138perl v5.38.0                      2023-11T-e0x1t::Layout::PDFAPI2::ImageElement(3)
Impressum