pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Transparent PNG images on Edge and Firefox v48 return 'RangeError: invalid array length', crashes PDF generator

Open eeedvisss opened this issue 10 years ago • 6 comments

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.

eeedvisss avatar Aug 04 '16 07:08 eeedvisss

I am also facing this issue. If anyone has a better solution please let us know.

Thanks

ashish-jain-mp avatar Aug 05 '16 12:08 ashish-jain-mp

We're seeing the same problem, there's another workaround suggested here.

hillelcoren avatar Aug 08 '16 20:08 hillelcoren

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

FastestRobot avatar Aug 21 '16 11:08 FastestRobot

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?

mikaoelitiana avatar Oct 13 '16 08:10 mikaoelitiana

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.

mikaoelitiana avatar Oct 13 '16 09:10 mikaoelitiana

Fixed. New version released.

liborm85 avatar Dec 23 '16 07:12 liborm85