Skip to content

Commit

Permalink
v2.4.18
Browse files Browse the repository at this point in the history
Fixed scope bug introduced in v2.4.17
  • Loading branch information
Aymkdn committed Apr 18, 2023
1 parent 8a661cd commit ec05571
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion browser.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/browser-2.4.17.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/browser-2.4.18.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h1>HTML to PDFMake convertor</h1>
<div id="pdf_ie" style="display:none;padding:3em">The PDF file is sent to you for download. Use a modern browser (like Chrome or Firefox) to display the PDF in this page.</div>
</div>
</div>
<script src="browser-2.4.17.js"></script>
<script src="browser-2.4.18.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdfmake@latest/build/pdfmake.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdfmake@latest/build/vfs_fonts.js"></script>
<script>
Expand Down
Binary file modified example.pdf
Binary file not shown.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function htmlToPdfMake(htmlText, options) {
this.ignoreStyles = (options && Array.isArray(options.ignoreStyles) ? options.ignoreStyles : []);

// A random string to be used in the image references
this.imagesByReferenceSuffix = (Math.random().toString(36).slice(2,8));
var imagesByReferenceSuffix = (Math.random().toString(36).slice(2,8));

// Used with the size attribute on the font elements to calculate relative font size
this.fontSizes = (options && Array.isArray(options.fontSizes) ? options.fontSizes : [10, 14, 16, 18, 20, 24, 28]);
Expand Down Expand Up @@ -446,9 +446,9 @@ function htmlToPdfMake(htmlText, options) {
if (this.imagesByReference) {
var src = element.getAttribute("data-src") || element.getAttribute("src");
var index = this.imagesRef.indexOf(src);
if (index>-1) ret.image = 'img_ref_'+this.imagesByReferenceSuffix+index;
if (index>-1) ret.image = 'img_ref_'+imagesByReferenceSuffix+index;
else {
ret.image = 'img_ref_'+this.imagesByReferenceSuffix+this.imagesRef.length;
ret.image = 'img_ref_'+imagesByReferenceSuffix+this.imagesRef.length;
this.imagesRef.push(src);
}
} else {
Expand Down Expand Up @@ -942,7 +942,7 @@ function htmlToPdfMake(htmlText, options) {
result = {content:result, images:{}};
this.imagesRef.forEach(function(src, i) {
// check if 'src' is a JSON string
result.images['img_ref_'+this.imagesByReferenceSuffix+i] = (src.startsWith("{") ? JSON.parse(src) : src);
result.images['img_ref_'+imagesByReferenceSuffix+i] = (src.startsWith("{") ? JSON.parse(src) : src);
});
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-to-pdfmake",
"version": "2.4.17",
"version": "2.4.18",
"description": "Convert HTML code to PDFMake",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ec05571

Please sign in to comment.