Transparent PNG images on Edge and Firefox v48 return 'RangeError: invalid array length', crashes PDF generator
When passing transparent PNG image as Data-URL to image property, we get 'RangeError: invalid array length' on Firefox v48(worked perfectly on v47) and 'Invalid offset/length when creating typed array' on Microsoft Edge. This crashes all of PDF generator completely. You can easily reproduce this on pdfmake playground 'IMAGES' tab, by passing PNG Data-URL with transparency. Also if we pass PNG without transparency we just see empty space where image should be visible.
I am also facing this issue. If anyone has a better solution please let us know.
Thanks
We're seeing the same problem, there's another workaround suggested here.
See this comment - it seems that Firefox 48 and IE edge are doing the TypedArray.subarray by just invoking the TypedArray constructor with additional parameters, which are not honored by the buffer implementation of pdfmake
I can't apply the workaround because pdfmake package is automatically assembled in bundle in our project using bower. How is there another way like removing the image transparancy or something similar?
I found a solution for our case where we use canvas and export it as dataUrl. Now we have something like:
img = canvas.toDataURL("image/jpeg", 1.0)
This will force the image not to have alpha channel and we will not have the issue.
Fixed. New version released.