Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [20.x, 22.x]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ typings/
# dotenv environment variables file
.env

.DS_Store
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ The document must be wrapped in `<pdf></pdf>` tags
+ `<colors>` Color aliases, eg `<colors darkred="#880000"/>`
+ `<fonts>` Font aliases, eg `<fonts comic="Comic Sans Regular"/>`
+ `<filename>` Set document filename
+ `<title>` Set document title
+ `<styles>` Add or change page tag style definintions, eg: `<styles><redtext extends="span" color="red"/></styles>`
* Elements attributes can include:
- `extends="String"` Style definition to extend
Expand Down Expand Up @@ -117,5 +116,6 @@ The document must be wrapped in `<pdf></pdf>` tags
- `src="String"` Source of the image to draw relative to the template file
- `scale="Number"` Size of image relative to its original
- `fit="Boolean"` Fit image within the width and height without chaning its aspect ratio
- `alt="String"` Add alt text to an image to improve accessibility
* `<a>` Create a web link for the contained text.
- `href="String"` The link to go to when clicked. If no `href` is specified an href is created by adding `https://` to the beginning of the text
- `href="String"` The link to go to when clicked. If no `href` is specified an href is created by adding `https://` to the beginning of the text
4 changes: 3 additions & 1 deletion lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const defaults = {
left: 42.5,
right: 42.5,
bottom: 36
}
},
lang: 'en-GB',
pdfVersion: '1.7'
},
colors: {
grey: '#ddd'
Expand Down
10 changes: 9 additions & 1 deletion lib/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ class PDF {
}

imgTag(state, options) {
let imageSection = state.doc.struct('Sect');

state.doc.addStructure(imageSection);
let imgOptions = {};
if (options.pos.width) imgOptions.width = options.pos.width;
if (options.height) imgOptions.height = options.height;
Expand All @@ -405,7 +408,12 @@ class PDF {
let filePath = options.src;
if (!filePath || typeof filePath !== 'string') throw new Error('Invalid <img> src attribute');
if (!filePath.match(/^data:/)) filePath = path.resolve(this.config.basePath, filePath);
state.doc.image(filePath, state.doc.x, state.doc.y, imgOptions);
imageSection.add(
state.doc.struct('Figure', {alt: (options.alt? options.alt: '')}, () => {
state.doc.image(filePath, state.doc.x, state.doc.y, imgOptions);
})
);
imageSection.end();
}

indentTag(state, options, children) {
Expand Down
Loading
Loading