pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Inherited styles

Open brianmgray opened this issue 11 years ago • 2 comments

It would be helpful to be able to base styles on other styles. I am not sure how difficult this would be.

For example:

var dd = {
    content: [
        { 
            text: 'This is a header, using header style', 
            style: 'header' 
        },
        'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Confectum ponit legam, perferendis nomine miserum, animi. Moveat nesciunt triari naturam.\n\n',
        {
            text: 'Subheader 1 - using subheader style',
            style: 'subheader'
        },
        'Subheader above would appear bold!'
    ],
    styles: {
        header: {
            fontSize: 18,
            bold: true
        },
        subheader: {
            fontSize: 15,
            style: 'header'
        }
    }
}

brianmgray avatar Oct 27 '15 16:10 brianmgray

Implemented by commit https://github.com/bpampuch/pdfmake/commit/79c8e0b5cd8a935b458691e94d09cc4a440b6e9e new extends property for style.

Simple example:

var dd = {
	content: [
		{
			text: 'This is a header, using header style',
			style: 'header'
		},
		{
			text: 'Subheader 1 - using subheader style',
			style: 'subheader'
		}
	],
	styles: {
		header: {
			fontSize: 18,
			bold: true
		},
		subheader: {
			fontSize: 15,
			extends: 'header' // or array of strings
		},
	}
};

liborm85 avatar Jan 16 '26 13:01 liborm85

Feature released in version 0.3.3.

liborm85 avatar Jan 18 '26 10:01 liborm85