Skip to content
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

JS regression: minified pdfmake errors #509

Closed
jpodeszfa opened this issue Jul 1, 2022 · 3 comments
Closed

JS regression: minified pdfmake errors #509

jpodeszfa opened this issue Jul 1, 2022 · 3 comments

Comments

@jpodeszfa
Copy link

I have encountered some problems with minified https://github.com/bpampuch/pdfmake (version 0.2.5). It used to work in minify version v2.10.0. Unfortunately, I could not prepare a minimal example.

File minified with command:

minify build/pdfmake.js

chrome error:

Uncaught TypeError: Cannot read properties of undefined (reading 'getHighWaterMark')
at 6577 (pdfmake.js:182:11415)
at e (pdfmake.js:194:140975)
at 2830 (pdfmake.js:182:6392)
at e (pdfmake.js:194:140975)
at 1680 (pdfmake.js:55:11696)
at e (pdfmake.js:194:140975)
at 6079 (pdfmake.js:194:15815)
at e (pdfmake.js:194:140975)
at 8617 (pdfmake.js:194:15977)
at e (pdfmake.js:194:140975)

git bisect output:

e7fcbe9 is the first bad commit
commit e7fcbe9
Author: Taco de Wolff [email protected]
Date: Sat Apr 2 14:48:10 2022 -0300

JS: merge sequential var declarations into another declaration

It appears, that this error does not occur with --js-keep-var-names parameter, but another error was encountered.

File minified with command:

minify --js-keep-var-names build/pdfmake.js

chrome error:

Uncaught (in promise) Error: SVGMeasure: Error: Attribute without value
Line: 0
Column: 66
Char: =
    at parseSVG (pdfmake.js:194:54321)
    at SVGMeasure.measureSVG (pdfmake.js:194:54520)
    at DocMeasure.measureSVG (pdfmake.js:193:19786)
    at pdfmake.js:193:16411
    at StyleContextStack.auto (pdfmake.js:194:53464)
    at DocMeasure.measureNode (pdfmake.js:193:15812)
    at DocMeasure.measureVerticalContainer (pdfmake.js:193:21494)
    at pdfmake.js:193:15970
    at StyleContextStack.auto (pdfmake.js:194:53464)
    at DocMeasure.measureNode (pdfmake.js:193:15812)

git bisect output:

ff4ee8b is the first bad commit
commit ff4ee8b
Author: Taco de Wolff [email protected]
Date: Sat May 28 09:27:37 2022 -0400

JS: use template literals when shorter than double/single quoted strings

Sample web page to reproduce errors:

<!DOCTYPE html>
<script src="pdfmake.js"></script>
<script src="vfs_fonts.js"></script>
<script>
  var emc2 = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><g><text x = "10" y = "25" font-size = "20"><tspan>e = mc<tspan baseline-shift = "super">2</tspan>        </tspan>        <tspan x = "10" y = "60">            T             <tspan baseline-shift = "sub">i+2</tspan>=T<tspan baseline-shift = "sub">i</tspan> + T <tspan baseline-shift = "sub">i+1</tspan></tspan></text></g>';

  pdfMake.createPdf({
    pageSize: 'A4',
    content: [
      'test',
      {
        svg: emc2,
      }
    ]
  }).open();
</script>
@tdewolff
Copy link
Owner

tdewolff commented Jul 1, 2022

Thanks for raising the issue, I will look into both cases

@tdewolff
Copy link
Owner

tdewolff commented Jul 1, 2022

The first bug has been fixed with the commit above. The other bug was actually caused by a665158

@tdewolff
Copy link
Owner

tdewolff commented Jul 1, 2022

Fixed! Thanks for bringing this up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants