-
Notifications
You must be signed in to change notification settings - Fork 26
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
Is it possible to use pdfkit link method to generate hyperlinks inside the table? #18
Comments
Hi, you can add And you can change the text color using {
id: 'description',
header: 'Product',
cache: false,
renderer(tb, data, draw) {
if (draw) {
tb.pdf.fillColor('red'); return data.description
}
return ``;
}
} |
Hi @tafel thanks so much for your description here, however, I am struggling a bit to get a link to actually work, can you perhaps show what the column configuration should look like for passing a dynamic link into a field? Thanks so much! Here's what I have, I've also tried different variations, but I'm just not sure how to do that. Thanks
|
When you have special needs, like dynamic links or images, you will need to manage yourself the drawing. Here's an example of how to add your dynamic link: // column definition
{
id: 'description',
header: 'Product',
align: 'left',
link: 'https://duckduckgo.com/?q=xxx',
cache: false,
renderer(tb, data, draw, column, pos) {
if (!draw) {
// we are calculating cell height. We only need text now.
return data.description;
} else {
// we are drawing content on the page. You probably will
// need to adjust `pos.x` and `pos.y` as well as cell width,
// depending on the cell padding you want.
tb.pdf.text(data.description, pos.x, pos.y, {
...column,
link: column.link.replace('xxx', data.id),
height: data._renderedContent.height, // this value is automatically calculated
width: column.width
});
}
}
}
// sample data
{ id: 'abc', description: 'Product 1' } |
That is exactly what I needed, thank you very much! |
@tafel Just letting you know your solution worked, thanks :) |
Do you know how to apply font or change color? |
Do you know how to apply font or change color? |
No description provided.
The text was updated successfully, but these errors were encountered: