Image
Embeds an image asset declared in assets. Width and height are constraints — the image scales proportionally unless both are set.
Asset declaration
Section titled “Asset declaration”Images must be declared in assets before use. The src attribute is the path of a PNG or JPEG file, which the SDK reads from the machine that renders the PDF. To supply the bytes yourself, call loadImage on the engine and leave src out (see Installation). The name uses lowercase letters, digits and -.
<lpdf version="1"> <assets> <image name="logo" src="logo.png"/> </assets> <document size="letter" margin="48pt"> <section> <layout> <img name="logo" width="120pt"/> </layout> </section> </document></lpdf>L.document({ size: 'letter', margin: '48pt', assets: { images: [{ name: 'logo', src: 'logo.png' }] } }, [ L.section(NoAttr, [ L.layout(NoAttr, [ L.img({ name: 'logo', width: '120pt' }), ]), ]),])L.document(DocumentAttr(size='letter', margin='48pt', assets=DocumentAssets(images=[ImageAttr(name='logo', src='logo.png')])), [ L.section(NoAttr, [ L.layout(NoAttr, [ L.img(ImgAttr(name='logo', width='120pt')) ]) ])])L::document(new DocumentAttr(size: 'letter', margin: '48pt', assets: new DocumentAssets(images: [new ImageAttr(name: 'logo', src: 'logo.png')])), [ L::section(NoAttr, [ L::layout(NoAttr, [ L::img(new ImgAttr(name: 'logo', width: '120pt')), ]), ]),])L.Document(new() { Size = "letter", Margin = "48pt", Assets = new DocumentAssets(Images: [new ImageAttr { Name = "logo", Src = "logo.png" }]) }, [ L.Section(NoAttr, [ L.Layout(NoAttr, [ L.Img(new() { Name = "logo", Width = "120pt" }), ]), ]),])Attributes
Section titled “Attributes”| Attribute | Type | Default | Description |
|---|---|---|---|
name |
string | — | Required. Asset name declared in assets |
width |
token/pt | — | Constrain width (aspect ratio preserved unless height also set) |
height |
pt | — | Constrain height |
padding |
spacing | — | Inner padding |
background |
color | — | Background behind image |
border |
string | — | Border |
radius |
token/pt | — | Corner radius (clips image) |
Fixed width
Section titled “Fixed width”<img name="logo" width="100pt"/>L.img({ name: 'logo', width: '100pt' })L.img(ImgAttr(name='logo', width='100pt'))L::img(new ImgAttr(name: 'logo', width: '100pt'))L.Img(new() { Name = "logo", Width = "100pt" })Fixed height
Section titled “Fixed height”<img name="photo" height="200pt"/>L.img({ name: 'photo', height: '200pt' })L.img(ImgAttr(name='photo', height='200pt'))L::img(new ImgAttr(name: 'photo', height: '200pt'))L.Img(new() { Name = "photo", Height = "200pt" })Rounded image
Section titled “Rounded image”<img name="avatar" width="48pt" height="48pt" radius="xxl"/>L.img({ name: 'avatar', width: '48pt', height: '48pt', radius: 'xxl' })L.img(ImgAttr(name='avatar', width='48pt', height='48pt', radius='xxl'))L::img(new ImgAttr(name: 'avatar', width: '48pt', height: '48pt', radius: 'xxl'))L.Img(new() { Name = "avatar", Width = "48pt", Height = "48pt", Radius = "xxl" })