Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Putting an image in a column doesn't work because of the width? #2814

Open
dupontbertrand opened this issue Nov 30, 2024 · 1 comment
Open

Comments

@dupontbertrand
Copy link

dupontbertrand commented Nov 30, 2024

Hi everyone, newbie here,

I have the impression that pdfmake has a bug when you try to put an image in a column, because it expects the width to be a number for the image, whereas you enter the width of the column in auto, percentage or star, and so the width is for the column and not for the image.
Sorry if this question has already been asked.

var documentDefinition = { images: { "logo": 'https://placehold.co/200x150.png', }, pageSize: 'A4', pageOrientation: 'landscape', content: [ { image: 'logo', }, { text: 'Testing' }, { columns: [ { width: 'auto', text: 'First column' }, { width: '*', text: 'Second column' }, { width: 100, text: 'Third column' }, { width: '20%', text: 'Fourth column' } ], } ] };
Is working fine, but :
var documentDefinition = { images: { "logo": 'https://placehold.co/200x150.png', }, pageSize: 'A4', pageOrientation: 'landscape', content: [ { image: 'logo', }, { text: 'Testing' }, { columns: [ { width: 'auto', image: 'logo', }, { width: '*', text: 'Second column' }, { width: 100, text: 'Third column' }, { width: '20%', text: 'Fourth column' } ], } ] };
return :

image

So my question is : How to put an image in a column ? 😄
Thank you 🙏

I'm using it in the browser with the 0.2.12 version

@wangz-code
Copy link

add width and height to image

{
            image: logo, // img base64
            width: 50,
            height: 50,
            alignment: 'left',
            margin: [0, 0, 0, 0],
}
QQ20241204-162107@2x QQ20241204-162026@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants