Skip to content

Commit

Permalink
Merge branch 'master' into features/node-section
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Nov 8, 2024
2 parents d9afdc9 + 39fb7dc commit 53e59a3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.git*
.idea/
dev-playground/
docs/
examples/
Expand All @@ -9,7 +10,7 @@ yarn.lock
composer.json
bower.json
.editorconfig
.eslintrc.json
eslint.config.mjs
build-fonts.js
build-examples.js
babel.config.json
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

- Fixed speed in Node.js if is fetching URL for image or font redirected
- Fixed aspect ratio for image with exif orientation tag

## 0.3.0-beta.12 - 2024-11-03

- Added support PDF/A and PDF/UA (see [documentation](https://pdfmake.github.io/docs/0.3/document-definition-object/pdfa/))
Expand Down
8 changes: 8 additions & 0 deletions src/DocMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,16 @@ class DocMeasure {
this.convertIfBase64Image(node);

let image = this.pdfDocument.provideImage(node.image);

let imageSize = { width: image.width, height: image.height };

if (image.constructor.name === 'JPEG') {
// If EXIF orientation calls for it, swap width and height
if (image.orientation > 4) {
imageSize = { width: image.height, height: image.width };
}
}

this.measureImageWithDimensions(node, imageSize);

return node;
Expand Down
4 changes: 4 additions & 0 deletions src/URLResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const fetchUrl = (url, headers = {}) => {

h.get(url, options, res => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { // redirect url
res.resume();

fetchUrl(res.headers.location).then(buffer => {
resolve(buffer);
}, result => {
Expand All @@ -22,6 +24,8 @@ const fetchUrl = (url, headers = {}) => {
const ok = res.statusCode >= 200 && res.statusCode < 300;
if (!ok) {
reject(new TypeError(`Failed to fetch (status code: ${res.statusCode}, url: "${url}")`));
res.resume();
return;
}

const chunks = [];
Expand Down

0 comments on commit 53e59a3

Please sign in to comment.